Also follow HELM_PLUGINS when installing from http

This is effectively <https://github.com/helm/helm/pull/10008> but for the overridden case of `Path()` in `pkg/plugins/installer/http_installer.go`. Well slightly simpler because it can just use the directory already in `base`.

The test is copied nearly wholesale from that PR.

Signed-off-by: Graham Reed <greed@7deadly.org>
pull/11781/head
Graham Reed 3 years ago
parent 76157c6d06
commit d44c3d5152

@ -159,7 +159,7 @@ func (i HTTPInstaller) Path() string {
if i.base.Source == "" {
return ""
}
return helmpath.DataPath("plugins", i.PluginName)
return filepath.Join(i.base.PluginsDirectory, i.PluginName)
}
// cleanJoin resolves dest as a subpath of root.

@ -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")
}
}

Loading…
Cancel
Save