From 5751cf38c572d30981e6c50646e202d4158c32e3 Mon Sep 17 00:00:00 2001 From: Gabriel Saratura Date: Thu, 5 Dec 2024 13:11:40 +0100 Subject: [PATCH] Create AddOn API --- apis/vshn/v1/dbaas_vshn_keycloak.go | 4 ++ apis/vshn/v1/dbaas_vshn_mariadb.go | 4 ++ apis/vshn/v1/dbaas_vshn_postgresql.go | 4 ++ apis/vshn/v1/dbaas_vshn_redis.go | 4 ++ apis/vshn/v1/non_gen_types.go | 9 ++++ apis/vshn/v1/vshn_minio.go | 4 ++ apis/vshn/v1/vshn_nextcloud.go | 34 +++++++++++-- apis/vshn/v1/zz_generated.deepcopy.go | 48 ++++++++++++------- crds/vshn.appcat.vshn.io_vshnnextclouds.yaml | 33 ++++++++----- crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml | 43 ++++++++++------- .../functions/common/billing.go | 16 ++----- .../functions/common/billing_test.go | 20 ++++---- .../functions/common/interfaces.go | 1 + .../functions/vshnnextcloud/billing.go | 7 --- .../functions/vshnnextcloud/collabora.go | 10 ++-- .../functions/vshnnextcloud/collabora_test.go | 6 +-- pkg/controller/webhooks/nextcloud.go | 8 ++-- 17 files changed, 163 insertions(+), 92 deletions(-) diff --git a/apis/vshn/v1/dbaas_vshn_keycloak.go b/apis/vshn/v1/dbaas_vshn_keycloak.go index 0d072cc9d3..67f842debf 100644 --- a/apis/vshn/v1/dbaas_vshn_keycloak.go +++ b/apis/vshn/v1/dbaas_vshn_keycloak.go @@ -356,3 +356,7 @@ func (v *VSHNKeycloak) GetBillingName() string { func (v *VSHNKeycloak) GetSLA() string { return string(v.Spec.Parameters.Service.ServiceLevel) } + +func (v *VSHNKeycloak) GetEnabledAddOns() []AddOn { + return []AddOn{} +} diff --git a/apis/vshn/v1/dbaas_vshn_mariadb.go b/apis/vshn/v1/dbaas_vshn_mariadb.go index eaafa06539..eb4f256bbd 100644 --- a/apis/vshn/v1/dbaas_vshn_mariadb.go +++ b/apis/vshn/v1/dbaas_vshn_mariadb.go @@ -310,3 +310,7 @@ func (v *VSHNMariaDB) GetBillingName() string { func (v *VSHNMariaDB) GetSLA() string { return string(v.Spec.Parameters.Service.ServiceLevel) } + +func (v *VSHNMariaDB) GetEnabledAddOns() []AddOn { + return []AddOn{} +} diff --git a/apis/vshn/v1/dbaas_vshn_postgresql.go b/apis/vshn/v1/dbaas_vshn_postgresql.go index e573b87058..40b6dc74fd 100644 --- a/apis/vshn/v1/dbaas_vshn_postgresql.go +++ b/apis/vshn/v1/dbaas_vshn_postgresql.go @@ -434,3 +434,7 @@ func (v *VSHNPostgreSQL) GetBillingName() string { func (v *VSHNPostgreSQL) GetSLA() string { return string(v.Spec.Parameters.Service.ServiceLevel) } + +func (v *VSHNPostgreSQL) GetEnabledAddOns() []AddOn { + return []AddOn{} +} diff --git a/apis/vshn/v1/dbaas_vshn_redis.go b/apis/vshn/v1/dbaas_vshn_redis.go index 49b795e2ac..e833d93537 100644 --- a/apis/vshn/v1/dbaas_vshn_redis.go +++ b/apis/vshn/v1/dbaas_vshn_redis.go @@ -322,3 +322,7 @@ func (v *VSHNRedis) GetBillingName() string { func (v *VSHNRedis) GetSLA() string { return string(v.Spec.Parameters.Service.ServiceLevel) } + +func (v *VSHNRedis) GetEnabledAddOns() []AddOn { + return []AddOn{} +} diff --git a/apis/vshn/v1/non_gen_types.go b/apis/vshn/v1/non_gen_types.go index 0e8c00993e..ee6c579d05 100644 --- a/apis/vshn/v1/non_gen_types.go +++ b/apis/vshn/v1/non_gen_types.go @@ -16,6 +16,15 @@ type PodTemplateLabelsManager interface { client.Object } +// +kubebuilder:skip +// +kubebuilder:skipclient +// +kubebuilder:skipdeepcopy +// +kubebuilder:object:generate=false +type AddOn interface { + GetName() string + GetInstances() int +} + // +kubebuilder:skip // +kubebuilder:skipclient // +kubebuilder:skipdeepcopy diff --git a/apis/vshn/v1/vshn_minio.go b/apis/vshn/v1/vshn_minio.go index fd45a6861a..c9c5dc224f 100644 --- a/apis/vshn/v1/vshn_minio.go +++ b/apis/vshn/v1/vshn_minio.go @@ -274,3 +274,7 @@ func (v *VSHNMinio) GetBillingName() string { func (v *VSHNMinio) GetSLA() string { return string(BestEffort) } + +func (v *VSHNMinio) GetEnabledAddOns() []AddOn { + return []AddOn{} +} diff --git a/apis/vshn/v1/vshn_nextcloud.go b/apis/vshn/v1/vshn_nextcloud.go index 9c7d943695..acb4e8a5d1 100644 --- a/apis/vshn/v1/vshn_nextcloud.go +++ b/apis/vshn/v1/vshn_nextcloud.go @@ -79,6 +79,11 @@ type VSHNNextcloudParameters struct { // Security defines the security of a service Security Security `json:"security,omitempty"` + // VSHNNextcloudAddOns are additional components, modules, or extensions that enhances the functionality of VSHN Nextcloud. + // Add-ons are designed to provide optional features or capabilities that are not part of the main product but + // can be installed as needed. Usually add-on are billed separately. + AddOns VSHNNextcloudAddOns `json:"addOns,omitempty"` + // +kubebuilder:default=1 // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=3 @@ -90,8 +95,6 @@ type VSHNNextcloudParameters struct { // VSHNNextcloudServiceSpec contains nextcloud DBaaS specific properties type VSHNNextcloudServiceSpec struct { - // Collabora contains settings to control the Collabora integration. - Collabora CollaboraSpec `json:"collabora,omitempty"` // +kubebuilder:validation:Required // +kubebuilder:validation:MinItems=1 @@ -152,6 +155,22 @@ type VSHNNextcloudSizeSpec struct { Plan string `json:"plan,omitempty"` } +// VSHNNextcloudAddOns are additional components, modules, or extensions that enhances the functionality of VSHN Services. +// Add-ons are designed to provide optional features or capabilities that are not part of the main product but +// can be installed as needed. Usually add-on are billed separately. +type VSHNNextcloudAddOns struct { + // Office contains settings to control the Collabora integration. + Office OfficeSpec `json:"office,omitempty"` +} + +func (o OfficeSpec) GetName() string { + return "office" +} + +func (o OfficeSpec) GetInstances() int { + return 1 +} + // VSHNNextcloudStatus reflects the observed state of a VSHNNextcloud. type VSHNNextcloudStatus struct { // InstanceNamespace contains the name of the namespace where the instance resides @@ -181,8 +200,8 @@ func (v *VSHNNextcloud) SetInstanceNamespaceStatus() { v.Status.InstanceNamespace = v.GetInstanceNamespace() } -// CollaboraSpec defines the desired state of a Collabora instance. -type CollaboraSpec struct { +// OfficeSpec defines the desired state of a Collabora instance. +type OfficeSpec struct { // Enabled enables the Collabora integration. It will autoconfigure the Collabora server URL in Your Nextcloud instance. //+kubebuilder:default=false Enabled bool `json:"enabled"` @@ -342,3 +361,10 @@ func (v *VSHNNextcloud) GetBillingName() string { func (v *VSHNNextcloud) GetSLA() string { return string(v.Spec.Parameters.Service.ServiceLevel) } + +func (v *VSHNNextcloud) GetEnabledAddOns() []AddOn { + if v.Spec.Parameters.AddOns.Office.Enabled { + return []AddOn{v.Spec.Parameters.AddOns.Office} + } + return []AddOn{} +} diff --git a/apis/vshn/v1/zz_generated.deepcopy.go b/apis/vshn/v1/zz_generated.deepcopy.go index 72e61bf92f..da998f2cb1 100644 --- a/apis/vshn/v1/zz_generated.deepcopy.go +++ b/apis/vshn/v1/zz_generated.deepcopy.go @@ -11,21 +11,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CollaboraSpec) DeepCopyInto(out *CollaboraSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollaboraSpec. -func (in *CollaboraSpec) DeepCopy() *CollaboraSpec { - if in == nil { - return nil - } - out := new(CollaboraSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Condition) DeepCopyInto(out *Condition) { *out = *in @@ -103,6 +88,21 @@ func (in *LocalObjectReference) DeepCopy() *LocalObjectReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OfficeSpec) DeepCopyInto(out *OfficeSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OfficeSpec. +func (in *OfficeSpec) DeepCopy() *OfficeSpec { + if in == nil { + return nil + } + out := new(OfficeSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Security) DeepCopyInto(out *Security) { *out = *in @@ -841,6 +841,22 @@ func (in *VSHNNextcloud) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSHNNextcloudAddOns) DeepCopyInto(out *VSHNNextcloudAddOns) { + *out = *in + out.Office = in.Office +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNNextcloudAddOns. +func (in *VSHNNextcloudAddOns) DeepCopy() *VSHNNextcloudAddOns { + if in == nil { + return nil + } + out := new(VSHNNextcloudAddOns) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VSHNNextcloudList) DeepCopyInto(out *VSHNNextcloudList) { *out = *in @@ -884,6 +900,7 @@ func (in *VSHNNextcloudParameters) DeepCopyInto(out *VSHNNextcloudParameters) { out.Maintenance = in.Maintenance in.Monitoring.DeepCopyInto(&out.Monitoring) in.Security.DeepCopyInto(&out.Security) + out.AddOns = in.AddOns } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNNextcloudParameters. @@ -899,7 +916,6 @@ func (in *VSHNNextcloudParameters) DeepCopy() *VSHNNextcloudParameters { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VSHNNextcloudServiceSpec) DeepCopyInto(out *VSHNNextcloudServiceSpec) { *out = *in - out.Collabora = in.Collabora if in.FQDN != nil { in, out := &in.FQDN, &out.FQDN *out = make([]string, len(*in)) diff --git a/crds/vshn.appcat.vshn.io_vshnnextclouds.yaml b/crds/vshn.appcat.vshn.io_vshnnextclouds.yaml index 21a5df9390..d767d218b6 100644 --- a/crds/vshn.appcat.vshn.io_vshnnextclouds.yaml +++ b/crds/vshn.appcat.vshn.io_vshnnextclouds.yaml @@ -42,6 +42,26 @@ spec: parameters: description: Parameters are the configurable fields of a VSHNNextcloud. properties: + addOns: + description: |- + VSHNNextcloudAddOns are additional components, modules, or extensions that enhances the functionality of VSHN Nextcloud. + Add-ons are designed to provide optional features or capabilities that are not part of the main product but + can be installed as needed. Usually add-on are billed separately. + properties: + office: + description: Office contains settings to control the Collabora integration. + properties: + enabled: + default: false + description: Enabled enables the Collabora integration. It will autoconfigure the Collabora server URL in Your Nextcloud instance. + type: boolean + fqdn: + description: FQDN contains the FQDN of the Collabora server. This is used to configure the Collabora server URL in Your Nextcloud instance. + type: string + required: + - enabled + type: object + type: object backup: description: Backup contains settings to control how the instance should get backed up. properties: @@ -4851,19 +4871,6 @@ spec: service: description: Service contains nextcloud DBaaS specific properties properties: - collabora: - description: Collabora contains settings to control the Collabora integration. - properties: - enabled: - default: false - description: Enabled enables the Collabora integration. It will autoconfigure the Collabora server URL in Your Nextcloud instance. - type: boolean - fqdn: - description: FQDN contains the FQDN of the Collabora server. This is used to configure the Collabora server URL in Your Nextcloud instance. - type: string - required: - - enabled - type: object fqdn: description: |- FQDN contains the FQDNs array, which will be used for the ingress. diff --git a/crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml b/crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml index f279b3a498..49b9539776 100644 --- a/crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml +++ b/crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml @@ -83,6 +83,31 @@ spec: parameters: description: Parameters are the configurable fields of a VSHNNextcloud. properties: + addOns: + description: |- + VSHNNextcloudAddOns are additional components, modules, or extensions that enhances the functionality of VSHN Nextcloud. + Add-ons are designed to provide optional features or capabilities that are not part of the main product but + can be installed as needed. Usually add-on are billed separately. + properties: + office: + description: Office contains settings to control the Collabora + integration. + properties: + enabled: + default: false + description: Enabled enables the Collabora integration. + It will autoconfigure the Collabora server URL in Your + Nextcloud instance. + type: boolean + fqdn: + description: FQDN contains the FQDN of the Collabora server. + This is used to configure the Collabora server URL in + Your Nextcloud instance. + type: string + required: + - enabled + type: object + type: object backup: description: Backup contains settings to control how the instance should get backed up. @@ -5575,24 +5600,6 @@ spec: service: description: Service contains nextcloud DBaaS specific properties properties: - collabora: - description: Collabora contains settings to control the Collabora - integration. - properties: - enabled: - default: false - description: Enabled enables the Collabora integration. - It will autoconfigure the Collabora server URL in Your - Nextcloud instance. - type: boolean - fqdn: - description: FQDN contains the FQDN of the Collabora server. - This is used to configure the Collabora server URL in - Your Nextcloud instance. - type: string - required: - - enabled - type: object fqdn: description: |- FQDN contains the FQDNs array, which will be used for the ingress. diff --git a/pkg/comp-functions/functions/common/billing.go b/pkg/comp-functions/functions/common/billing.go index 5a76646340..4ee89ed0e4 100644 --- a/pkg/comp-functions/functions/common/billing.go +++ b/pkg/comp-functions/functions/common/billing.go @@ -11,16 +11,10 @@ import ( controllerruntime "sigs.k8s.io/controller-runtime" ) -// ServiceAddOns describes an addOn for a services with necessary data for billing -type ServiceAddOns struct { - Name string - Instances int -} - // CreateBillingRecord creates a new prometheus rule per each instance namespace // The rule is skipped for any secondary service such as postgresql instance for nextcloud // The skipping is based on whether label appuio.io/billing-name is set or not on instance namespace -func CreateBillingRecord(ctx context.Context, svc *runtime.ServiceRuntime, comp InfoGetter, addOns ...ServiceAddOns) *xfnproto.Result { +func CreateBillingRecord(ctx context.Context, svc *runtime.ServiceRuntime, comp InfoGetter) *xfnproto.Result { log := controllerruntime.LoggerFrom(ctx) log.Info("Enabling billing for service", "service", comp.GetName()) @@ -64,13 +58,13 @@ func CreateBillingRecord(ctx context.Context, svc *runtime.ServiceRuntime, comp }, } - for _, addOn := range addOns { - log.Info("Adding billing addOn for service", "service", comp.GetName(), "addOn", addOn.Name) - exprAddOn := getVectorExpression(addOn.Instances) + for _, addOn := range comp.GetEnabledAddOns() { + log.Info("Adding billing addOn for service", "service", comp.GetName(), "addOn", addOn.GetName()) + exprAddOn := getVectorExpression(addOn.GetInstances()) rg.Rules = append(rg.Rules, v1.Rule{ Record: "appcat:metering", Expr: intstr.FromString(exprAddOn), - Labels: getLabels(svc, comp, org, addOn.Name), + Labels: getLabels(svc, comp, org, addOn.GetName()), }) } diff --git a/pkg/comp-functions/functions/common/billing_test.go b/pkg/comp-functions/functions/common/billing_test.go index fee4a4e6d4..e7dd302052 100644 --- a/pkg/comp-functions/functions/common/billing_test.go +++ b/pkg/comp-functions/functions/common/billing_test.go @@ -22,7 +22,6 @@ func TestBilling(t *testing.T) { comp *v1.VSHNNextcloud svc *runtime.ServiceRuntime org string - addOns []ServiceAddOns expectedRuleGroup v2.RuleGroup }{ { @@ -40,17 +39,17 @@ func TestBilling(t *testing.T) { Parameters: v1.VSHNNextcloudParameters{ Instances: 1, Service: v1.VSHNNextcloudServiceSpec{ServiceLevel: v1.BestEffort}, + AddOns: v1.VSHNNextcloudAddOns{ + Office: v1.OfficeSpec{ + Enabled: true, + FQDN: "example.com", + }, + }, }, }, }, svc: commontest.LoadRuntimeFromFile(t, "common/billing.yaml"), org: "APPUiO", - addOns: []ServiceAddOns{ - { - Name: "office", - Instances: 1, - }, - }, expectedRuleGroup: v2.RuleGroup{ Name: "appcat-metering-rules", Rules: []v2.Rule{ @@ -105,9 +104,8 @@ func TestBilling(t *testing.T) { }, }, }, - svc: commontest.LoadRuntimeFromFile(t, "common/billing.yaml"), - org: "APPUiO", - addOns: []ServiceAddOns{}, + svc: commontest.LoadRuntimeFromFile(t, "common/billing.yaml"), + org: "APPUiO", expectedRuleGroup: v2.RuleGroup{ Name: "appcat-metering-rules", Rules: []v2.Rule{ @@ -132,7 +130,7 @@ func TestBilling(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - r := CreateBillingRecord(context.Background(), tt.svc, tt.comp, tt.addOns...) + r := CreateBillingRecord(context.Background(), tt.svc, tt.comp) assert.Equal(t, xfnproto.Severity_SEVERITY_NORMAL, r.Severity) actual := &v2.PrometheusRule{} err := tt.svc.GetDesiredKubeObject(actual, "nextcloud-gc9x4-billing") diff --git a/pkg/comp-functions/functions/common/interfaces.go b/pkg/comp-functions/functions/common/interfaces.go index cb38c6eaf9..01dbe974fd 100644 --- a/pkg/comp-functions/functions/common/interfaces.go +++ b/pkg/comp-functions/functions/common/interfaces.go @@ -23,6 +23,7 @@ type InfoGetter interface { GetClaimName() string GetSLA() string GetBillingName() string + GetEnabledAddOns() []vshnv1.AddOn } // InstanceNamespaceInfo provides all the necessary information to create diff --git a/pkg/comp-functions/functions/vshnnextcloud/billing.go b/pkg/comp-functions/functions/vshnnextcloud/billing.go index 537c6f8a30..a30a84f3d7 100644 --- a/pkg/comp-functions/functions/vshnnextcloud/billing.go +++ b/pkg/comp-functions/functions/vshnnextcloud/billing.go @@ -18,12 +18,5 @@ func AddBilling(ctx context.Context, comp *v1.VSHNNextcloud, svc *runtime.Servic return runtime.NewFatalResult(fmt.Errorf("can't get composite: %w", err)) } - if comp.Spec.Parameters.Service.Collabora.Enabled { - return common.CreateBillingRecord(ctx, svc, comp, common.ServiceAddOns{ - Name: "office", - Instances: 1, - }) - } - return common.CreateBillingRecord(ctx, svc, comp) } diff --git a/pkg/comp-functions/functions/vshnnextcloud/collabora.go b/pkg/comp-functions/functions/vshnnextcloud/collabora.go index 5fb059cef6..69893d335d 100644 --- a/pkg/comp-functions/functions/vshnnextcloud/collabora.go +++ b/pkg/comp-functions/functions/vshnnextcloud/collabora.go @@ -48,7 +48,7 @@ func DeployCollabora(ctx context.Context, comp *vshnv1.VSHNNextcloud, svc *runti return runtime.NewWarningResult("Cannot GetObservedComposite: " + err.Error()) } - if !comp.Spec.Parameters.Service.Collabora.Enabled { + if !comp.Spec.Parameters.AddOns.Office.Enabled { return runtime.NewNormalResult("Collabora not enabled") } @@ -344,7 +344,7 @@ func AddCollaboraIngress(comp *vshnv1.VSHNNextcloud, svc *runtime.ServiceRuntime Spec: networkingv1.IngressSpec{ Rules: []networkingv1.IngressRule{ { - Host: comp.Spec.Parameters.Service.Collabora.FQDN, + Host: comp.Spec.Parameters.AddOns.Office.FQDN, IngressRuleValue: networkingv1.IngressRuleValue{ HTTP: &networkingv1.HTTPIngressRuleValue{ Paths: []networkingv1.HTTPIngressPath{ @@ -367,7 +367,7 @@ func AddCollaboraIngress(comp *vshnv1.VSHNNextcloud, svc *runtime.ServiceRuntime }, TLS: []networkingv1.IngressTLS{ { - Hosts: []string{comp.Spec.Parameters.Service.Collabora.FQDN}, + Hosts: []string{comp.Spec.Parameters.AddOns.Office.FQDN}, SecretName: comp.GetName() + "-collabora-code-ingress-tls", }, }, @@ -401,7 +401,7 @@ func createCertificate(comp *vshnv1.VSHNNextcloud, svc *runtime.ServiceRuntime) }, Spec: cmv1.CertificateSpec{ SecretName: comp.GetName() + "-collabora-code-tls", - DNSNames: []string{comp.Spec.Parameters.Service.Collabora.FQDN}, + DNSNames: []string{comp.Spec.Parameters.AddOns.Office.FQDN}, IssuerRef: certmgrv1.ObjectReference{ Name: comp.GetName() + "-collabora-code-issuer", }, @@ -540,7 +540,7 @@ func createInstallCollaboraJob(comp *vshnv1.VSHNNextcloud, svc *runtime.ServiceR Command: []string{ "bash", "-cefx", - fmt.Sprintf("oc exec -i deployments/%s -- /install-collabora.sh \"%s\" \"%s\" \"%s\"", comp.GetWorkloadName(), svc.Config.Data["isOpenshift"], comp.GetName(), comp.Spec.Parameters.Service.Collabora.FQDN), + fmt.Sprintf("oc exec -i deployments/%s -- /install-collabora.sh \"%s\" \"%s\" \"%s\"", comp.GetWorkloadName(), svc.Config.Data["isOpenshift"], comp.GetName(), comp.Spec.Parameters.AddOns.Office.FQDN), }, }, }, diff --git a/pkg/comp-functions/functions/vshnnextcloud/collabora_test.go b/pkg/comp-functions/functions/vshnnextcloud/collabora_test.go index 5b4e87fc0f..f128256ca7 100644 --- a/pkg/comp-functions/functions/vshnnextcloud/collabora_test.go +++ b/pkg/comp-functions/functions/vshnnextcloud/collabora_test.go @@ -14,8 +14,8 @@ func Test_addCollabora(t *testing.T) { ctx := context.TODO() - comp.Spec.Parameters.Service.Collabora.Enabled = true - comp.Spec.Parameters.Service.Collabora.FQDN = "collabora.example.com" + comp.Spec.Parameters.AddOns.Office.Enabled = true + comp.Spec.Parameters.AddOns.Office.FQDN = "collabora.example.com" assert.Nil(t, DeployNextcloud(ctx, comp, svc)) @@ -52,7 +52,7 @@ func Test_addCollabora(t *testing.T) { assert.Equal(t, "1", resources[val]) } - comp.Spec.Parameters.Service.Collabora.Enabled = false + comp.Spec.Parameters.AddOns.Office.Enabled = false res = DeployCollabora(ctx, comp, svc) assert.True(t, res.Severity == v1beta1.Severity_SEVERITY_NORMAL && res.Message == "Collabora not enabled") diff --git a/pkg/controller/webhooks/nextcloud.go b/pkg/controller/webhooks/nextcloud.go index 8db99ab353..4570ef19c4 100644 --- a/pkg/controller/webhooks/nextcloud.go +++ b/pkg/controller/webhooks/nextcloud.go @@ -63,8 +63,8 @@ func (n *NextcloudWebhookHandler) ValidateCreate(ctx context.Context, obj runtim return nil, err } - if nx.Spec.Parameters.Service.Collabora.Enabled { - if err := validateFQDNs([]string{nx.Spec.Parameters.Service.Collabora.FQDN}); err != nil { + if nx.Spec.Parameters.AddOns.Office.Enabled { + if err := validateFQDNs([]string{nx.Spec.Parameters.AddOns.Office.FQDN}); err != nil { return nil, err } } @@ -87,8 +87,8 @@ func (n *NextcloudWebhookHandler) ValidateUpdate(ctx context.Context, oldObj, ne return nil, err } - if nx.Spec.Parameters.Service.Collabora.Enabled { - if err := validateFQDNs([]string{nx.Spec.Parameters.Service.Collabora.FQDN}); err != nil { + if nx.Spec.Parameters.AddOns.Office.Enabled { + if err := validateFQDNs([]string{nx.Spec.Parameters.AddOns.Office.FQDN}); err != nil { return nil, err } }