diff --git a/pkg/plugin/installer/http_installer.go b/pkg/plugin/installer/http_installer.go index 3bcf71208..4ee4957a5 100644 --- a/pkg/plugin/installer/http_installer.go +++ b/pkg/plugin/installer/http_installer.go @@ -162,7 +162,7 @@ func (i HTTPInstaller) Path() string { if i.Source == "" { return "" } - return helmpath.DataPath("plugins", i.PluginName) + return filepath.Join(i.base.PluginsDirectory, i.PluginName) } // cleanJoin resolves dest as a subpath of root. diff --git a/pkg/plugin/installer/http_installer_test.go b/pkg/plugin/installer/http_installer_test.go index ed4b73b35..035cd5c38 100644 --- a/pkg/plugin/installer/http_installer_test.go +++ b/pkg/plugin/installer/http_installer_test.go @@ -348,3 +348,38 @@ func TestMediaTypeToExtension(t *testing.T) { } } } + +func TestHttpInstallerPath(t *testing.T) { + tests := []struct { + source string + pluginName string + helmPluginsDir string + expectPath string + }{ + { + source: "", + pluginName: "not-used", + helmPluginsDir: "/helm/data/plugins", + expectPath: "", + }, { + source: "https://github.com/jkroepke/helm-secrets", + pluginName: "helm-http-plugin", + helmPluginsDir: "/helm/data/plugins", + expectPath: "/helm/data/plugins/helm-http-plugin", + }, + } + + for _, tt := range tests { + + os.Setenv("HELM_PLUGINS", tt.helmPluginsDir) + ins := &HTTPInstaller{ + PluginName: tt.pluginName, + base: newBase(tt.source), + } + insPath := ins.Path() + if insPath != tt.expectPath { + t.Errorf("expected name %s, got %s", tt.expectPath, insPath) + } + os.Unsetenv("HELM_PLUGINS") + } +}