pull/32237/merge
Shaik Abrar 17 hours ago committed by GitHub
commit 175bff42ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -41,5 +41,11 @@ func (b *base) Path() string {
if b.Source == "" { if b.Source == "" {
return "" return ""
} }
return filepath.Join(b.PluginsDirectory, filepath.Base(b.Source))
pluginsDirectory := b.PluginsDirectory
if pluginsDirectories := filepath.SplitList(b.PluginsDirectory); len(pluginsDirectories) > 0 {
pluginsDirectory = pluginsDirectories[0]
}
return filepath.Join(pluginsDirectory, filepath.Base(b.Source))
} }

@ -14,12 +14,18 @@ limitations under the License.
package installer package installer
import ( import (
"fmt"
"path/filepath"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestPath(t *testing.T) { func TestPath(t *testing.T) {
pluginsDir := filepath.Join(string(filepath.Separator), "helm", "data", "plugins")
systemPluginsDir := filepath.Join(string(filepath.Separator), "helm", "system", "plugins")
pluginSource := "https://github.com/jkroepke/helm-secrets"
tests := []struct { tests := []struct {
source string source string
helmPluginsDir string helmPluginsDir string
@ -27,12 +33,16 @@ func TestPath(t *testing.T) {
}{ }{
{ {
source: "", source: "",
helmPluginsDir: "/helm/data/plugins", helmPluginsDir: pluginsDir,
expectPath: "", expectPath: "",
}, { }, {
source: "https://github.com/jkroepke/helm-secrets", source: pluginSource,
helmPluginsDir: "/helm/data/plugins", helmPluginsDir: pluginsDir,
expectPath: "/helm/data/plugins/helm-secrets", expectPath: filepath.Join(pluginsDir, filepath.Base(pluginSource)),
}, {
source: pluginSource,
helmPluginsDir: fmt.Sprintf("%s%c%s", pluginsDir, filepath.ListSeparator, systemPluginsDir),
expectPath: filepath.Join(pluginsDir, filepath.Base(pluginSource)),
}, },
} }

Loading…
Cancel
Save