diff --git a/internal/plugin/installer/base.go b/internal/plugin/installer/base.go index c21a245a8..0b7a997fb 100644 --- a/internal/plugin/installer/base.go +++ b/internal/plugin/installer/base.go @@ -30,9 +30,17 @@ type base struct { func newBase(source string) base { settings := cli.New() + pluginsDirectory := settings.PluginsDirectory + for _, dir := range filepath.SplitList(settings.PluginsDirectory) { + if dir != "" { + pluginsDirectory = dir + break + } + } + return base{ Source: source, - PluginsDirectory: settings.PluginsDirectory, + PluginsDirectory: pluginsDirectory, } } diff --git a/internal/plugin/installer/base_test.go b/internal/plugin/installer/base_test.go index 62b77bde5..d5da12040 100644 --- a/internal/plugin/installer/base_test.go +++ b/internal/plugin/installer/base_test.go @@ -14,6 +14,8 @@ limitations under the License. package installer // import "helm.sh/helm/v4/internal/plugin/installer" import ( + "path/filepath" + "strings" "testing" ) @@ -27,11 +29,22 @@ func TestPath(t *testing.T) { source: "", helmPluginsDir: "/helm/data/plugins", expectPath: "", - }, { + }, + { source: "https://github.com/jkroepke/helm-secrets", helmPluginsDir: "/helm/data/plugins", expectPath: "/helm/data/plugins/helm-secrets", }, + { + source: "https://github.com/jkroepke/helm-secrets", + helmPluginsDir: strings.Join([]string{"/helm/data/plugins", "/helm/nfs/plugins"}, string(filepath.ListSeparator)), + expectPath: "/helm/data/plugins/helm-secrets", + }, + { + source: "https://github.com/jkroepke/helm-secrets", + helmPluginsDir: strings.Join([]string{"", "/helm/nfs/plugins"}, string(filepath.ListSeparator)), + expectPath: "/helm/nfs/plugins/helm-secrets", + }, } for _, tt := range tests {