From abecbb7ace9c7f83d3212b6c5a5f30c4f2983f74 Mon Sep 17 00:00:00 2001
From: Daniel Scholl <dascholl@microsoft.com>
Date: Thu, 3 Oct 2024 09:14:34 -0500
Subject: [PATCH] Modified conditional gitops configuration.

---
 bicep/modules/blade_service.bicep | 84 +++++++++++++++++--------------
 1 file changed, 47 insertions(+), 37 deletions(-)

diff --git a/bicep/modules/blade_service.bicep b/bicep/modules/blade_service.bicep
index 7578ab12..ffab1679 100644
--- a/bicep/modules/blade_service.bicep
+++ b/bicep/modules/blade_service.bicep
@@ -717,38 +717,6 @@ module appConfigMap './aks-config-map/main.bicep' = {
  \______| |__|     |__|      \______/  | _|   |_______/                                                          
 */
 
-var componentKustomization = {
-  path: serviceLayerConfig.gitops.components
-  timeoutInSeconds: 300
-  syncIntervalInSeconds: 300
-  retryIntervalInSeconds: 300
-  prune: true
-}
-
-var applicationKustomization = {
-  path: serviceLayerConfig.gitops.applications
-  dependsOn: [
-    'components'
-  ]
-  timeoutInSeconds: 300
-  syncIntervalInSeconds: 300
-  retryIntervalInSeconds: 300
-  prune: true
-}
-
-var experimentalKustomization = {
-  experimental: {
-    path: serviceLayerConfig.gitops.experimental
-    dependsOn: [
-      'applications'
-    ]
-    timeoutInSeconds: 300
-    syncIntervalInSeconds: 300
-    retryIntervalInSeconds: 300
-    prune: true
-  }
-}
-
 //--------------Flux Config---------------
 module fluxConfiguration 'br/public:avm/res/kubernetes-configuration/flux-configuration:0.3.3' = if(enableSoftwareLoad) {
   name: '${bladeConfig.sectionName}-cluster-gitops'
@@ -768,11 +736,53 @@ module fluxConfiguration 'br/public:avm/res/kubernetes-configuration/flux-config
         tag: serviceLayerConfig.gitops.tag
       }
     }
-
-    kustomizations: union(
-      componentKustomization, 
-      applicationKustomization, 
-      enableExperimental ? experimentalKustomization : {})
+    kustomizations: enableExperimental ? {
+      components: {
+        path: serviceLayerConfig.gitops.components
+        timeoutInSeconds: 300
+        syncIntervalInSeconds: 300
+        retryIntervalInSeconds: 300
+        prune: true
+      }
+      applications: {
+        path: serviceLayerConfig.gitops.applications
+        dependsOn: [
+          'components'
+        ]
+        timeoutInSeconds: 300
+        syncIntervalInSeconds: 300
+        retryIntervalInSeconds: 300
+        prune: true
+      }
+      experimental: {
+        path: serviceLayerConfig.gitops.experimental
+        dependsOn: [
+          'applications'
+        ]
+        timeoutInSeconds: 300
+        syncIntervalInSeconds: 300
+        retryIntervalInSeconds: 300
+        prune: true
+      }
+    } : {
+      components: {
+        path: serviceLayerConfig.gitops.components
+        timeoutInSeconds: 300
+        syncIntervalInSeconds: 300
+        retryIntervalInSeconds: 300
+        prune: true
+      }
+      applications: {
+        path: serviceLayerConfig.gitops.applications
+        dependsOn: [
+          'components'
+        ]
+        timeoutInSeconds: 300
+        syncIntervalInSeconds: 300
+        retryIntervalInSeconds: 300
+        prune: true
+      }
+    }
   }
   dependsOn: [
     app_config