Skip to content

Commit

Permalink
backend: plugins: Remove .plugins from watch list
Browse files Browse the repository at this point in the history
This fix prevents the development app (when running npm run dev-only-app) from watching for static plugins locally, which causes an endless loop of refreshes to the app.

Fixes: #1937

Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
  • Loading branch information
skoeva committed May 2, 2024
1 parent ce248d6 commit af516e3
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions backend/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,17 @@ func flagset() *flag.FlagSet {
// Gets the default plugins-dir depending on platform.
func defaultPluginDir() string {
// These are the folders we use for the default plugin-dir.
// - the passed in pluginDir if it's not empty.
// - "./.plugins" if it exists.
// - ~/.config/Headlamp/plugins exists or it can be made
// - "./.plugins" if the ~/.config/Headlamp/plugins can't be made.
// Windows: %APPDATA%\Headlamp\Config\plugins
// (for example, C:\Users\USERNAME\AppData\Roaming\Headlamp\Config\plugins)
pluginDirDefault := "./.plugins"

if folderExists(pluginDirDefault) {
return pluginDirDefault
}

// https://www.npmjs.com/package/env-paths
// https://pkg.go.dev/os#UserConfigDir
userConfigDir, err := os.UserConfigDir()
if err != nil {
logger.Log(logger.LevelError, nil, err, "getting user config dir")

return pluginDirDefault
return "./.plugins"
}

pluginsConfigDir := filepath.Join(userConfigDir, "Headlamp", "plugins")
Expand All @@ -207,22 +199,12 @@ func defaultPluginDir() string {
if err != nil {
logger.Log(logger.LevelError, nil, err, "creating plugins directory")

return pluginDirDefault
return "./.plugins"
}

return pluginsConfigDir
}

// folderExists(path) returns true if the folder exists.
func folderExists(path string) bool {
info, err := os.Stat(path)
if os.IsNotExist(err) {
return false
}

return info.IsDir()
}

func GetDefaultKubeConfigPath() string {
user, err := user.Current()
if err != nil {
Expand Down

0 comments on commit af516e3

Please sign in to comment.