@@ -400,26 +400,27 @@ func addPluginListRoute(config *HeadlampConfig, r *mux.Router) {
400400 }).Methods ("GET" )
401401}
402402
403- //nolint:gocognit,funlen,gocyclo
404- func createHeadlampHandler (config * HeadlampConfig ) http.Handler {
405- kubeConfigPath := config .KubeConfigPath
406-
407- config .StaticPluginDir = os .Getenv ("HEADLAMP_STATIC_PLUGINS_DIR" )
408-
409- logStartupInfo (config );
410-
403+ // setupPluginHandlers initializes the plugin cache and sets up handlers for plugins.
404+ func setupPluginHandlers (config * HeadlampConfig , skipFunc kubeconfig.ShouldBeSkippedFunc ) {
411405 plugins .PopulatePluginsCache (config .StaticPluginDir , config .PluginDir , config .cache )
412406
413- skipFunc := kubeconfig .SkipKubeContextInCommaSeparatedString (config .SkippedKubeContexts )
414-
415407 if ! config .UseInCluster || config .WatchPluginsChanges {
416- // in-cluster mode is unlikely to want reloading plugins.
417408 pluginEventChan := make (chan string )
418409 go plugins .Watch (config .PluginDir , pluginEventChan )
419410 go plugins .HandlePluginEvents (config .StaticPluginDir , config .PluginDir , pluginEventChan , config .cache )
420- // in-cluster mode is unlikely to want reloading kubeconfig.
421- go kubeconfig .LoadAndWatchFiles (config .KubeConfigStore , kubeConfigPath , kubeconfig .KubeConfig , skipFunc )
411+ go kubeconfig .LoadAndWatchFiles (config .KubeConfigStore , config .KubeConfigPath , kubeconfig .KubeConfig , skipFunc )
422412 }
413+ }
414+
415+ //nolint:gocognit,funlen,gocyclo
416+ func createHeadlampHandler (config * HeadlampConfig ) http.Handler {
417+ kubeConfigPath := config .KubeConfigPath
418+
419+ config .StaticPluginDir = os .Getenv ("HEADLAMP_STATIC_PLUGINS_DIR" )
420+
421+ logStartupInfo (config )
422+ skipFunc := kubeconfig .SkipKubeContextInCommaSeparatedString (config .SkippedKubeContexts )
423+ setupPluginHandlers (config , skipFunc )
423424
424425 // In-cluster
425426 if config .UseInCluster {
0 commit comments