Skip to content

Commit 19669d2

Browse files
feat: add repository_id to AppSet generators (#15820) (#22416)
Signed-off-by: Gregor Eichelberger <[email protected]>
1 parent 895dcf7 commit 19669d2

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

applicationset/generators/scm_provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ func (g *SCMProviderGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha
253253
params := map[string]any{
254254
"organization": repo.Organization,
255255
"repository": repo.Repository,
256+
"repository_id": repo.RepositoryId,
256257
"url": repo.URL,
257258
"branch": repo.Branch,
258259
"sha": repo.SHA,

applicationset/generators/scm_provider_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestSCMProviderGenerateParams(t *testing.T) {
2525
{
2626
Organization: "myorg",
2727
Repository: "repo1",
28+
RepositoryId: 190320251,
2829
URL: "[email protected]:myorg/repo1.git",
2930
Branch: "main",
3031
SHA: "0bc57212c3cbbec69d20b34c507284bd300def5b",
@@ -33,6 +34,7 @@ func TestSCMProviderGenerateParams(t *testing.T) {
3334
{
3435
Organization: "myorg",
3536
Repository: "repo2",
37+
RepositoryId: 190320252,
3638
URL: "[email protected]:myorg/repo2.git",
3739
Branch: "main",
3840
SHA: "59d0",
@@ -42,6 +44,7 @@ func TestSCMProviderGenerateParams(t *testing.T) {
4244
{
4345
"organization": "myorg",
4446
"repository": "repo1",
47+
"repository_id": 190320251,
4548
"url": "[email protected]:myorg/repo1.git",
4649
"branch": "main",
4750
"branchNormalized": "main",
@@ -53,6 +56,7 @@ func TestSCMProviderGenerateParams(t *testing.T) {
5356
{
5457
"organization": "myorg",
5558
"repository": "repo2",
59+
"repository_id": 190320252,
5660
"url": "[email protected]:myorg/repo2.git",
5761
"branch": "main",
5862
"branchNormalized": "main",
@@ -69,6 +73,7 @@ func TestSCMProviderGenerateParams(t *testing.T) {
6973
{
7074
Organization: "myorg",
7175
Repository: "repo3",
76+
RepositoryId: 190320253,
7277
URL: "[email protected]:myorg/repo3.git",
7378
Branch: "main",
7479
SHA: "0bc57212c3cbbec69d20b34c507284bd300def5b",
@@ -83,6 +88,7 @@ func TestSCMProviderGenerateParams(t *testing.T) {
8388
{
8489
"organization": "myorg",
8590
"repository": "repo3",
91+
"repository_id": 190320253,
8692
"url": "[email protected]:myorg/repo3.git",
8793
"branch": "main",
8894
"branchNormalized": "main",
@@ -95,6 +101,52 @@ func TestSCMProviderGenerateParams(t *testing.T) {
95101
},
96102
},
97103
},
104+
{
105+
name: "Repos with and without id",
106+
repos: []*scm_provider.Repository{
107+
{
108+
Organization: "myorg",
109+
Repository: "repo4",
110+
RepositoryId: "idaz09",
111+
URL: "[email protected]:myorg/repo4.git",
112+
Branch: "main",
113+
SHA: "0bc57212c3cbbec69d20b34c507284bd300def5b",
114+
},
115+
{
116+
Organization: "myorg",
117+
Repository: "repo5",
118+
URL: "[email protected]:myorg/repo5.git",
119+
Branch: "main",
120+
SHA: "0bc57212c3cbbec69d20b34c507284bd300def5b",
121+
},
122+
},
123+
expected: []map[string]any{
124+
{
125+
"organization": "myorg",
126+
"repository": "repo4",
127+
"repository_id": "idaz09",
128+
"url": "[email protected]:myorg/repo4.git",
129+
"branch": "main",
130+
"branchNormalized": "main",
131+
"sha": "0bc57212c3cbbec69d20b34c507284bd300def5b",
132+
"short_sha": "0bc57212",
133+
"short_sha_7": "0bc5721",
134+
"labels": "",
135+
},
136+
{
137+
"organization": "myorg",
138+
"repository": "repo5",
139+
"repository_id": nil,
140+
"url": "[email protected]:myorg/repo5.git",
141+
"branch": "main",
142+
"branchNormalized": "main",
143+
"sha": "0bc57212c3cbbec69d20b34c507284bd300def5b",
144+
"short_sha": "0bc57212",
145+
"short_sha_7": "0bc5721",
146+
"labels": "",
147+
},
148+
},
149+
},
98150
}
99151

100152
for _, testCase := range cases {

docs/operator-manual/applicationset/Generators-SCM-Provider.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ spec:
442442
443443
* `organization`: The name of the organization the repository is in.
444444
* `repository`: The name of the repository.
445+
* `repository_id`: The id of the repository.
445446
* `url`: The clone URL for the repository.
446447
* `branch`: The default branch of the repository.
447448
* `sha`: The Git commit SHA for the branch.

0 commit comments

Comments
 (0)