@@ -23,20 +23,16 @@ import (
2323 "github.com/go-logr/logr"
2424 "github.com/openstack-k8s-operators/lib-common/modules/common"
2525 "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
26- "github.com/openstack-k8s-operators/lib-common/modules/common/configmap"
2726 "github.com/openstack-k8s-operators/lib-common/modules/common/env"
2827 "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
2928 "github.com/openstack-k8s-operators/lib-common/modules/common/job"
3029 common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac"
31- "github.com/openstack-k8s-operators/lib-common/modules/common/util"
3230 testv1beta1 "github.com/openstack-k8s-operators/test-operator/api/v1beta1"
3331 "github.com/openstack-k8s-operators/test-operator/pkg/horizontest"
34- "gopkg.in/yaml.v3"
3532 batchv1 "k8s.io/api/batch/v1"
3633 corev1 "k8s.io/api/core/v1"
3734 k8s_errors "k8s.io/apimachinery/pkg/api/errors"
3835 ctrl "sigs.k8s.io/controller-runtime"
39- "sigs.k8s.io/controller-runtime/pkg/client"
4036 "sigs.k8s.io/controller-runtime/pkg/log"
4137)
4238
@@ -155,7 +151,7 @@ func (r *HorizonTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
155151 "workflowStep" : "0" ,
156152 }
157153
158- yamlResult , err := r . EnsureHorizonTestCloudsYAML (ctx , instance , helper , serviceLabels )
154+ yamlResult , err := EnsureCloudsConfigMapExists (ctx , instance , helper , serviceLabels )
159155
160156 if err != nil {
161157 return yamlResult , err
@@ -272,49 +268,6 @@ func (r *HorizonTestReconciler) SetupWithManager(mgr ctrl.Manager) error {
272268 Complete (r )
273269}
274270
275- // Horizon requires password value to be present in clouds.yaml
276- // This code ensures that we set a default value of 12345678 when
277- // password value is missing in the clouds.yaml
278- func (r * HorizonTestReconciler ) EnsureHorizonTestCloudsYAML (ctx context.Context , instance client.Object , helper * helper.Helper , labels map [string ]string ) (ctrl.Result , error ) {
279- cm , _ , _ := configmap .GetConfigMap (ctx , helper , instance , "openstack-config" , time .Second * 10 )
280- result := make (map [string ]interface {})
281-
282- err := yaml .Unmarshal ([]byte (cm .Data ["clouds.yaml" ]), & result )
283- if err != nil {
284- return ctrl.Result {}, err
285- }
286-
287- clouds := result ["clouds" ].(map [string ]interface {})
288- defaultValue := clouds ["default" ].(map [string ]interface {})
289- auth := defaultValue ["auth" ].(map [string ]interface {})
290-
291- if _ , ok := auth ["password" ].(string ); ! ok {
292- auth ["password" ] = "12345678"
293- }
294-
295- yamlString , err := yaml .Marshal (result )
296- if err != nil {
297- return ctrl.Result {}, err
298- }
299-
300- cms := []util.Template {
301- {
302- Name : "horizontest-clouds-config" ,
303- Namespace : instance .GetNamespace (),
304- Labels : labels ,
305- CustomData : map [string ]string {
306- "clouds.yaml" : string (yamlString ),
307- },
308- },
309- }
310- err = configmap .EnsureConfigMaps (ctx , helper , instance , cms , nil )
311- if err != nil {
312- return ctrl.Result {}, err
313- }
314-
315- return ctrl.Result {}, nil
316- }
317-
318271func (r * HorizonTestReconciler ) PrepareHorizonTestEnvVars (
319272 instance * testv1beta1.HorizonTest ,
320273) map [string ]env.Setter {
0 commit comments