Skip to content

Commit

Permalink
fixup! ASOAPI: add resource mutator framework
Browse files Browse the repository at this point in the history
  • Loading branch information
nojnhuh committed May 1, 2024
1 parent bbc4d0c commit 09c01b7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions exp/controllers/azureasomanagedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context,
return ctrl.Result{Requeue: true}, nil
}

resources, err := mutators.ApplyMutators(ctx, asoManagedCluster.Spec.Resources)
resources, err := mutators.ToUnstructured(ctx, asoManagedCluster.Spec.Resources)
if err != nil {
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -279,7 +279,7 @@ func (r *AzureASOManagedClusterReconciler) reconcileDelete(ctx context.Context,
defer done()
log.V(4).Info("reconciling delete")

resources, err := mutators.ApplyMutators(ctx, asoManagedCluster.Spec.Resources)
resources, err := mutators.ToUnstructured(ctx, asoManagedCluster.Spec.Resources)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion exp/controllers/azureasomanagedcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileDelete(ctx context.Cont
defer done()
log.V(4).Info("reconciling delete")

resources, err := mutators.ApplyMutators(ctx, asoManagedControlPlane.Spec.Resources)
resources, err := mutators.ToUnstructured(ctx, asoManagedControlPlane.Spec.Resources)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion exp/controllers/azureasomanagedmachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (r *AzureASOManagedMachinePoolReconciler) reconcileDelete(ctx context.Conte
// If the entire cluster is being deleted, this ASO ManagedClustersAgentPool will be deleted with the rest
// of the ManagedCluster.
if cluster.DeletionTimestamp.IsZero() {
resources, err := mutators.ApplyMutators(ctx, asoManagedMachinePool.Spec.Resources)
resources, err := mutators.ToUnstructured(ctx, asoManagedMachinePool.Spec.Resources)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
5 changes: 5 additions & 0 deletions exp/mutators/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ func ApplyMutators(ctx context.Context, resources []runtime.RawExtension, mutato
}
return us, nil
}

// ToUnstructured converts the given resources to Unstructured.
func ToUnstructured(ctx context.Context, resources []runtime.RawExtension) ([]*unstructured.Unstructured, error) {
return ApplyMutators(ctx, resources)

Check warning on line 80 in exp/mutators/mutator.go

View check run for this annotation

Codecov / codecov/patch

exp/mutators/mutator.go#L79-L80

Added lines #L79 - L80 were not covered by tests
}

0 comments on commit 09c01b7

Please sign in to comment.