Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Raise error for duplicate application names #69

Merged
merged 3 commits into from Dec 18, 2020

Conversation

jopit
Copy link
Contributor

@jopit jopit commented Dec 9, 2020

Signed-off-by: John Pitman jpitman@redhat.com

Fixes #68

Signed-off-by: John Pitman <jpitman@redhat.com>
Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jopit, looks great, just a couple quick tweaks.

pkg/controllers/applicationset_controller.go Outdated Show resolved Hide resolved
pkg/controllers/applicationset_controller.go Outdated Show resolved Hide resolved
@@ -78,6 +79,10 @@ func (r *ApplicationSetReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
if err != nil {
return ctrl.Result{}, err
}
err = validateDesiredApplications(desiredApplications)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be part of the generateApplications, if there is a duplicate name the generate will fail with an error. what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's cleaner if the validation is done separately from the generation, particularly in light of Jonathan's comments above about the reconcile being retried when there is an error. If validation is separate, an error from generateApplications will still result in the reconcile being retried, while a duplicate application name will not.

Also, if there is a problem generating one of the applications, generateApplications currently will return both an error and a slice containing the valid applications (I'm not sure why). I think weaving the return of an error for duplicate names into this logic would be unnecessarily complicated.

Signed-off-by: John Pitman <jpitman@redhat.com>
Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jopit , approved!

Co-authored-by: William Tam <wtam@redhat.com>
@wtam2018
Copy link
Collaborator

LGTM

@xianlubird xianlubird merged commit 06b669f into argoproj:master Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ApplicationSet which generates Applications with matching names should report an error and return
5 participants