github.com/verrazzano/verrazzano@v1.7.0/platform-operator/controllers/secrets/secrets_utils_test.go (about)

     1  // Copyright (c) 2022, 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 secrets
     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  	testSecretName = "po-val"
    17  	testVZName     = "test-vz"
    18  )
    19  
    20  var compStatusMap = makeVerrazzanoComponentStatusMap()
    21  
    22  var testSecret = corev1.Secret{
    23  	TypeMeta: metav1.TypeMeta{
    24  		Kind: "Secret",
    25  	},
    26  	ObjectMeta: metav1.ObjectMeta{
    27  		Name:      testSecretName,
    28  		Namespace: testNS,
    29  	},
    30  	Immutable: nil,
    31  	Data:      map[string][]byte{"override": []byte("true")},
    32  }
    33  
    34  var testVZ = vzapi.Verrazzano{
    35  	TypeMeta: metav1.TypeMeta{
    36  		APIVersion: "install.verrazzano.io/v1alpha1",
    37  		Kind:       "Verrazzano",
    38  	},
    39  	ObjectMeta: metav1.ObjectMeta{
    40  		Name:      testVZName,
    41  		Namespace: testNS,
    42  	},
    43  	Spec: vzapi.VerrazzanoSpec{
    44  		Components: vzapi.ComponentSpec{PrometheusOperator: &vzapi.PrometheusOperatorComponent{
    45  			Enabled: True(),
    46  			InstallOverrides: vzapi.InstallOverrides{
    47  				MonitorChanges: True(),
    48  				ValueOverrides: []vzapi.Overrides{
    49  					{
    50  						SecretRef: &corev1.SecretKeySelector{
    51  							LocalObjectReference: corev1.LocalObjectReference{
    52  								Name: testSecretName,
    53  							},
    54  							Key:      "",
    55  							Optional: nil,
    56  						},
    57  					},
    58  				},
    59  			},
    60  		}},
    61  	},
    62  	Status: vzapi.VerrazzanoStatus{
    63  		State: vzapi.VzStateReady,
    64  		Conditions: []vzapi.Condition{
    65  			{
    66  				Type: vzapi.CondInstallComplete,
    67  			},
    68  		},
    69  		Components: compStatusMap,
    70  	},
    71  }
    72  
    73  // create component status map required for testing
    74  func makeVerrazzanoComponentStatusMap() vzapi.ComponentStatusMap {
    75  	statusMap := make(vzapi.ComponentStatusMap)
    76  	for _, comp := range registry.GetComponents() {
    77  		if comp.IsOperatorInstallSupported() {
    78  			statusMap[comp.Name()] = &vzapi.ComponentStatusDetails{
    79  				Name: comp.Name(),
    80  				Conditions: []vzapi.Condition{
    81  					{
    82  						Type:   vzapi.CondInstallComplete,
    83  						Status: corev1.ConditionTrue,
    84  					},
    85  				},
    86  				State: vzapi.CompStateReady,
    87  			}
    88  		}
    89  	}
    90  	return statusMap
    91  }
    92  
    93  // return address of a bool var with true value
    94  func True() *bool {
    95  	x := true
    96  	return &x
    97  }