@@ -35,6 +35,11 @@ import (
3535
3636const DeploymentSubroutineName = "DeploymentSubroutine"
3737
38+ const (
39+ deploymentTechFluxCD = "fluxcd"
40+ deploymentTechArgoCD = "argocd"
41+ )
42+
3843type DeploymentSubroutine struct {
3944 clientInfra client.Client
4045 clientRuntime client.Client
@@ -209,7 +214,7 @@ func (r *DeploymentSubroutine) Process(ctx context.Context, runtimeObj runtimeob
209214 }
210215 deploymentTech , _ := tmplVars ["deploymentTechnology" ].(string )
211216 if deploymentTech == "" {
212- deploymentTech = "fluxcd" // default to fluxcd if not in profile
217+ deploymentTech = deploymentTechFluxCD // default to fluxcd if not in profile
213218 }
214219 deploymentTech = strings .ToLower (deploymentTech )
215220
@@ -220,7 +225,7 @@ func (r *DeploymentSubroutine) Process(ctx context.Context, runtimeObj runtimeob
220225 log .Error ().Err (err ).Msg ("Failed to get cert-manager resource" )
221226 return ctrl.Result {}, errors .NewOperatorError (err , false , false )
222227 }
223- if deploymentTech == "argocd" {
228+ if deploymentTech == deploymentTechArgoCD {
224229 // For ArgoCD Applications, check status.sync.status and status.health.status directly
225230 // ArgoCD Applications may not have conditions initially, so check status fields directly
226231 syncStatus , found , _ := unstructured .NestedString (rel .Object , "status" , "sync" , "status" )
@@ -234,7 +239,7 @@ func (r *DeploymentSubroutine) Process(ctx context.Context, runtimeObj runtimeob
234239 }
235240 }
236241
237- if deploymentTech == "fluxcd" {
242+ if deploymentTech == deploymentTechFluxCD {
238243 // For FluxCD HelmReleases, check Ready condition
239244 if ! matchesConditionWithStatus (rel , "Ready" , "True" ) {
240245 return ctrl.Result {}, errors .NewOperatorError (errors .New ("cert-manager Release is not ready" ), true , false )
@@ -271,7 +276,7 @@ func (r *DeploymentSubroutine) Process(ctx context.Context, runtimeObj runtimeob
271276 log .Error ().Err (err ).Msg ("Failed to get istio-istiod resource" )
272277 return ctrl.Result {}, errors .NewOperatorError (err , false , false )
273278 }
274- if deploymentTech == "argocd" {
279+ if deploymentTech == deploymentTechArgoCD {
275280 // For ArgoCD Applications, check status.sync.status and status.health.status directly
276281 syncStatus , found , _ := unstructured .NestedString (rel .Object , "status" , "sync" , "status" )
277282 healthStatus , healthFound , _ := unstructured .NestedString (rel .Object , "status" , "health" , "status" )
@@ -284,7 +289,7 @@ func (r *DeploymentSubroutine) Process(ctx context.Context, runtimeObj runtimeob
284289 }
285290 }
286291
287- if deploymentTech == "fluxcd" {
292+ if deploymentTech == deploymentTechFluxCD {
288293 // For FluxCD HelmReleases, check Ready condition
289294 if ! matchesConditionWithStatus (rel , "Ready" , "True" ) {
290295 return ctrl.Result {}, errors .NewOperatorError (errors .New ("istio-istiod Release is not ready" ), true , false )
@@ -361,7 +366,7 @@ func (r *DeploymentSubroutine) templateVarsFromProfileInfra(ctx context.Context,
361366 }
362367
363368 // Add deploymentTechnology from profile or templateVars (defaults to fluxcd if not specified)
364- deploymentTech := "fluxcd" // default
369+ deploymentTech := deploymentTechFluxCD // default
365370 if deploymentTechFromProfile , ok := infraProfileMap ["deploymentTechnology" ].(string ); ok && deploymentTechFromProfile != "" {
366371 deploymentTech = deploymentTechFromProfile
367372 }
@@ -370,17 +375,14 @@ func (r *DeploymentSubroutine) templateVarsFromProfileInfra(ctx context.Context,
370375 }
371376 // Normalize to lowercase
372377 deploymentTech = strings .ToLower (deploymentTech )
373- if deploymentTech != "fluxcd" && deploymentTech != "argocd" {
374- deploymentTech = "fluxcd" // default to fluxcd if invalid
378+ if deploymentTech != deploymentTechFluxCD && deploymentTech != deploymentTechArgoCD {
379+ deploymentTech = deploymentTechFluxCD // default to fluxcd if invalid
375380 }
376381 infraProfileMap ["deploymentTechnology" ] = deploymentTech
377382
378383 // Merge infra profile (base) with templateVars (overrides)
379384 // templateVars take precedence over profile values
380- log , err := logger .New (logger .DefaultConfig ())
381- if err != nil {
382- return nil , errors .Wrap (err , "Failed to create logger" )
383- }
385+ log := logger .LoadLoggerFromContext (ctx ).ChildLogger ("subroutine" , r .GetName ())
384386 tmplVars , err := merge .MergeMaps (infraProfileMap , templateVarsMap , log )
385387 if err != nil {
386388 return nil , errors .Wrap (err , "Failed to merge infra profile with templateVars" )
@@ -523,10 +525,7 @@ func (r *DeploymentSubroutine) buildRuntimeTemplateVars(ctx context.Context, ins
523525// buildComponentsTemplateVars parses components profile using TemplateVars and produces the data
524526// structure expected by gotemplates/components (root keys: values, releaseNamespace).
525527func (r * DeploymentSubroutine ) buildComponentsTemplateVars (ctx context.Context , inst * v1alpha1.PlatformMesh , templateVars apiextensionsv1.JSON ) (map [string ]interface {}, error ) {
526- log , err := logger .New (logger .DefaultConfig ())
527- if err != nil {
528- return nil , errors .Wrap (err , "Failed to create logger" )
529- }
528+ log := logger .LoadLoggerFromContext (ctx ).ChildLogger ("subroutine" , r .GetName ())
530529
531530 // Load components profile from ConfigMap
532531 _ , componentsProfileYaml , err := r .loadProfileSections (ctx , inst )
@@ -659,7 +658,7 @@ func (r *DeploymentSubroutine) buildComponentsTemplateVars(ctx context.Context,
659658 }
660659
661660 // Add deploymentTechnology from profile or templateVars (defaults to fluxcd if not specified)
662- deploymentTech := "fluxcd" // default
661+ deploymentTech := deploymentTechFluxCD // default
663662 if deploymentTechFromProfile , ok := values ["deploymentTechnology" ].(string ); ok && deploymentTechFromProfile != "" {
664663 deploymentTech = deploymentTechFromProfile
665664 }
@@ -668,13 +667,13 @@ func (r *DeploymentSubroutine) buildComponentsTemplateVars(ctx context.Context,
668667 }
669668 // Normalize to lowercase
670669 deploymentTech = strings .ToLower (deploymentTech )
671- if deploymentTech != "fluxcd" && deploymentTech != "argocd" {
672- deploymentTech = "fluxcd" // default to fluxcd if invalid
670+ if deploymentTech != deploymentTechFluxCD && deploymentTech != deploymentTechArgoCD {
671+ deploymentTech = deploymentTechFluxCD // default to fluxcd if invalid
673672 }
674673 data ["deploymentTechnology" ] = deploymentTech
675674
676675 // Calculate sync waves for ArgoCD Applications based on dependsOn
677- if deploymentTech == "argocd" {
676+ if deploymentTech == deploymentTechArgoCD {
678677 if err := calculateSyncWaves (mergedServices ); err != nil {
679678 log .Warn ().Err (err ).Msg ("Failed to calculate sync waves, continuing without sync wave annotations" )
680679 }
@@ -1036,7 +1035,7 @@ func (r *DeploymentSubroutine) renderAndApplyInfraTemplates(ctx context.Context,
10361035
10371036 deploymentTech , ok := tmplVars ["deploymentTechnology" ].(string )
10381037 if ! ok {
1039- deploymentTech = "fluxcd"
1038+ deploymentTech = deploymentTechFluxCD
10401039 }
10411040 deploymentTech = strings .ToLower (deploymentTech )
10421041
@@ -1072,7 +1071,7 @@ func (r *DeploymentSubroutine) renderAndApplyComponentsInfraTemplates(ctx contex
10721071
10731072 deploymentTech , ok := tmplVars ["deploymentTechnology" ].(string )
10741073 if ! ok {
1075- deploymentTech = "fluxcd"
1074+ deploymentTech = deploymentTechFluxCD
10761075 }
10771076 deploymentTech = strings .ToLower (deploymentTech )
10781077
@@ -1295,7 +1294,7 @@ func getDeploymentResource(ctx context.Context, client client.Client, resourceNa
12951294 deploymentTech = strings .ToLower (deploymentTech )
12961295 obj := & unstructured.Unstructured {}
12971296
1298- if deploymentTech == "argocd" {
1297+ if deploymentTech == deploymentTechArgoCD {
12991298 obj .SetGroupVersionKind (schema.GroupVersionKind {Group : "argoproj.io" , Version : "v1alpha1" , Kind : "Application" })
13001299 } else {
13011300 // Default to FluxCD
0 commit comments