Add support for ChartCenter (#1492)

Resolves #1326
This commit is contained in:
Yusuke Kuoka 2020-09-21 15:31:24 +09:00 committed by GitHub
parent b176408eb2
commit 942b9a64c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 13 deletions

View File

@ -775,11 +775,11 @@ func Test_isLocalChart(t *testing.T) {
want: true, want: true,
}, },
{ {
name: "local chart in 3-level deep dir", name: "remote chart in 3-level deep dir (e.g. ChartCenter)",
args: args{ args: args{
chart: "foo/bar/baz", chart: "center/bar/baz",
}, },
want: true, want: false,
}, },
} }
for i := range tests { for i := range tests {
@ -818,6 +818,14 @@ func Test_normalizeChart(t *testing.T) {
}, },
want: "remote/app", 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", name: "construct local chart path, parent dir",
args: args{ args: args{

View File

@ -21,7 +21,8 @@ func isLocalChart(chart string) bool {
return chart == "" || return chart == "" ||
chart[0] == '/' || chart[0] == '/' ||
strings.Index(chart, "/") == -1 || 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) { func resolveRemoteChart(repoAndChart string) (string, string, bool) {
@ -29,8 +30,13 @@ func resolveRemoteChart(repoAndChart string) (string, string, bool) {
return "", "", false return "", "", false
} }
parts := strings.Split(repoAndChart, "/") uriLike := strings.Index(repoAndChart, "://") > -1
if len(parts) != 2 { if uriLike {
return "", "", false
}
parts := strings.SplitN(repoAndChart, "/", 2)
if len(parts) < 2 {
return "", "", false return "", "", false
} }

View File

@ -15,13 +15,17 @@ func TestIsLocalChart(t *testing.T) {
input: "stable/mysql", input: "stable/mysql",
expected: false, expected: false,
}, },
{
input: "center/stable/mysql",
expected: false,
},
{ {
input: "./charts/myapp", input: "./charts/myapp",
expected: true, expected: true,
}, },
{ {
input: "charts/mysubsystem/myapp", input: "center/stable/myapp",
expected: true, expected: false,
}, },
{ {
input: "./charts/mysubsystem/myapp", input: "./charts/mysubsystem/myapp",
@ -77,8 +81,10 @@ func TestResolveRemortChart(t *testing.T) {
remote: false, remote: false,
}, },
{ {
input: "charts/mysubsystem/myapp", input: "center/stable/myapp",
remote: false, repo: "center",
chart: "stable/myapp",
remote: true,
}, },
{ {
input: "./charts/mysubsystem/myapp", input: "./charts/mysubsystem/myapp",

View File

@ -6,8 +6,8 @@ environments:
repositories: repositories:
- name: stable - name: stable
url: https://kubernetes-charts.storage.googleapis.com/ url: https://kubernetes-charts.storage.googleapis.com/
- name: incubator - name: center
url: https://kubernetes-charts-incubator.storage.googleapis.com url: https://repo.chartcenter.io
helmDefaults: helmDefaults:
kubeContext: minikube kubeContext: minikube
@ -29,7 +29,7 @@ releases:
- "{{`{{.HelmfileCommand}}`}}" - "{{`{{.HelmfileCommand}}`}}"
- name: raw - name: raw
chart: incubator/raw chart: center/incubator/raw
values: values:
- mysecret: {{ .Environment.Values.mysecret }} - mysecret: {{ .Environment.Values.mysecret }}
- values.yaml - values.yaml