pull/32115/merge
Zakhar Dvurechensky 9 hours ago committed by GitHub
commit 5457413561
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -32,10 +32,18 @@ func newBase(source string) base {
settings := cli.New()
return base{
Source: source,
PluginsDirectory: settings.PluginsDirectory,
PluginsDirectory: firstPluginDir(settings.PluginsDirectory),
}
}
func firstPluginDir(pluginsDirectory string) string {
paths := filepath.SplitList(pluginsDirectory)
if len(paths) == 0 {
return pluginsDirectory
}
return paths[0]
}
// Path is where the plugin will be installed.
func (b *base) Path() string {
if b.Source == "" {

@ -15,6 +15,7 @@ package installer // import "helm.sh/helm/v3/pkg/plugin/installer"
import (
"os"
"path/filepath"
"testing"
)
@ -32,6 +33,10 @@ func TestPath(t *testing.T) {
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: "/helm/user/plugins" + string(filepath.ListSeparator) + "/helm/shared/plugins",
expectPath: "/helm/user/plugins/helm-secrets",
},
}

@ -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.

@ -127,6 +127,23 @@ func TestHTTPInstaller(t *testing.T) {
}
func TestHTTPInstallerPathWithPluginPathList(t *testing.T) {
first := t.TempDir()
second := t.TempDir()
t.Setenv("HELM_PLUGINS", first+string(filepath.ListSeparator)+second)
source := "https://example.com/plugins/fake-plugin-0.0.1.tar.gz"
i, err := NewHTTPInstaller(source)
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
expect := filepath.Join(first, "fake-plugin")
if i.Path() != expect {
t.Fatalf("expected path %q, got %q", expect, i.Path())
}
}
func TestHTTPInstallerNonExistentVersion(t *testing.T) {
ensure.HelmHome(t)
srv := mockArchiveServer()

Loading…
Cancel
Save