-
Notifications
You must be signed in to change notification settings - Fork 21
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
remove application set revision check. #271
Conversation
applicationsets was checking the manifest was targeting main, however there are cases where targetRevision may be using template e.g. `{{ .values.target }}` This causes the check to fail and does not perform applicationset checks. This PR removes the check as this check is only required on the applications not applicationsets.
Mergecat's ReviewClick to read mergecats review!😼 Mergecat review of pkg/affected_apps/argocd_matcher.go@@ -77,7 +77,7 @@ func (a *ArgocdMatcher) AffectedApps(_ context.Context, changeList []string, tar
}
appsSlice := a.appsDirectory.FindAppsBasedOnChangeList(changeList, targetBranch)
- appSetsSlice := a.appSetsDirectory.FindAppsBasedOnChangeList(changeList, targetBranch, repo)
+ appSetsSlice := a.appSetsDirectory.FindAppsBasedOnChangeList(changeList, repo)
// and return both apps and appSets
return AffectedItems{ Feedback & Suggestions:
😼 Mergecat review of pkg/appdir/appset_directory_test.go@@ -82,7 +82,6 @@ func TestAppSetDirectory_FindAppsBasedOnChangeList(t *testing.T) {
changeList: []string{
"appsets/httpdump/valid-appset.yaml",
},
- targetBranch: "main",
mockFiles: map[string]string{
"appsets/httpdump/valid-appset.yaml": `
apiVersion: argoproj.io/v1alpha1
@@ -180,7 +179,6 @@ spec:
changeList: []string{
"invalid-appset.yaml",
},
- targetBranch: "main",
mockFiles: map[string]string{
"appsets/httpdump/invalid-appset.yaml": "invalid yaml content",
},
@@ -214,7 +212,7 @@ spec:
t.Fatalf("failed to create tmp folder %s", fatalErr)
}
d := &AppSetDirectory{}
- result := d.FindAppsBasedOnChangeList(tt.changeList, tt.targetBranch, &git.Repo{Directory: tempDir})
+ result := d.FindAppsBasedOnChangeList(tt.changeList, &git.Repo{Directory: tempDir})
assert.Equal(t, tt.expected, result)
})
} Feedback & Suggestions:
😼 Mergecat review of pkg/appdir/appset_directory.go@@ -68,7 +68,7 @@ func (d *AppSetDirectory) ProcessApp(app v1alpha1.ApplicationSet) {
// e.g. changeList = ["/appset/httpdump/httpdump.yaml", "/app/testapp/values.yaml"]
// if the changed file is application set file, return it.
-func (d *AppSetDirectory) FindAppsBasedOnChangeList(changeList []string, targetBranch string, repo *git.Repo) []v1alpha1.ApplicationSet {
+func (d *AppSetDirectory) FindAppsBasedOnChangeList(changeList []string, repo *git.Repo) []v1alpha1.ApplicationSet {
log.Debug().Str("type", "applicationsets").Msgf("checking %d changes", len(changeList))
appsSet := make(map[string]struct{})
@@ -97,53 +97,21 @@ func (d *AppSetDirectory) FindAppsBasedOnChangeList(changeList []string, targetB
continue
}
- if !appSetShouldInclude(appSet, targetBranch) {
- log.Debug().Msgf("target revision of %s is %s and does not match '%s'", appSet, appSetGetTargetRevision(appSet), targetBranch)
- continue
- }
-
// Store the unique ApplicationSet
if _, exists := appsSet[appSet.Name]; !exists {
appsSet[appSet.Name] = struct{}{}
appSets = append(appSets, *appSet)
}
}
- log.Debug().Str("source", "appset_directory").Msgf("matched %d files into %d appset", len(changeList), len(appsSet))
+ log.Debug().Str("source", "appset_directory").Msgf("matched %d files into %d appset", len(changeList), len(appSets))
return appSets
}
-func appSetGetTargetRevision(app *v1alpha1.ApplicationSet) string {
- return app.Spec.Template.Spec.GetSource().TargetRevision
-}
-
func appSetGetSourcePath(app *v1alpha1.ApplicationSet) string {
return app.Spec.Template.Spec.GetSource().Path
}
-func appSetShouldInclude(app *v1alpha1.ApplicationSet, targetBranch string) bool {
- targetRevision := appSetGetTargetRevision(app)
- if targetRevision == "" {
- return true
- }
-
- if targetRevision == targetBranch {
- return true
- }
-
- if targetRevision == "HEAD" {
- if targetBranch == "main" {
- return true
- }
-
- if targetBranch == "master" {
- return true
- }
- }
-
- return false
-}
-
func (d *AppSetDirectory) GetAppSets(filter func(stub v1alpha1.ApplicationSet) bool) []v1alpha1.ApplicationSet {
var result []v1alpha1.ApplicationSet
for _, value := range d.appSetsMap { Feedback & Suggestions:
Dependency ReviewClick to read mergecats review!No suggestions found |
Temporary image deleted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure this is more technically correct, or less technically correct, but let's give it a shot.
applicationsets was checking the manifest was targeting main, however there are cases where targetRevision may be using template e.g.
{{ .values.target }}
This causes the check to fail and does not perform applicationset checks.This PR removes the check as this check is only required on the applications not applicationsets.
fixes #269