func generateApplicationSet()

in pkg/argocd/argoapplicationset_manager.go [380:434]


func generateApplicationSet(
	pipeline *cdPipeApi.CDPipeline,
	gitopsUrl string,
) *argoApi.ApplicationSet {
	templatePatch := generateTemplatePatch(pipeline.Name, gitopsUrl)

	return &argoApi.ApplicationSet{
		ObjectMeta: metav1.ObjectMeta{
			Name:      pipeline.Name,
			Namespace: pipeline.Namespace,
		},
		Spec: argoApi.ApplicationSetSpec{
			Generators:        []argoApi.ApplicationSetGenerator{},
			GoTemplate:        true,
			GoTemplateOptions: []string{"missingkey=error"},
			TemplatePatch:     &templatePatch,
			Template: argoApi.ApplicationSetTemplate{
				ApplicationSetTemplateMeta: argoApi.ApplicationSetTemplateMeta{
					Name:       fmt.Sprintf("%s-{{ .stage }}-{{ .codebase }}", pipeline.Name),
					Finalizers: []string{"resources-finalizer.argocd.argoproj.io"}, // check if it is our or argo's responsibility
					Labels: map[string]string{
						"app.edp.epam.com/app-name": "{{ .codebase }}",
						"app.edp.epam.com/pipeline": pipeline.Name,
						"app.edp.epam.com/stage":    "{{ .stage }}",
					},
				},
				Spec: argoApi.ApplicationSpec{
					Destination: argoApi.ApplicationDestination{
						Name:      "{{ .cluster }}",
						Namespace: "{{ .namespace }}",
					},
					Project: pipeline.Namespace,
					Source: &argoApi.ApplicationSource{
						Helm: &argoApi.ApplicationSourceHelm{
							Parameters: []argoApi.HelmParameter{
								{
									Name:  "image.tag",
									Value: "{{ .imageTag }}",
								},
								{
									Name:  "image.repository",
									Value: "{{ .imageRepository }}",
								},
							},
							ReleaseName: "{{ .codebase }}",
						},
						Path:           "deploy-templates",
						RepoURL:        "{{ .repoURL }}",
						TargetRevision: `{{ if eq .versionType "edp" }}build/{{ .imageTag }}{{ else }}{{ .imageTag }}{{ end }}`,
					},
				},
			},
		},
	}
}