@@ -25,6 +25,7 @@ package v1beta1
2525import (
2626 "fmt"
2727
28+ rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
2829 topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2930 "github.com/openstack-k8s-operators/lib-common/modules/common/service"
3031 "github.com/openstack-k8s-operators/lib-common/modules/common/util"
@@ -101,6 +102,20 @@ func (spec *ManilaSpec) Default() {
101102
102103// Default - set defaults for this Manila spec base
103104func (spec * ManilaSpecBase ) Default () {
105+ // Default MessagingBus with cluster name from RabbitMqClusterName
106+ rabbitmqv1 .DefaultRabbitMqConfig (& spec .MessagingBus , spec .RabbitMqClusterName )
107+
108+ // Default NotificationsBus if NotificationsBusInstance is specified
109+ if spec .NotificationsBusInstance != nil && * spec .NotificationsBusInstance != "" {
110+ if spec .NotificationsBus == nil {
111+ // Initialize NotificationsBus with MessagingBus values to inherit user/vhost
112+ spec .NotificationsBus = & rabbitmqv1.RabbitMqConfig {
113+ User : spec .MessagingBus .User ,
114+ Vhost : spec .MessagingBus .Vhost ,
115+ }
116+ }
117+ rabbitmqv1 .DefaultRabbitMqConfig (spec .NotificationsBus , * spec .NotificationsBusInstance )
118+ }
104119
105120 if spec .APITimeout == 0 {
106121 spec .APITimeout = manilaDefaults .APITimeout
@@ -200,6 +215,21 @@ func (r *Manila) ValidateUpdate(old runtime.Object) (admission.Warnings, error)
200215func (spec * ManilaSpec ) ValidateUpdate (old ManilaSpec , basePath * field.Path , namespace string ) field.ErrorList {
201216 var allErrs field.ErrorList
202217
218+ // Reject changes to deprecated RabbitMqClusterName field - users should use the new messagingBus.cluster field instead
219+ if spec .RabbitMqClusterName != old .RabbitMqClusterName {
220+ allErrs = append (allErrs , field .Forbidden (
221+ basePath .Child ("rabbitMqClusterName" ),
222+ "rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead" ))
223+ }
224+
225+ // Reject changes to deprecated NotificationsBusInstance field
226+ if spec .NotificationsBusInstance != nil && old .NotificationsBusInstance != nil &&
227+ * spec .NotificationsBusInstance != * old .NotificationsBusInstance {
228+ allErrs = append (allErrs , field .Forbidden (
229+ basePath .Child ("notificationsBusInstance" ),
230+ "notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead" ))
231+ }
232+
203233 // validate the service base parameters
204234 allErrs = append (allErrs , spec .ValidateBaseParams (basePath )... )
205235
@@ -217,6 +247,21 @@ func (spec *ManilaSpec) ValidateUpdate(old ManilaSpec, basePath *field.Path, nam
217247func (spec * ManilaSpecCore ) ValidateUpdate (old ManilaSpecCore , basePath * field.Path , namespace string ) field.ErrorList {
218248 var allErrs field.ErrorList
219249
250+ // Reject changes to deprecated RabbitMqClusterName field - users should use the new messagingBus.cluster field instead
251+ if spec .RabbitMqClusterName != old .RabbitMqClusterName {
252+ allErrs = append (allErrs , field .Forbidden (
253+ basePath .Child ("rabbitMqClusterName" ),
254+ "rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead" ))
255+ }
256+
257+ // Reject changes to deprecated NotificationsBusInstance field
258+ if spec .NotificationsBusInstance != nil && old .NotificationsBusInstance != nil &&
259+ * spec .NotificationsBusInstance != * old .NotificationsBusInstance {
260+ allErrs = append (allErrs , field .Forbidden (
261+ basePath .Child ("notificationsBusInstance" ),
262+ "notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead" ))
263+ }
264+
220265 // validate the service base parameters
221266 allErrs = append (allErrs , spec .ValidateBaseParams (basePath )... )
222267
0 commit comments