Skip to content
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

feat(appset): Advanced templating for ApplicationSet #11567

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9ad71eb
11164: ApplicationSet full templating
speedfl Feb 8, 2023
cf8d316
Merge branch 'master' into feature/11164
speedfl Feb 8, 2023
bf2cee1
Merge branch 'master' into feature/11164
speedfl Feb 9, 2023
3405dfa
Merge branch 'master' into feature/11164
speedfl Feb 9, 2023
2dc20cb
Merge branch 'master' into feature/11164
speedfl Feb 13, 2023
21b9247
Merge branch 'master' into feature/11164
speedfl Feb 14, 2023
ae03d4e
Merge branch 'master' into feature/11164
speedfl Feb 14, 2023
ff4ef9a
11164: Cannot update status
speedfl Feb 15, 2023
05c2d1e
Merge branch 'master' into feature/11164
speedfl Feb 16, 2023
72c20cc
Merge branch 'master' into feature/11164
speedfl Feb 16, 2023
68a97e4
Merge branch 'master' of github.com:speedfl/argo-cd into feature/11164
speedfl Mar 13, 2023
5ec61da
11164: Some fixes
speedfl Mar 13, 2023
7ae3f8b
Merge branch 'master' into feature/11164
speedfl Mar 13, 2023
d5f4cee
Merge branch 'master' into feature/11164
speedfl Mar 14, 2023
8abb8b7
11164: Fix codegen
speedfl Mar 15, 2023
c6c72b4
Merge branch 'master' into feature/11164
speedfl Mar 15, 2023
27ef81f
Merge branch 'master' of github.com:speedfl/argo-cd into feature/11164
speedfl Mar 15, 2023
afd8e4a
Merge branch 'master' of github.com:speedfl/argo-cd into feature/11164
speedfl Mar 17, 2023
9a84be7
11164: Fix build
speedfl Mar 17, 2023
941c3f5
Merge branch 'master' into feature/11164
speedfl Mar 17, 2023
1c2a28b
Merge branch 'master' of github.com:speedfl/argo-cd into feature/11164
speedfl Mar 23, 2023
ef08418
Merge branch 'feature/11164' of github.com:speedfl/argo-cd into featu…
speedfl Mar 23, 2023
61c69d5
Merge branch 'master' of github.com:speedfl/argo-cd into feature/11164
speedfl Apr 17, 2023
963f7a7
Merge branch 'master' into feature/11164
speedfl Apr 17, 2023
4097233
Merge branch 'master' of github.com:speedfl/argo-cd into feature/11164
speedfl Apr 21, 2023
86a070e
Merge branch 'feature/11164' of github.com:speedfl/argo-cd into featu…
speedfl Apr 21, 2023
39ad354
Merge branch 'master' of github.com:speedfl/argo-cd into feature/11164
speedfl May 1, 2023
e94488e
11164: Empty
speedfl May 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions applicationset/controllers/applicationset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ func (r *ApplicationSetReconciler) validateGeneratedApplications(ctx context.Con
continue
}

if !reflect.DeepEqual(app.Status, argov1alpha1.ApplicationStatus{}) {
errorsByIndex[i] = fmt.Errorf("application contains status updates")
continue
}

proj, err := r.ArgoAppClientset.ArgoprojV1alpha1().AppProjects(namespace).Get(ctx, app.Spec.GetProject(), metav1.GetOptions{})
if err != nil {
if apierr.IsNotFound(err) {
Expand Down Expand Up @@ -462,26 +467,14 @@ func (r *ApplicationSetReconciler) getMinRequeueAfter(applicationSetInfo *argov1
return res
}

func getTempApplication(applicationSetTemplate argov1alpha1.ApplicationSetTemplate) *argov1alpha1.Application {
var tmplApplication argov1alpha1.Application
tmplApplication.Annotations = applicationSetTemplate.Annotations
tmplApplication.Labels = applicationSetTemplate.Labels
tmplApplication.Namespace = applicationSetTemplate.Namespace
tmplApplication.Name = applicationSetTemplate.Name
tmplApplication.Spec = applicationSetTemplate.Spec
tmplApplication.Finalizers = applicationSetTemplate.Finalizers

return &tmplApplication
}

func (r *ApplicationSetReconciler) generateApplications(applicationSetInfo argov1alpha1.ApplicationSet) ([]argov1alpha1.Application, argov1alpha1.ApplicationSetReasonType, error) {
var res []argov1alpha1.Application

var firstError error
var applicationSetReason argov1alpha1.ApplicationSetReasonType

for _, requestedGenerator := range applicationSetInfo.Spec.Generators {
t, err := generators.Transform(requestedGenerator, r.Generators, applicationSetInfo.Spec.Template, &applicationSetInfo, map[string]interface{}{})
t, err := generators.Transform(requestedGenerator, r.Generators, &applicationSetInfo.Spec.Template, &applicationSetInfo, map[string]interface{}{})
if err != nil {
log.WithError(err).WithField("generator", requestedGenerator).
Error("error generating application from params")
Expand All @@ -493,10 +486,9 @@ func (r *ApplicationSetReconciler) generateApplications(applicationSetInfo argov
}

for _, a := range t {
tmplApplication := getTempApplication(a.Template)

for _, p := range a.Params {
app, err := r.Renderer.RenderTemplateParams(tmplApplication, applicationSetInfo.Spec.SyncPolicy, p, applicationSetInfo.Spec.GoTemplate)
app, err := r.Renderer.RenderTemplateParams(a.Template, applicationSetInfo.Spec.SyncPolicy, p, applicationSetInfo.Spec.GoTemplate)
if err != nil {
log.WithError(err).WithField("params", a.Params).WithField("generator", requestedGenerator).
Error("error generating application from params")
Expand Down
Loading