@@ -43,7 +43,7 @@ import (
43
43
)
44
44
45
45
// ResourceMutatorFunc holds the type for mutators to be applied on resources during a move operation.
46
- type ResourceMutatorFunc func (u * unstructured.Unstructured )
46
+ type ResourceMutatorFunc func (u * unstructured.Unstructured ) error
47
47
48
48
// ObjectMover defines methods for moving Cluster API objects to another management cluster.
49
49
type ObjectMover interface {
@@ -606,7 +606,10 @@ func patchCluster(proxy Proxy, n *node, patch client.Patch, mutators ...Resource
606
606
clusterObj .SetName (n .identity .Name )
607
607
clusterObj .SetNamespace (n .identity .Namespace )
608
608
for _ , mutator := range mutators {
609
- mutator (clusterObj )
609
+ if err = mutator (clusterObj ); err != nil {
610
+ return errors .Wrapf (err , "error applying resource mutator to %q %s/%s" ,
611
+ clusterObj .GroupVersionKind (), clusterObj .GetNamespace (), clusterObj .GetName ())
612
+ }
610
613
}
611
614
612
615
if err := cFrom .Get (ctx , client .ObjectKeyFromObject (clusterObj ), clusterObj ); err != nil {
@@ -635,7 +638,10 @@ func pauseClusterClass(proxy Proxy, n *node, pause bool, mutators ...ResourceMut
635
638
clusterClass .SetName (n .identity .Name )
636
639
clusterClass .SetNamespace (n .identity .Namespace )
637
640
for _ , mutator := range mutators {
638
- mutator (clusterClass )
641
+ if err = mutator (clusterClass ); err != nil {
642
+ return errors .Wrapf (err , "error applying resource mutator to %q %s/%s" ,
643
+ clusterClass .GroupVersionKind (), clusterClass .GetNamespace (), clusterClass .GetName ())
644
+ }
639
645
}
640
646
if err := cFrom .Get (ctx , client .ObjectKeyFromObject (clusterClass ), clusterClass ); err != nil {
641
647
return errors .Wrapf (err , "error reading ClusterClass %s/%s" , n .identity .Namespace , n .identity .Name )
@@ -887,7 +893,10 @@ func (o *objectMover) createTargetObject(nodeToCreate *node, toProxy Proxy, muta
887
893
}
888
894
889
895
for _ , mutator := range mutators {
890
- mutator (obj )
896
+ if err = mutator (obj ); err != nil {
897
+ return errors .Wrapf (err , "error applying resource mutator to %q %s/%s" ,
898
+ obj .GroupVersionKind (), obj .GetNamespace (), obj .GetName ())
899
+ }
891
900
}
892
901
// Applying mutators MAY change the namespace, so ensure the namespace exists before creating the resource.
893
902
if ! nodeToCreate .isGlobal && ! existingNamespaces .Has (obj .GetNamespace ()) {
0 commit comments