|
|
|
@ -37,7 +37,6 @@ import (
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v4/internal/test/ensure"
|
|
|
|
"helm.sh/helm/v4/internal/test/ensure"
|
|
|
|
"helm.sh/helm/v4/pkg/cli"
|
|
|
|
|
|
|
|
"helm.sh/helm/v4/pkg/getter"
|
|
|
|
"helm.sh/helm/v4/pkg/getter"
|
|
|
|
"helm.sh/helm/v4/pkg/helmpath"
|
|
|
|
"helm.sh/helm/v4/pkg/helmpath"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@ -248,34 +247,34 @@ func TestNewOCIInstaller(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestOCIInstaller_Path(t *testing.T) {
|
|
|
|
func TestOCIInstaller_Path(t *testing.T) {
|
|
|
|
|
|
|
|
customPluginsDir := "/foo/bar"
|
|
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
source string
|
|
|
|
source string
|
|
|
|
pluginName string
|
|
|
|
helmPluginsDir string
|
|
|
|
expectPath string
|
|
|
|
expectPath string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "valid plugin name",
|
|
|
|
name: "default helm plugins dir",
|
|
|
|
source: "oci://ghcr.io/user/plugin-name:v1.0.0",
|
|
|
|
source: "oci://ghcr.io/user/plugin-name:v1.0.0",
|
|
|
|
pluginName: "plugin-name",
|
|
|
|
helmPluginsDir: "",
|
|
|
|
expectPath: helmpath.DataPath("plugins", "plugin-name"),
|
|
|
|
expectPath: helmpath.DataPath("plugins", "plugin-name"),
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
{
|
|
|
|
name: "custom helm plugins dir",
|
|
|
|
name: "empty source",
|
|
|
|
source: "oci://ghcr.io/user/plugin-name:v1.0.0",
|
|
|
|
source: "",
|
|
|
|
helmPluginsDir: customPluginsDir,
|
|
|
|
pluginName: "",
|
|
|
|
expectPath: filepath.Join(customPluginsDir, "plugin-name"),
|
|
|
|
expectPath: "",
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
installer := &OCIInstaller{
|
|
|
|
if tt.helmPluginsDir != "" {
|
|
|
|
PluginName: tt.pluginName,
|
|
|
|
t.Setenv("HELM_PLUGINS", tt.helmPluginsDir)
|
|
|
|
base: newBase(tt.source),
|
|
|
|
|
|
|
|
settings: cli.New(),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
installer, err := NewOCIInstaller(tt.source)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
path := installer.Path()
|
|
|
|
path := installer.Path()
|
|
|
|
assert.Equal(t, tt.expectPath, path, "expected path %s, got %s", tt.expectPath, path)
|
|
|
|
assert.Equal(t, tt.expectPath, path, "expected path %s, got %s", tt.expectPath, path)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|