diff --git a/pkg/state/state_test.go b/pkg/state/state_test.go index 88be32fc..0b78da1c 100644 --- a/pkg/state/state_test.go +++ b/pkg/state/state_test.go @@ -775,11 +775,11 @@ func Test_isLocalChart(t *testing.T) { want: true, }, { - name: "local chart in 3-level deep dir", + name: "remote chart in 3-level deep dir (e.g. ChartCenter)", args: args{ - chart: "foo/bar/baz", + chart: "center/bar/baz", }, - want: true, + want: false, }, } for i := range tests { @@ -818,6 +818,14 @@ func Test_normalizeChart(t *testing.T) { }, want: "remote/app", }, + { + name: "chartcenter repo path", + args: args{ + basePath: "/Users/jane/code/deploy/charts", + chart: "center/stable/myapp", + }, + want: "center/stable/myapp", + }, { name: "construct local chart path, parent dir", args: args{ diff --git a/pkg/state/util.go b/pkg/state/util.go index eadb22ca..a3204cd0 100644 --- a/pkg/state/util.go +++ b/pkg/state/util.go @@ -21,7 +21,8 @@ func isLocalChart(chart string) bool { return chart == "" || chart[0] == '/' || strings.Index(chart, "/") == -1 || - len(strings.Split(chart, "/")) != 2 + (len(strings.Split(chart, "/")) != 2 && + len(strings.Split(chart, "/")) != 3) } func resolveRemoteChart(repoAndChart string) (string, string, bool) { @@ -29,8 +30,13 @@ func resolveRemoteChart(repoAndChart string) (string, string, bool) { return "", "", false } - parts := strings.Split(repoAndChart, "/") - if len(parts) != 2 { + uriLike := strings.Index(repoAndChart, "://") > -1 + if uriLike { + return "", "", false + } + + parts := strings.SplitN(repoAndChart, "/", 2) + if len(parts) < 2 { return "", "", false } diff --git a/pkg/state/util_test.go b/pkg/state/util_test.go index 57d51f3a..c4cceebb 100644 --- a/pkg/state/util_test.go +++ b/pkg/state/util_test.go @@ -15,13 +15,17 @@ func TestIsLocalChart(t *testing.T) { input: "stable/mysql", expected: false, }, + { + input: "center/stable/mysql", + expected: false, + }, { input: "./charts/myapp", expected: true, }, { - input: "charts/mysubsystem/myapp", - expected: true, + input: "center/stable/myapp", + expected: false, }, { input: "./charts/mysubsystem/myapp", @@ -77,8 +81,10 @@ func TestResolveRemortChart(t *testing.T) { remote: false, }, { - input: "charts/mysubsystem/myapp", - remote: false, + input: "center/stable/myapp", + repo: "center", + chart: "stable/myapp", + remote: true, }, { input: "./charts/mysubsystem/myapp", diff --git a/test/integration/happypath.yaml b/test/integration/happypath.yaml index 9d1401c7..70e94650 100644 --- a/test/integration/happypath.yaml +++ b/test/integration/happypath.yaml @@ -6,8 +6,8 @@ environments: repositories: - name: stable url: https://kubernetes-charts.storage.googleapis.com/ - - name: incubator - url: https://kubernetes-charts-incubator.storage.googleapis.com + - name: center + url: https://repo.chartcenter.io helmDefaults: kubeContext: minikube @@ -29,7 +29,7 @@ releases: - "{{`{{.HelmfileCommand}}`}}" - name: raw - chart: incubator/raw + chart: center/incubator/raw values: - mysecret: {{ .Environment.Values.mysecret }} - values.yaml