/
module_integration.go
63 lines (52 loc) · 2.57 KB
/
module_integration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2023, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
package nginx
import (
"github.com/verrazzano/verrazzano-modules/pkg/controller/spi/controllerspi"
"github.com/verrazzano/verrazzano/platform-operator/apis/verrazzano/v1alpha1"
"github.com/verrazzano/verrazzano/platform-operator/controllers/verrazzano/component/common"
"github.com/verrazzano/verrazzano/platform-operator/controllers/verrazzano/component/common/watch"
"github.com/verrazzano/verrazzano/platform-operator/controllers/verrazzano/component/fluentoperator"
"github.com/verrazzano/verrazzano/platform-operator/controllers/verrazzano/component/spi"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"reflect"
)
// valuesConfig Structure for the translated effective Verrazzano CR values to Module CR Helm values
type valuesConfig struct {
Ingress *v1alpha1.IngressNginxComponent `json:"ingress,omitempty"`
DNS *v1alpha1.DNSComponent `json:"dns,omitempty"`
EnvironmentName string `json:"environmentName,omitempty"`
}
var emptyConfig = valuesConfig{}
// GetModuleConfigAsHelmValues returns an unstructured JSON valuesConfig representing the portion of the Verrazzano CR that corresponds to the module
func (c nginxComponent) GetModuleConfigAsHelmValues(effectiveCR *v1alpha1.Verrazzano) (*apiextensionsv1.JSON, error) {
if effectiveCR == nil {
return nil, nil
}
configSnippet := valuesConfig{}
dns := effectiveCR.Spec.Components.DNS
if dns != nil {
configSnippet.DNS = &v1alpha1.DNSComponent{
External: dns.External,
InstallOverrides: v1alpha1.InstallOverrides{}, // always ignore the overrides here, those are handled separately
OCI: dns.OCI,
Wildcard: dns.Wildcard,
}
}
nginx := effectiveCR.Spec.Components.Ingress
if nginx != nil {
configSnippet.Ingress = nginx.DeepCopy()
configSnippet.Ingress.InstallOverrides.ValueOverrides = []v1alpha1.Overrides{}
}
if len(effectiveCR.Spec.EnvironmentName) > 0 {
configSnippet.EnvironmentName = effectiveCR.Spec.EnvironmentName
}
if reflect.DeepEqual(emptyConfig, configSnippet) {
return nil, nil
}
return spi.NewModuleConfigHelmValuesWrapper(configSnippet)
}
// GetWatchDescriptors returns the list of WatchDescriptors for objects being watched by the component
func (c nginxComponent) GetWatchDescriptors() []controllerspi.WatchDescriptor {
return watch.GetModuleInstalledWatches([]string{common.IstioComponentName, fluentoperator.ComponentName})
}