forked from argoproj/applicationset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pull request support to SCM generator
This commit adds pull request support to SCM generator so the generator can create ArgoCD apps for PRs as well. Fixes argoproj#466 Signed-off-by: Fardin Khanjani <[email protected]>
- Loading branch information
Showing
14 changed files
with
100 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,15 +86,15 @@ func TestSCMProviderGenerateParams(t *testing.T) { | |
Organization: "myorg", | ||
Repository: "repo1", | ||
URL: "[email protected]:myorg/repo1.git", | ||
Branch: "main", | ||
Revision: "main", | ||
SHA: "abcd1234", | ||
Labels: []string{"prod", "staging"}, | ||
}, | ||
{ | ||
Organization: "myorg", | ||
Repository: "repo2", | ||
URL: "[email protected]:myorg/repo2.git", | ||
Branch: "main", | ||
Revision: "main", | ||
SHA: "00000000", | ||
}, | ||
}, | ||
|
@@ -108,7 +108,7 @@ func TestSCMProviderGenerateParams(t *testing.T) { | |
assert.Equal(t, "myorg", params[0]["organization"]) | ||
assert.Equal(t, "repo1", params[0]["repository"]) | ||
assert.Equal(t, "[email protected]:myorg/repo1.git", params[0]["url"]) | ||
assert.Equal(t, "main", params[0]["branch"]) | ||
assert.Equal(t, "main", params[0]["revision"]) | ||
assert.Equal(t, "abcd1234", params[0]["sha"]) | ||
assert.Equal(t, "prod,staging", params[0]["labels"]) | ||
assert.Equal(t, "repo2", params[1]["repository"]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,9 @@ func checkRateLimit(t *testing.T, err error) { | |
|
||
func TestGithubListRepos(t *testing.T) { | ||
cases := []struct { | ||
name, proto, url string | ||
hasError, allBranches bool | ||
branches []string | ||
name, proto, url string | ||
hasError, allBranches, allPullRequests bool | ||
branches []string | ||
}{ | ||
{ | ||
name: "blank protocol", | ||
|
@@ -65,11 +65,17 @@ func TestGithubListRepos(t *testing.T) { | |
url: "[email protected]:argoproj/applicationset.git", | ||
branches: []string{"master", "release-0.1.0"}, | ||
}, | ||
{ | ||
name: "all branches", | ||
allPullRequests: false, | ||
url: "[email protected]:argoproj/applicationset.git", | ||
branches: []string{"master", "release-0.1.0"}, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
t.Run(c.name, func(t *testing.T) { | ||
provider, _ := NewGithubProvider(context.Background(), "argoproj", "", "", c.allBranches) | ||
provider, _ := NewGithubProvider(context.Background(), "argoproj", "", "", c.allBranches, c.allPullRequests) | ||
rawRepos, err := provider.ListRepos(context.Background(), c.proto) | ||
if c.hasError { | ||
assert.NotNil(t, err) | ||
|
@@ -82,7 +88,7 @@ func TestGithubListRepos(t *testing.T) { | |
for _, r := range rawRepos { | ||
if r.Repository == "applicationset" { | ||
repos = append(repos, r) | ||
branches = append(branches, r.Branch) | ||
branches = append(branches, r.Revision) | ||
} | ||
} | ||
assert.NotEmpty(t, repos) | ||
|
@@ -96,11 +102,11 @@ func TestGithubListRepos(t *testing.T) { | |
} | ||
|
||
func TestGithubHasPath(t *testing.T) { | ||
host, _ := NewGithubProvider(context.Background(), "argoproj", "", "", false) | ||
host, _ := NewGithubProvider(context.Background(), "argoproj", "", "", false, false) | ||
repo := &Repository{ | ||
Organization: "argoproj", | ||
Repository: "applicationset", | ||
Branch: "master", | ||
Revision: "master", | ||
} | ||
ok, err := host.RepoHasPath(context.Background(), repo, "pkg/") | ||
checkRateLimit(t, err) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters