Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#308 from hjensas/ironic-de…
Browse files Browse the repository at this point in the history
…faulting

Move ironic template defaulting to the webhook
  • Loading branch information
openshift-merge-robot authored May 15, 2023
2 parents 4ebfb36 + f40baf2 commit 8aff954
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 12 additions & 0 deletions apis/core/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
9 changes: 0 additions & 9 deletions pkg/openstack/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8aff954

Please sign in to comment.