github.com/verrazzano/verrazzano@v1.7.0/platform-operator/controllers/configmaps/overrides/controller_utils_test.go (about) 1 // Copyright (c) 2022, 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package overrides 5 6 import ( 7 vzapi "github.com/verrazzano/verrazzano/platform-operator/apis/verrazzano/v1alpha1" 8 "github.com/verrazzano/verrazzano/platform-operator/controllers/verrazzano/component/registry" 9 10 corev1 "k8s.io/api/core/v1" 11 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 12 ) 13 14 const ( 15 testNS = "default" 16 testCMName = "po-val" 17 testVZName = "test-vz" 18 testVZConfig = "test-vz-effective-config" 19 ) 20 21 var compStatusMap = makeVerrazzanoComponentStatusMap() 22 23 var testConfigMap = corev1.ConfigMap{ 24 TypeMeta: metav1.TypeMeta{ 25 Kind: "ConfigMap", 26 }, 27 ObjectMeta: metav1.ObjectMeta{ 28 Name: testCMName, 29 Namespace: testNS, 30 Finalizers: nil, 31 DeletionTimestamp: nil, 32 }, 33 Immutable: nil, 34 Data: map[string]string{"override": "true"}, 35 BinaryData: nil, 36 } 37 38 var testVZ = vzapi.Verrazzano{ 39 TypeMeta: metav1.TypeMeta{ 40 APIVersion: "install.verrazzano.io/v1alpha1", 41 Kind: "Verrazzano", 42 }, 43 ObjectMeta: metav1.ObjectMeta{ 44 Name: testVZName, 45 Namespace: testNS, 46 }, 47 Spec: vzapi.VerrazzanoSpec{ 48 Components: vzapi.ComponentSpec{PrometheusOperator: &vzapi.PrometheusOperatorComponent{ 49 Enabled: True(), 50 InstallOverrides: vzapi.InstallOverrides{ 51 MonitorChanges: True(), 52 ValueOverrides: []vzapi.Overrides{ 53 { 54 ConfigMapRef: &corev1.ConfigMapKeySelector{ 55 LocalObjectReference: corev1.LocalObjectReference{ 56 Name: testCMName, 57 }, 58 Key: "", 59 Optional: nil, 60 }, 61 }, 62 }, 63 }, 64 }}, 65 }, 66 Status: vzapi.VerrazzanoStatus{ 67 State: vzapi.VzStateReady, 68 Conditions: []vzapi.Condition{ 69 { 70 Type: vzapi.CondInstallComplete, 71 }, 72 }, 73 Components: compStatusMap, 74 }, 75 } 76 77 // create verrazzano component status map for testing 78 func makeVerrazzanoComponentStatusMap() vzapi.ComponentStatusMap { 79 statusMap := make(vzapi.ComponentStatusMap) 80 for _, comp := range registry.GetComponents() { 81 if comp.IsOperatorInstallSupported() { 82 statusMap[comp.Name()] = &vzapi.ComponentStatusDetails{ 83 Name: comp.Name(), 84 Conditions: []vzapi.Condition{ 85 { 86 Type: vzapi.CondInstallComplete, 87 Status: corev1.ConditionTrue, 88 }, 89 }, 90 State: vzapi.CompStateReady, 91 } 92 } 93 } 94 return statusMap 95 } 96 97 // return address of a bool var with true value 98 func True() *bool { 99 x := true 100 return &x 101 }