github.com/verrazzano/verrazzano@v1.7.1/pkg/profiles/merge.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 profiles
     5  
     6  import (
     7  	vzyaml "github.com/verrazzano/verrazzano/pkg/yaml"
     8  	"github.com/verrazzano/verrazzano/platform-operator/apis/verrazzano/v1alpha1"
     9  	"github.com/verrazzano/verrazzano/platform-operator/apis/verrazzano/v1beta1"
    10  	"os"
    11  	"sigs.k8s.io/yaml"
    12  )
    13  
    14  // MergeProfiles merges a list of v1alpha1.Verrazzano profile files with an existing Verrazzano CR.
    15  // The profiles must be in the Verrazzano CR format
    16  func MergeProfiles(actualCR *v1alpha1.Verrazzano, profileFiles ...string) (*v1alpha1.Verrazzano, error) {
    17  	// First merge the profiles
    18  	profileStrings, err := appendProfileComponentOverrides(profileFiles...)
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  	merged, err := vzyaml.StrategicMerge(v1alpha1.Verrazzano{}, profileStrings...)
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  
    27  	profileVerrazzano := &v1alpha1.Verrazzano{}
    28  	if err := yaml.Unmarshal([]byte(merged), profileVerrazzano); err != nil {
    29  		return nil, err
    30  	}
    31  	cr := actualCR.DeepCopy()
    32  	AppendComponentOverrides(cr, profileVerrazzano)
    33  
    34  	// Now merge the profiles on top of the Verrazzano CR
    35  	crYAML, err := yaml.Marshal(cr)
    36  	if err != nil {
    37  		return nil, err
    38  	}
    39  
    40  	// merge all profiles together into a single yaml
    41  	merged, err = vzyaml.StrategicMerge(v1alpha1.Verrazzano{}, merged, string(crYAML))
    42  	if err != nil {
    43  		return nil, err
    44  	}
    45  
    46  	// Return a new CR
    47  	var newCR v1alpha1.Verrazzano
    48  	err = yaml.Unmarshal([]byte(merged), &newCR)
    49  	if err != nil {
    50  		return nil, err
    51  	}
    52  
    53  	setNilV1alpha1OSReplicasToZero(&newCR)
    54  	return &newCR, nil
    55  }
    56  
    57  // MergeProfilesForV1beta1 merges a list of v1beta1.Verrazzano profile files with an existing Verrazzano CR.
    58  // The profiles must be in the Verrazzano CR format
    59  func MergeProfilesForV1beta1(actualCR *v1beta1.Verrazzano, profileFiles ...string) (*v1beta1.Verrazzano, error) {
    60  	// First merge the profiles
    61  	profileStrings, err := appendProfileComponentOverridesV1beta1(profileFiles...)
    62  	if err != nil {
    63  		return nil, err
    64  	}
    65  	merged, err := vzyaml.StrategicMerge(v1beta1.Verrazzano{}, profileStrings...)
    66  	if err != nil {
    67  		return nil, err
    68  	}
    69  
    70  	profileVerrazzano := &v1beta1.Verrazzano{}
    71  	if err := yaml.Unmarshal([]byte(merged), profileVerrazzano); err != nil {
    72  		return nil, err
    73  	}
    74  	cr := actualCR.DeepCopy()
    75  	AppendComponentOverridesV1beta1(cr, profileVerrazzano)
    76  
    77  	// Now merge the profiles on top of the Verrazzano CR
    78  	crYAML, err := yaml.Marshal(cr)
    79  	if err != nil {
    80  		return nil, err
    81  	}
    82  
    83  	// merge all profiles together into a single yaml
    84  	merged, err = vzyaml.StrategicMerge(v1beta1.Verrazzano{}, merged, string(crYAML))
    85  	if err != nil {
    86  		return nil, err
    87  	}
    88  
    89  	// Return a new CR
    90  	var newCR v1beta1.Verrazzano
    91  	err = yaml.Unmarshal([]byte(merged), &newCR)
    92  	if err != nil {
    93  		return nil, err
    94  	}
    95  	setNilV1beta1OSReplicasToZero(&newCR)
    96  	return &newCR, nil
    97  }
    98  
    99  func appendProfileComponentOverrides(profileFiles ...string) ([]string, error) {
   100  	var profileCR *v1alpha1.Verrazzano
   101  	var profileStrings []string
   102  	for i := range profileFiles {
   103  		profileFile := profileFiles[len(profileFiles)-1-i]
   104  		data, err := os.ReadFile(profileFile)
   105  		if err != nil {
   106  			return nil, err
   107  		}
   108  		cr := &v1alpha1.Verrazzano{}
   109  		if err := yaml.Unmarshal(data, cr); err != nil {
   110  			return nil, err
   111  		}
   112  		if profileCR == nil {
   113  			profileCR = cr
   114  		} else {
   115  			AppendComponentOverrides(profileCR, cr)
   116  			profileStrings = append(profileStrings, string(data))
   117  		}
   118  
   119  	}
   120  	data, err := yaml.Marshal(profileCR)
   121  	if err != nil {
   122  		return nil, err
   123  	}
   124  	profileStrings = append(profileStrings, string(data))
   125  	return profileStrings, nil
   126  }
   127  
   128  func appendProfileComponentOverridesV1beta1(profileFiles ...string) ([]string, error) {
   129  	var profileCR *v1beta1.Verrazzano
   130  	var profileStrings []string
   131  	for i := range profileFiles {
   132  		profileFile := profileFiles[len(profileFiles)-1-i]
   133  		data, err := os.ReadFile(profileFile)
   134  		if err != nil {
   135  			return nil, err
   136  		}
   137  		cr := &v1beta1.Verrazzano{}
   138  		if err := yaml.Unmarshal(data, cr); err != nil {
   139  			return nil, err
   140  		}
   141  		if profileCR == nil {
   142  			profileCR = cr
   143  		} else {
   144  			AppendComponentOverridesV1beta1(profileCR, cr)
   145  			profileStrings = append(profileStrings, string(data))
   146  		}
   147  
   148  	}
   149  	data, err := yaml.Marshal(profileCR)
   150  	if err != nil {
   151  		return nil, err
   152  	}
   153  	profileStrings = append(profileStrings, string(data))
   154  	return profileStrings, nil
   155  }
   156  
   157  // AppendComponentOverrides copies the profile overrides of v1alpha1.Verrazzano over to the actual overrides. Any component that has overrides should be included here.
   158  // Because overrides lacks a proper merge key, a strategic merge will replace the array instead of merging it. This function stops that replacement from occurring.
   159  // The profile CR overrides must be appended to the actual CR overrides to preserve the precedence order in the way HelmComponent consumes them.
   160  func AppendComponentOverrides(actual, profile *v1alpha1.Verrazzano) {
   161  	actualKubeStateMetrics := actual.Spec.Components.KubeStateMetrics
   162  	profileKubeStateMetrics := profile.Spec.Components.KubeStateMetrics
   163  	if actualKubeStateMetrics != nil && profileKubeStateMetrics != nil {
   164  		actualKubeStateMetrics.ValueOverrides = mergeOverrides(actualKubeStateMetrics.ValueOverrides, profileKubeStateMetrics.ValueOverrides)
   165  	}
   166  
   167  	actualPrometheusAdapter := actual.Spec.Components.PrometheusAdapter
   168  	profilePrometheusAdapter := profile.Spec.Components.PrometheusAdapter
   169  	if actualPrometheusAdapter != nil && profilePrometheusAdapter != nil {
   170  		actualPrometheusAdapter.ValueOverrides = mergeOverrides(actualPrometheusAdapter.ValueOverrides, profilePrometheusAdapter.ValueOverrides)
   171  	}
   172  
   173  	actualPrometheusNodeExporter := actual.Spec.Components.PrometheusNodeExporter
   174  	profilePrometheusNodeExporter := profile.Spec.Components.PrometheusNodeExporter
   175  	if actualPrometheusNodeExporter != nil && profilePrometheusNodeExporter != nil {
   176  		actualPrometheusNodeExporter.ValueOverrides = mergeOverrides(actualPrometheusNodeExporter.ValueOverrides, profilePrometheusNodeExporter.ValueOverrides)
   177  	}
   178  
   179  	actualPrometheusOperator := actual.Spec.Components.PrometheusOperator
   180  	profilePrometheusOperator := profile.Spec.Components.PrometheusOperator
   181  	if actualPrometheusOperator != nil && profilePrometheusOperator != nil {
   182  		actualPrometheusOperator.ValueOverrides = mergeOverrides(actualPrometheusOperator.ValueOverrides, profilePrometheusOperator.ValueOverrides)
   183  	}
   184  
   185  	actualPrometheusPushgateway := actual.Spec.Components.PrometheusPushgateway
   186  	profilePrometheusPushgateway := profile.Spec.Components.PrometheusPushgateway
   187  	if actualPrometheusPushgateway != nil && profilePrometheusPushgateway != nil {
   188  		actualPrometheusPushgateway.ValueOverrides = mergeOverrides(actualPrometheusPushgateway.ValueOverrides, profilePrometheusPushgateway.ValueOverrides)
   189  	}
   190  
   191  	actualCertManager := actual.Spec.Components.CertManager
   192  	profileCertManager := profile.Spec.Components.CertManager
   193  	if actualCertManager != nil && profileCertManager != nil {
   194  		actualCertManager.ValueOverrides = mergeOverrides(actualCertManager.ValueOverrides, profileCertManager.ValueOverrides)
   195  	}
   196  
   197  	actualOCIWebhook := actual.Spec.Components.CertManagerWebhookOCI
   198  	profileOCIWebhook := profile.Spec.Components.CertManagerWebhookOCI
   199  	if actualOCIWebhook != nil && profileOCIWebhook != nil {
   200  		actualOCIWebhook.ValueOverrides = mergeOverrides(actualOCIWebhook.ValueOverrides, profileOCIWebhook.ValueOverrides)
   201  	}
   202  
   203  	actualCoherenceOperator := actual.Spec.Components.CoherenceOperator
   204  	profileCoherenceOperator := profile.Spec.Components.CoherenceOperator
   205  	if actualCoherenceOperator != nil && profileCoherenceOperator != nil {
   206  		actualCoherenceOperator.ValueOverrides = mergeOverrides(actualCoherenceOperator.ValueOverrides, profileCoherenceOperator.ValueOverrides)
   207  	}
   208  
   209  	actualApplicationOperator := actual.Spec.Components.ApplicationOperator
   210  	profileApplicationOperator := profile.Spec.Components.ApplicationOperator
   211  	if actualApplicationOperator != nil && profileApplicationOperator != nil {
   212  		actualApplicationOperator.ValueOverrides = mergeOverrides(actualApplicationOperator.ValueOverrides, profileApplicationOperator.ValueOverrides)
   213  	}
   214  
   215  	actualAuthProxy := actual.Spec.Components.AuthProxy
   216  	profileAuthProxy := profile.Spec.Components.AuthProxy
   217  	if actualAuthProxy != nil && profileAuthProxy != nil {
   218  		actualAuthProxy.ValueOverrides = mergeOverrides(actualAuthProxy.ValueOverrides, profileAuthProxy.ValueOverrides)
   219  	}
   220  
   221  	actualOAM := actual.Spec.Components.OAM
   222  	profileOAM := profile.Spec.Components.OAM
   223  	if actualOAM != nil && profileOAM != nil {
   224  		actualOAM.ValueOverrides = mergeOverrides(actualOAM.ValueOverrides, profileOAM.ValueOverrides)
   225  	}
   226  
   227  	actualVerrazzano := actual.Spec.Components.Verrazzano
   228  	profileVerrazzano := profile.Spec.Components.Verrazzano
   229  	if actualVerrazzano != nil && profileVerrazzano != nil {
   230  		actualVerrazzano.ValueOverrides = mergeOverrides(actualVerrazzano.ValueOverrides, profileVerrazzano.ValueOverrides)
   231  	}
   232  
   233  	actualKiali := actual.Spec.Components.Kiali
   234  	profileKiali := profile.Spec.Components.Kiali
   235  	if actualKiali != nil && profileKiali != nil {
   236  		actualKiali.ValueOverrides = mergeOverrides(actualKiali.ValueOverrides, profileKiali.ValueOverrides)
   237  	}
   238  
   239  	actualConsole := actual.Spec.Components.Console
   240  	profileConsole := profile.Spec.Components.Console
   241  	if actualConsole != nil && profileConsole != nil {
   242  		actualConsole.ValueOverrides = mergeOverrides(actualConsole.ValueOverrides, profileConsole.ValueOverrides)
   243  	}
   244  
   245  	actualDNS := actual.Spec.Components.DNS
   246  	profileDNS := profile.Spec.Components.DNS
   247  	if actualDNS != nil && profileDNS != nil {
   248  		actualDNS.ValueOverrides = mergeOverrides(actualDNS.ValueOverrides, profileDNS.ValueOverrides)
   249  	}
   250  
   251  	actualIngress := actual.Spec.Components.Ingress
   252  	profileIngress := profile.Spec.Components.Ingress
   253  	if actualIngress != nil && profileIngress != nil {
   254  		actualIngress.ValueOverrides = mergeOverrides(actualIngress.ValueOverrides, profileIngress.ValueOverrides)
   255  	}
   256  
   257  	actualIstio := actual.Spec.Components.Istio
   258  	profileIstio := profile.Spec.Components.Istio
   259  	if actualIstio != nil && profileIstio != nil {
   260  		actualIstio.ValueOverrides = mergeOverrides(actualIstio.ValueOverrides, profileIstio.ValueOverrides)
   261  	}
   262  
   263  	actualJaegerOperator := actual.Spec.Components.JaegerOperator
   264  	profileJaegerOperator := profile.Spec.Components.JaegerOperator
   265  	if actualJaegerOperator != nil && profileJaegerOperator != nil {
   266  		actualJaegerOperator.ValueOverrides = mergeOverrides(actualJaegerOperator.ValueOverrides, profileJaegerOperator.ValueOverrides)
   267  	}
   268  
   269  	actualKeycloak := actual.Spec.Components.Keycloak
   270  	profileKeycloak := profile.Spec.Components.Keycloak
   271  	if actualKeycloak != nil && profileKeycloak != nil {
   272  		actualKeycloak.ValueOverrides = mergeOverrides(actualKeycloak.ValueOverrides, profileKeycloak.ValueOverrides)
   273  		actualKeycloak.MySQL.ValueOverrides = mergeOverrides(actualKeycloak.MySQL.ValueOverrides, profileKeycloak.MySQL.ValueOverrides)
   274  	}
   275  
   276  	actualRancher := actual.Spec.Components.Rancher
   277  	profileRancher := profile.Spec.Components.Rancher
   278  	if actualRancher != nil && profileRancher != nil {
   279  		actualRancher.ValueOverrides = mergeOverrides(actualRancher.ValueOverrides, profileRancher.ValueOverrides)
   280  	}
   281  
   282  	actualFluentd := actual.Spec.Components.Fluentd
   283  	profileFluentd := profile.Spec.Components.Fluentd
   284  	if actualFluentd != nil && profileFluentd != nil {
   285  		actualFluentd.ValueOverrides = mergeOverrides(actualFluentd.ValueOverrides, profileFluentd.ValueOverrides)
   286  	}
   287  
   288  	actualWebLogicOperator := actual.Spec.Components.WebLogicOperator
   289  	profileWebLogicOperator := profile.Spec.Components.WebLogicOperator
   290  	if actualWebLogicOperator != nil && profileWebLogicOperator != nil {
   291  		actualWebLogicOperator.ValueOverrides = mergeOverrides(actualWebLogicOperator.ValueOverrides, profileWebLogicOperator.ValueOverrides)
   292  	}
   293  
   294  	actualVelero := actual.Spec.Components.Velero
   295  	profileVelero := profile.Spec.Components.Velero
   296  	if actualVelero != nil && profileVelero != nil {
   297  		actualVelero.ValueOverrides = mergeOverrides(actualVelero.ValueOverrides, profileVelero.ValueOverrides)
   298  	}
   299  }
   300  
   301  // setNilV1alpha1OSReplicasToZero sets the replicas count to 0 if it is nil in the merged v1alpha1 CR
   302  // this is to avoid any nil pointer de-referencing further down the code
   303  func setNilV1alpha1OSReplicasToZero(merged *v1alpha1.Verrazzano) {
   304  	profileOpensearch := merged.Spec.Components.Elasticsearch
   305  	if profileOpensearch != nil {
   306  		for i := range profileOpensearch.Nodes {
   307  			if profileOpensearch.Nodes[i].Replicas == nil {
   308  				var v int32
   309  				profileOpensearch.Nodes[i].Replicas = &v
   310  			}
   311  		}
   312  	}
   313  }
   314  
   315  // setNilV1alpha1OSReplicasToZero sets the replicas count to 0 if it is nil in the merged v1beta1 CR
   316  // this is to avoid any nil pointer de-referencing further down the code
   317  func setNilV1beta1OSReplicasToZero(merged *v1beta1.Verrazzano) {
   318  	profileOpensearch := merged.Spec.Components.OpenSearch
   319  	if profileOpensearch != nil {
   320  		for i := range profileOpensearch.Nodes {
   321  			if profileOpensearch.Nodes[i].Replicas == nil {
   322  				var v int32
   323  				profileOpensearch.Nodes[i].Replicas = &v
   324  			}
   325  		}
   326  	}
   327  }
   328  
   329  // AppendComponentOverridesV1beta1 copies the profile overrides of v1beta1.Verrazzano over to the actual overrides. Any component that has overrides should be included here.
   330  // Because overrides lacks a proper merge key, a strategic merge will replace the array instead of merging it. This function stops that replacement from occurring.
   331  // The profile CR overrides must be appended to the actual CR overrides to preserve the precedence order in the way HelmComponent consumes them.
   332  func AppendComponentOverridesV1beta1(actual, profile *v1beta1.Verrazzano) {
   333  	actualKubeStateMetrics := actual.Spec.Components.KubeStateMetrics
   334  	profileKubeStateMetrics := profile.Spec.Components.KubeStateMetrics
   335  	if actualKubeStateMetrics != nil && profileKubeStateMetrics != nil {
   336  		actualKubeStateMetrics.ValueOverrides = mergeOverridesV1beta1(actualKubeStateMetrics.ValueOverrides, profileKubeStateMetrics.ValueOverrides)
   337  	}
   338  
   339  	actualPrometheusAdapter := actual.Spec.Components.PrometheusAdapter
   340  	profilePrometheusAdapter := profile.Spec.Components.PrometheusAdapter
   341  	if actualPrometheusAdapter != nil && profilePrometheusAdapter != nil {
   342  		actualPrometheusAdapter.ValueOverrides = mergeOverridesV1beta1(actualPrometheusAdapter.ValueOverrides, profilePrometheusAdapter.ValueOverrides)
   343  	}
   344  
   345  	actualPrometheusNodeExporter := actual.Spec.Components.PrometheusNodeExporter
   346  	profilePrometheusNodeExporter := profile.Spec.Components.PrometheusNodeExporter
   347  	if actualPrometheusNodeExporter != nil && profilePrometheusNodeExporter != nil {
   348  		actualPrometheusNodeExporter.ValueOverrides = mergeOverridesV1beta1(actualPrometheusNodeExporter.ValueOverrides, profilePrometheusNodeExporter.ValueOverrides)
   349  	}
   350  
   351  	actualPrometheusOperator := actual.Spec.Components.PrometheusOperator
   352  	profilePrometheusOperator := profile.Spec.Components.PrometheusOperator
   353  	if actualPrometheusOperator != nil && profilePrometheusOperator != nil {
   354  		actualPrometheusOperator.ValueOverrides = mergeOverridesV1beta1(actualPrometheusOperator.ValueOverrides, profilePrometheusOperator.ValueOverrides)
   355  	}
   356  
   357  	actualPrometheusPushgateway := actual.Spec.Components.PrometheusPushgateway
   358  	profilePrometheusPushgateway := profile.Spec.Components.PrometheusPushgateway
   359  	if actualPrometheusPushgateway != nil && profilePrometheusPushgateway != nil {
   360  		actualPrometheusPushgateway.ValueOverrides = mergeOverridesV1beta1(actualPrometheusPushgateway.ValueOverrides, profilePrometheusPushgateway.ValueOverrides)
   361  	}
   362  
   363  	actualCertManager := actual.Spec.Components.CertManager
   364  	profileCertManager := profile.Spec.Components.CertManager
   365  	if actualCertManager != nil && profileCertManager != nil {
   366  		actualCertManager.ValueOverrides = mergeOverridesV1beta1(actualCertManager.ValueOverrides, profileCertManager.ValueOverrides)
   367  	}
   368  
   369  	actualCoherenceOperator := actual.Spec.Components.CoherenceOperator
   370  	profileCoherenceOperator := profile.Spec.Components.CoherenceOperator
   371  	if actualCoherenceOperator != nil && profileCoherenceOperator != nil {
   372  		actualCoherenceOperator.ValueOverrides = mergeOverridesV1beta1(actualCoherenceOperator.ValueOverrides, profileCoherenceOperator.ValueOverrides)
   373  	}
   374  
   375  	actualApplicationOperator := actual.Spec.Components.ApplicationOperator
   376  	profileApplicationOperator := profile.Spec.Components.ApplicationOperator
   377  	if actualApplicationOperator != nil && profileApplicationOperator != nil {
   378  		actualApplicationOperator.ValueOverrides = mergeOverridesV1beta1(actualApplicationOperator.ValueOverrides, profileApplicationOperator.ValueOverrides)
   379  	}
   380  
   381  	actualAuthProxy := actual.Spec.Components.AuthProxy
   382  	profileAuthProxy := profile.Spec.Components.AuthProxy
   383  	if actualAuthProxy != nil && profileAuthProxy != nil {
   384  		actualAuthProxy.ValueOverrides = mergeOverridesV1beta1(actualAuthProxy.ValueOverrides, profileAuthProxy.ValueOverrides)
   385  	}
   386  
   387  	actualOAM := actual.Spec.Components.OAM
   388  	profileOAM := profile.Spec.Components.OAM
   389  	if actualOAM != nil && profileOAM != nil {
   390  		actualOAM.ValueOverrides = mergeOverridesV1beta1(actualOAM.ValueOverrides, profileOAM.ValueOverrides)
   391  	}
   392  
   393  	actualVerrazzano := actual.Spec.Components.Verrazzano
   394  	profileVerrazzano := profile.Spec.Components.Verrazzano
   395  	if actualVerrazzano != nil && profileVerrazzano != nil {
   396  		actualVerrazzano.ValueOverrides = mergeOverridesV1beta1(actualVerrazzano.ValueOverrides, profileVerrazzano.ValueOverrides)
   397  	}
   398  
   399  	actualKiali := actual.Spec.Components.Kiali
   400  	profileKiali := profile.Spec.Components.Kiali
   401  	if actualKiali != nil && profileKiali != nil {
   402  		actualKiali.ValueOverrides = mergeOverridesV1beta1(actualKiali.ValueOverrides, profileKiali.ValueOverrides)
   403  	}
   404  
   405  	actualConsole := actual.Spec.Components.Console
   406  	profileConsole := profile.Spec.Components.Console
   407  	if actualConsole != nil && profileConsole != nil {
   408  		actualConsole.ValueOverrides = mergeOverridesV1beta1(actualConsole.ValueOverrides, profileConsole.ValueOverrides)
   409  	}
   410  
   411  	actualDNS := actual.Spec.Components.DNS
   412  	profileDNS := profile.Spec.Components.DNS
   413  	if actualDNS != nil && profileDNS != nil {
   414  		actualDNS.ValueOverrides = mergeOverridesV1beta1(actualDNS.ValueOverrides, profileDNS.ValueOverrides)
   415  	}
   416  
   417  	actualIngress := actual.Spec.Components.IngressNGINX
   418  	profileIngress := profile.Spec.Components.IngressNGINX
   419  	if actualIngress != nil && profileIngress != nil {
   420  		actualIngress.ValueOverrides = mergeOverridesV1beta1(actualIngress.ValueOverrides, profileIngress.ValueOverrides)
   421  	}
   422  
   423  	actualIstio := actual.Spec.Components.Istio
   424  	profileIstio := profile.Spec.Components.Istio
   425  	if actualIstio != nil && profileIstio != nil {
   426  		actualIstio.ValueOverrides = mergeOverridesV1beta1(actualIstio.ValueOverrides, profileIstio.ValueOverrides)
   427  	}
   428  
   429  	actualJaegerOperator := actual.Spec.Components.JaegerOperator
   430  	profileJaegerOperator := profile.Spec.Components.JaegerOperator
   431  	if actualJaegerOperator != nil && profileJaegerOperator != nil {
   432  		actualJaegerOperator.ValueOverrides = mergeOverridesV1beta1(actualJaegerOperator.ValueOverrides, profileJaegerOperator.ValueOverrides)
   433  	}
   434  
   435  	actualKeycloak := actual.Spec.Components.Keycloak
   436  	profileKeycloak := profile.Spec.Components.Keycloak
   437  	if actualKeycloak != nil && profileKeycloak != nil {
   438  		actualKeycloak.ValueOverrides = mergeOverridesV1beta1(actualKeycloak.ValueOverrides, profileKeycloak.ValueOverrides)
   439  		actualKeycloak.MySQL.ValueOverrides = mergeOverridesV1beta1(actualKeycloak.MySQL.ValueOverrides, profileKeycloak.MySQL.ValueOverrides)
   440  	}
   441  
   442  	actualRancher := actual.Spec.Components.Rancher
   443  	profileRancher := profile.Spec.Components.Rancher
   444  	if actualRancher != nil && profileRancher != nil {
   445  		actualRancher.ValueOverrides = mergeOverridesV1beta1(actualRancher.ValueOverrides, profileRancher.ValueOverrides)
   446  	}
   447  
   448  	actualFluentd := actual.Spec.Components.Fluentd
   449  	profileFluentd := profile.Spec.Components.Fluentd
   450  	if actualFluentd != nil && profileFluentd != nil {
   451  		actualFluentd.ValueOverrides = mergeOverridesV1beta1(actualFluentd.ValueOverrides, profileFluentd.ValueOverrides)
   452  	}
   453  
   454  	actualWebLogicOperator := actual.Spec.Components.WebLogicOperator
   455  	profileWebLogicOperator := profile.Spec.Components.WebLogicOperator
   456  	if actualWebLogicOperator != nil && profileWebLogicOperator != nil {
   457  		actualWebLogicOperator.ValueOverrides = mergeOverridesV1beta1(actualWebLogicOperator.ValueOverrides, profileWebLogicOperator.ValueOverrides)
   458  	}
   459  
   460  	actualVelero := actual.Spec.Components.Velero
   461  	profileVelero := profile.Spec.Components.Velero
   462  	if actualVelero != nil && profileVelero != nil {
   463  		actualVelero.ValueOverrides = mergeOverridesV1beta1(actualVelero.ValueOverrides, profileVelero.ValueOverrides)
   464  	}
   465  }
   466  
   467  // mergeOverrides merges the various profiles overrides of v1beta1.Verrazzano into the actual overrides
   468  func mergeOverrides(actual, profile []v1alpha1.Overrides) []v1alpha1.Overrides {
   469  	return append(actual, profile...)
   470  }
   471  
   472  // mergeOverridesV1beta1 merges the various profiles overrides of v1beta1.Verrazzano into the actual overrides
   473  func mergeOverridesV1beta1(actual, profile []v1beta1.Overrides) []v1beta1.Overrides {
   474  	return append(actual, profile...)
   475  }