Skip to content

Commit

Permalink
fix(appset): use topics for Gitlab SCM Provider (#13169) (#13170)
Browse files Browse the repository at this point in the history
* fix(scm gitlab): use project topics instead of tags

Signed-off-by: tillepille <[email protected]>

* feat(scm gitlab): add testcase for labels

Signed-off-by: tillepille <[email protected]>

fix test

Signed-off-by: tillepille <[email protected]>

* feat(scm gitlab): update docs for gitlab filtering

Signed-off-by: tillepille <[email protected]>

* feat(scm gitlab): add fallback for old gitlab versions

Signed-off-by: tillepille <[email protected]>

---------

Signed-off-by: tillepille <[email protected]>
  • Loading branch information
tillepille authored Nov 20, 2023
1 parent 6fa9b17 commit b2a52de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 9 additions & 1 deletion applicationset/services/scm_provider/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,20 @@ func (g *GitlabProvider) ListRepos(ctx context.Context, cloneProtocol string) ([
return nil, fmt.Errorf("unknown clone protocol for Gitlab %v", cloneProtocol)
}

var repoLabels []string
if len(gitlabRepo.Topics) == 0 {
// fallback to for gitlab prior to 14.5
repoLabels = gitlabRepo.TagList
} else {
repoLabels = gitlabRepo.Topics
}

repos = append(repos, &Repository{
Organization: gitlabRepo.Namespace.FullPath,
Repository: gitlabRepo.Path,
URL: url,
Branch: gitlabRepo.DefaultBranch,
Labels: gitlabRepo.TagList,
Labels: repoLabels,
RepositoryId: gitlabRepo.ID,
})
}
Expand Down
10 changes: 10 additions & 0 deletions applicationset/services/scm_provider/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,16 @@ func TestGitlabListRepos(t *testing.T) {
proto: "ssh",
url: "[email protected]:test-argocd-proton/argocd.git",
},
{
name: "labelmatch",
proto: "ssh",
url: "[email protected]:test-argocd-proton/argocd.git",
filters: []v1alpha1.SCMProviderGeneratorFilter{
{
LabelMatch: strp("test-topic"),
},
},
},
{
name: "https protocol",
proto: "https",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ spec:
* `tokenRef`: A `Secret` name and key containing the GitLab access token to use for requests. If not specified, will make anonymous requests which have a lower rate limit and can only see public repositories.
* `insecure`: By default (false) - Skip checking the validity of the SCM's certificate - useful for self-signed TLS certificates.

For label filtering, the repository tags are used.
For label filtering, the repository topics are used.

Available clone protocols are `ssh` and `https`.

Expand Down

0 comments on commit b2a52de

Please sign in to comment.