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