pull/32569/merge
hhbf 19 hours ago committed by GitHub
commit 040ca4320e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -36,10 +36,22 @@ func newBase(source string) base {
}
}
// pluginsDir returns the directory where plugins should be installed. When
// HELM_PLUGINS contains a list of directories (separated by the OS path list
// separator), the first non-empty directory is the default install target.
func (b *base) pluginsDir() string {
for _, dir := range filepath.SplitList(b.PluginsDirectory) {
if dir != "" {
return dir
}
}
return b.PluginsDirectory
}
// Path is where the plugin will be installed.
func (b *base) Path() string {
if b.Source == "" {
return ""
}
return filepath.Join(b.PluginsDirectory, filepath.Base(b.Source))
return filepath.Join(b.pluginsDir(), filepath.Base(b.Source))
}

@ -14,6 +14,8 @@ limitations under the License.
package installer
import (
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/assert"
@ -32,7 +34,15 @@ func TestPath(t *testing.T) {
}, {
source: "https://github.com/jkroepke/helm-secrets",
helmPluginsDir: "/helm/data/plugins",
expectPath: "/helm/data/plugins/helm-secrets",
expectPath: filepath.Join("/helm/data/plugins", "helm-secrets"),
}, {
source: "https://github.com/jkroepke/helm-secrets",
helmPluginsDir: strings.Join([]string{"/helm/data/plugins", "/helm/data/extra"}, string(filepath.ListSeparator)),
expectPath: filepath.Join("/helm/data/plugins", "helm-secrets"),
}, {
source: "https://github.com/jkroepke/helm-secrets",
helmPluginsDir: string(filepath.ListSeparator) + "/helm/data/plugins",
expectPath: filepath.Join("/helm/data/plugins", "helm-secrets"),
},
}

@ -152,7 +152,7 @@ func (i HTTPInstaller) Path() string {
if i.Source == "" {
return ""
}
return helmpath.DataPath("plugins", i.PluginName)
return filepath.Join(i.pluginsDir(), i.PluginName)
}
// SupportsVerification returns true if the HTTP installer can verify plugins

@ -176,7 +176,7 @@ func (i *LocalInstaller) Path() string {
pluginName = stripPluginName(pluginName)
}
return helmpath.DataPath("plugins", pluginName)
return filepath.Join(i.pluginsDir(), pluginName)
}
// SupportsVerification returns true if the local installer can verify plugins

@ -195,7 +195,7 @@ func (i OCIInstaller) Path() string {
if i.Source == "" {
return ""
}
return filepath.Join(i.settings.PluginsDirectory, i.PluginName)
return filepath.Join(i.pluginsDir(), i.PluginName)
}
// extractTarGz extracts a gzipped tar archive to a directory

Loading…
Cancel
Save