fix(plugin): install to first HELM_PLUGINS path entry

Signed-off-by: LarytheLord <llawlietbagsum@gmail.com>
pull/31906/head
LarytheLord 7 months ago
parent b4f4c4c2dd
commit c976a18a2f

@ -30,9 +30,17 @@ type base struct {
func newBase(source string) base { func newBase(source string) base {
settings := cli.New() settings := cli.New()
pluginsDirectory := settings.PluginsDirectory
for _, dir := range filepath.SplitList(settings.PluginsDirectory) {
if dir != "" {
pluginsDirectory = dir
break
}
}
return base{ return base{
Source: source, Source: source,
PluginsDirectory: settings.PluginsDirectory, PluginsDirectory: pluginsDirectory,
} }
} }

@ -14,6 +14,8 @@ limitations under the License.
package installer // import "helm.sh/helm/v4/internal/plugin/installer" package installer // import "helm.sh/helm/v4/internal/plugin/installer"
import ( import (
"path/filepath"
"strings"
"testing" "testing"
) )
@ -27,11 +29,22 @@ func TestPath(t *testing.T) {
source: "", source: "",
helmPluginsDir: "/helm/data/plugins", helmPluginsDir: "/helm/data/plugins",
expectPath: "", expectPath: "",
}, { },
{
source: "https://github.com/jkroepke/helm-secrets", source: "https://github.com/jkroepke/helm-secrets",
helmPluginsDir: "/helm/data/plugins", helmPluginsDir: "/helm/data/plugins",
expectPath: "/helm/data/plugins/helm-secrets", 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 { for _, tt := range tests {

Loading…
Cancel
Save