diff --git a/apis/core/v1beta1/openstackcontrolplane_webhook.go b/apis/core/v1beta1/openstackcontrolplane_webhook.go index baa468ce..0f885815 100644 --- a/apis/core/v1beta1/openstackcontrolplane_webhook.go +++ b/apis/core/v1beta1/openstackcontrolplane_webhook.go @@ -232,6 +232,18 @@ func (r *OpenStackControlPlane) DefaultServices() { // Ironic if r.Spec.Ironic.Enabled { + // Default Secret + if r.Spec.Ironic.Template.Secret == "" { + r.Spec.Ironic.Template.Secret = r.Spec.Secret + } + // Default DatabaseInstance + if r.Spec.Ironic.Template.DatabaseInstance == "" { + r.Spec.Ironic.Template.DatabaseInstance = "openstack" + } + // Default StorageClass + if r.Spec.Ironic.Template.StorageClass == "" { + r.Spec.Ironic.Template.StorageClass = r.Spec.StorageClass + } r.Spec.Ironic.Template.Default() } diff --git a/pkg/openstack/ironic.go b/pkg/openstack/ironic.go index b4db47db..d207ccb5 100644 --- a/pkg/openstack/ironic.go +++ b/pkg/openstack/ironic.go @@ -35,15 +35,6 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl helper.GetLogger().Info("Reconciling Ironic", "Ironic.Namespace", instance.Namespace, "Ironic.Name", "ironic") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), ironic, func() error { instance.Spec.Ironic.Template.DeepCopyInto(&ironic.Spec) - if ironic.Spec.Secret == "" { - ironic.Spec.Secret = instance.Spec.Secret - } - if ironic.Spec.DatabaseInstance == "" { - ironic.Spec.DatabaseInstance = "openstack" - } - if ironic.Spec.StorageClass == "" { - ironic.Spec.StorageClass = instance.Spec.StorageClass - } err := controllerutil.SetControllerReference(helper.GetBeforeObject(), ironic, helper.GetScheme()) if err != nil { return err