Skip to content

Commit ea63f8d

Browse files
authored
fix(helm): allow special char in chart repo name (#1366)
feat: allow special char in repo name
1 parent ccf705b commit ea63f8d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

pkg/helm/charts.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import (
1212
)
1313

1414
var (
15-
// https://regex101.com/r/7xFFtU/3
16-
chartExp = regexp.MustCompile(`^(?P<chart>\w+\/.+)@(?P<version>[^:\n\s]+)(?:\:(?P<path>[\w-. ]+))?$`)
17-
repoExp = regexp.MustCompile(`^\w+$`)
15+
// https://regex101.com/r/9m42pQ/1
16+
chartExp = regexp.MustCompile(`^(?P<chart>[\w+-\/.]+)@(?P<version>[^:\n\s]+)(?:\:(?P<path>[\w-. ]+))?$`)
17+
// https://regex101.com/r/xoAx8c/1
18+
repoExp = regexp.MustCompile(`^[\w-]+$`)
1819
)
1920

2021
// LoadChartfile opens a Chartfile tree

pkg/helm/charts_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ func TestParseReq(t *testing.T) {
5050
input: "https://helm.releases.hashicorp.com/[email protected]",
5151
err: errors.New("not of form 'repo/chart@version(:path)' where repo contains no special characters"),
5252
},
53+
{
54+
name: "repo-with-special-chars",
55+
input: "with-dashes/[email protected]",
56+
expected: &Requirement{
57+
Chart: "with-dashes/package",
58+
Version: "1.0.0",
59+
Directory: "",
60+
},
61+
},
5362
}
5463

5564
for _, tc := range testCases {
@@ -68,12 +77,13 @@ func TestAddRepos(t *testing.T) {
6877
err = c.AddRepos(
6978
Repo{Name: "foo", URL: "https://foo.com"},
7079
Repo{Name: "foo2", URL: "https://foo2.com"},
80+
Repo{Name: "with-dashes", URL: "https://foo.com"},
7181
)
7282
assert.NoError(t, err)
7383

74-
// Only \w characters are allowed in repo names
84+
// Only \w- characters are allowed in repo names
7585
err = c.AddRepos(
76-
Repo{Name: "with-dashes", URL: "https://foo.com"},
86+
Repo{Name: "re:po", URL: "https://foo.com"},
7787
)
7888
assert.EqualError(t, err, "1 Repo(s) were skipped. Please check above logs for details")
7989

0 commit comments

Comments
 (0)