@@ -41,12 +41,14 @@ func ImplementMemcachedMolecule(sample sample.Sample, image string) {
4141 err := kbutil .InsertCode (moleculeTaskPath , targetMoleculeCheckDeployment , molecuTaskToCheckConfigMap )
4242 pkg .CheckError ("replacing memcached task to add config map check" , err )
4343
44- log .Info ("insert molecule task to ensure to check secret" )
45- err = kbutil .InsertCode (moleculeTaskPath , memcachedCustomStatusMoleculeTarget , testSecretMoleculeCheck )
46- pkg .CheckError ("replacing memcached task to add secret check" , err )
44+ if skipSecretGeneration == "" {
45+ log .Info ("insert molecule task to ensure to check secret" )
46+ err = kbutil .InsertCode (moleculeTaskPath , memcachedCustomStatusMoleculeTarget , testSecretMoleculeCheck )
47+ pkg .CheckError ("replacing memcached task to add secret check" , err )
48+ }
4749
4850 log .Info ("insert molecule task to ensure to foo " )
49- err = kbutil .InsertCode (moleculeTaskPath , testSecretMoleculeCheck , testFooMoleculeCheck )
51+ err = kbutil .InsertCode (moleculeTaskPath , memcachedCustomStatusMoleculeTarget , testFooMoleculeCheck )
5052 pkg .CheckError ("replacing memcached task to add foo check" , err )
5153
5254 log .Info ("insert molecule task to check custom metrics" )
@@ -100,34 +102,36 @@ func ImplementMemcachedMolecule(sample sample.Sample, image string) {
100102 "playbook: playbooks/memcached.yml" , memcachedWatchCustomizations )
101103 pkg .CheckError ("replacing in watches" , err )
102104
103- log .Info ("removing ignore group for the secret from watches as an workaround to work with core types" )
104- err = kbutil .ReplaceInFile (filepath .Join (sample .Dir (), "watches.yaml" ),
105- "ignore.example.com" , "\" \" " )
106- pkg .CheckError ("replacing the watches file" , err )
107-
108- log .Info ("removing molecule test for the Secret since it is a core type" )
109- cmd := exec .Command ("rm" , "-rf" , filepath .Join (sample .Dir (), "molecule" , "default" , "tasks" , "secret_test.yml" ))
110- _ , err = sample .CommandContext ().Run (cmd )
111- pkg .CheckError ("removing secret test file" , err )
112-
113- log .Info ("adding Secret task to the role" )
114- err = kbutil .ReplaceInFile (filepath .Join (sample .Dir (), "roles" , "secret" , "tasks" , "main.yml" ),
115- originalTaskSecret , taskForSecret )
116- pkg .CheckError ("replacing in secret/tasks/main.yml file" , err )
117-
118- log .Info ("adding ManageStatus == false for role secret" )
119- err = kbutil .ReplaceInFile (filepath .Join (sample .Dir (), "watches.yaml" ),
120- "role: secret" , manageStatusFalseForRoleSecret )
121- pkg .CheckError ("replacing in watches.yaml" , err )
122-
123- // prevent high load of controller caused by watching all the secrets in the cluster
124- watchNamespacePatchFileName := "watch_namespace_patch.yaml"
125- log .Info ("adding WATCH_NAMESPACE env patch to watch own namespace" )
126- err = os .WriteFile (filepath .Join (sample .Dir (), "config" , "testing" , watchNamespacePatchFileName ), []byte (watchNamespacePatch ), 0644 )
127- pkg .CheckError ("adding watch_namespace_patch.yaml" , err )
128-
129- log .Info ("adding WATCH_NAMESPACE env patch to patch list to be applied" )
130- err = kbutil .InsertCode (filepath .Join (sample .Dir (), "config" , "testing" , "kustomization.yaml" ), "patchesStrategicMerge:" ,
131- fmt .Sprintf ("\n - %s" , watchNamespacePatchFileName ))
132- pkg .CheckError ("inserting in kustomization.yaml" , err )
105+ if skipSecretGeneration == "" {
106+ log .Info ("removing ignore group for the secret from watches as an workaround to work with core types" )
107+ err = kbutil .ReplaceInFile (filepath .Join (sample .Dir (), "watches.yaml" ),
108+ "ignore.example.com" , "\" \" " )
109+ pkg .CheckError ("replacing the watches file" , err )
110+
111+ log .Info ("removing molecule test for the Secret since it is a core type" )
112+ cmd := exec .Command ("rm" , "-rf" , filepath .Join (sample .Dir (), "molecule" , "default" , "tasks" , "secret_test.yml" ))
113+ _ , err = sample .CommandContext ().Run (cmd )
114+ pkg .CheckError ("removing secret test file" , err )
115+
116+ log .Info ("adding Secret task to the role" )
117+ err = kbutil .ReplaceInFile (filepath .Join (sample .Dir (), "roles" , "secret" , "tasks" , "main.yml" ),
118+ originalTaskSecret , taskForSecret )
119+ pkg .CheckError ("replacing in secret/tasks/main.yml file" , err )
120+
121+ log .Info ("adding ManageStatus == false for role secret" )
122+ err = kbutil .ReplaceInFile (filepath .Join (sample .Dir (), "watches.yaml" ),
123+ "role: secret" , manageStatusFalseForRoleSecret )
124+ pkg .CheckError ("replacing in watches.yaml" , err )
125+
126+ // prevent high load of controller caused by watching all the secrets in the cluster
127+ watchNamespacePatchFileName := "watch_namespace_patch.yaml"
128+ log .Info ("adding WATCH_NAMESPACE env patch to watch own namespace" )
129+ err = os .WriteFile (filepath .Join (sample .Dir (), "config" , "testing" , watchNamespacePatchFileName ), []byte (watchNamespacePatch ), 0644 )
130+ pkg .CheckError ("adding watch_namespace_patch.yaml" , err )
131+
132+ log .Info ("adding WATCH_NAMESPACE env patch to patch list to be applied" )
133+ err = kbutil .InsertCode (filepath .Join (sample .Dir (), "config" , "testing" , "kustomization.yaml" ), "patchesStrategicMerge:" ,
134+ fmt .Sprintf ("\n - %s" , watchNamespacePatchFileName ))
135+ pkg .CheckError ("inserting in kustomization.yaml" , err )
136+ }
133137}
0 commit comments