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
4 changed files with 33 additions and 13 deletions
+11 -3
View File
@@ -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{
+9 -3
View File
@@ -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
}
+10 -4
View File
@@ -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",
+3 -3
View File
@@ -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