Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added missing 'alias:' prefix for repository name (#15563) #15902

Merged
merged 15 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ func getHelmDependencyRepos(appPath string) ([]*v1alpha1.Repository, error) {
repos = append(repos, &v1alpha1.Repository{
Name: r.Repository[1:],
})
} else if strings.HasPrefix(r.Repository, "alias:") {
repos = append(repos, &v1alpha1.Repository{
Name: strings.TrimPrefix(r.Repository, "alias:"),
})
} else if u, err := url.Parse(r.Repository); err == nil && (u.Scheme == "https" || u.Scheme == "oci") {
repo := &v1alpha1.Repository{
// trimming oci:// prefix since it is currently not supported by Argo CD (OCI repos just have no scheme)
Expand Down
17 changes: 17 additions & 0 deletions reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,7 @@ func TestListApps(t *testing.T) {
"out-of-bounds-values-file-link": "Helm",
"values-files": "Helm",
"helm-with-dependencies": "Helm",
"helm-with-dependencies-alias": "Helm",
}
assert.Equal(t, expectedApps, res.Apps)
}
Expand Down Expand Up @@ -2756,6 +2757,22 @@ func TestGetHelmRepo_NamedRepos(t *testing.T) {
assert.Equal(t, helmRepos[0].Repo, "https://example.com")
}

func TestGetHelmRepo_NamedReposAlias(t *testing.T) {
src := argoappv1.ApplicationSource{Path: "."}
q := apiclient.ManifestRequest{Repo: &argoappv1.Repository{}, ApplicationSource: &src, Repos: []*argoappv1.Repository{{
Name: "custom-repo-alias",
Repo: "https://example.com",
Username: "test-alias",
}}}

helmRepos, err := getHelmRepos("./testdata/helm-with-dependencies-alias", q.Repos, q.HelmRepoCreds)
assert.Nil(t, err)

assert.Equal(t, len(helmRepos), 1)
assert.Equal(t, helmRepos[0].Username, "test-alias")
assert.Equal(t, helmRepos[0].Repo, "https://example.com")
}

func Test_getResolvedValueFiles(t *testing.T) {
tempDir := t.TempDir()
paths := io.NewRandomizedTempPaths(tempDir)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: helm-with-dependencies-alias
version: v1.0.0
dependencies:
- name: helm
repository: "alias:custom-repo-alias"
version: v1.0.0
Loading