@@ -69,21 +69,28 @@ func NewManagedMachinePoolScope(ctx context.Context, params ManagedMachinePoolSc
6969 return nil , errors .Wrap (err , "failed to init patch helper" )
7070 }
7171
72+ capiMachinePoolPatchHelper , err := patch .NewHelper (params .MachinePool , params .Client )
73+ if err != nil {
74+ return nil , errors .Wrap (err , "failed to init patch helper" )
75+ }
76+
7277 return & ManagedMachinePoolScope {
73- Client : params .Client ,
74- Cluster : params .Cluster ,
75- ControlPlane : params .ControlPlane ,
76- MachinePool : params .MachinePool ,
77- InfraMachinePool : params .InfraMachinePool ,
78- patchHelper : helper ,
79- ManagedClusterScoper : params .ManagedControlPlaneScope ,
78+ Client : params .Client ,
79+ Cluster : params .Cluster ,
80+ ControlPlane : params .ControlPlane ,
81+ MachinePool : params .MachinePool ,
82+ InfraMachinePool : params .InfraMachinePool ,
83+ patchHelper : helper ,
84+ capiMachinePoolPatchHelper : capiMachinePoolPatchHelper ,
85+ ManagedClusterScoper : params .ManagedControlPlaneScope ,
8086 }, nil
8187}
8288
8389// ManagedMachinePoolScope defines the basic context for an actuator to operate upon.
8490type ManagedMachinePoolScope struct {
85- Client client.Client
86- patchHelper * patch.Helper
91+ Client client.Client
92+ patchHelper * patch.Helper
93+ capiMachinePoolPatchHelper * patch.Helper
8794
8895 azure.ManagedClusterScoper
8996 Cluster * clusterv1.Cluster
@@ -231,7 +238,7 @@ func (s *ManagedMachinePoolScope) UpdateDeleteStatus(condition clusterv1.Conditi
231238 }
232239}
233240
234- // UpdatePutStatus updates a condition on the AzureManagedControlPlane status after a PUT operation.
241+ // UpdatePutStatus updates a condition on the AzureManagedMachinePool status after a PUT operation.
235242func (s * ManagedMachinePoolScope ) UpdatePutStatus (condition clusterv1.ConditionType , service string , err error ) {
236243 switch {
237244 case err == nil :
@@ -243,7 +250,7 @@ func (s *ManagedMachinePoolScope) UpdatePutStatus(condition clusterv1.ConditionT
243250 }
244251}
245252
246- // UpdatePatchStatus updates a condition on the AzureManagedControlPlane status after a PATCH operation.
253+ // UpdatePatchStatus updates a condition on the AzureManagedMachinePool status after a PATCH operation.
247254func (s * ManagedMachinePoolScope ) UpdatePatchStatus (condition clusterv1.ConditionType , service string , err error ) {
248255 switch {
249256 case err == nil :
@@ -254,3 +261,32 @@ func (s *ManagedMachinePoolScope) UpdatePatchStatus(condition clusterv1.Conditio
254261 conditions .MarkFalse (s .InfraMachinePool , condition , infrav1 .FailedReason , clusterv1 .ConditionSeverityError , "%s failed to update. err: %s" , service , err .Error ())
255262 }
256263}
264+
265+ // PatchCAPIMachinePoolObject persists the capi machinepool configuration and status.
266+ func (s * ManagedMachinePoolScope ) PatchCAPIMachinePoolObject (ctx context.Context ) error {
267+ return s .capiMachinePoolPatchHelper .Patch (
268+ ctx ,
269+ s .MachinePool ,
270+ )
271+ }
272+
273+ // UpdateCAPIMachinePoolReplicas updates the associated MachinePool replica count.
274+ func (s * ManagedMachinePoolScope ) UpdateCAPIMachinePoolReplicas (replicas * int32 ) {
275+ s .MachinePool .Spec .Replicas = replicas
276+ }
277+
278+ // UpdateCAPIMachinePoolAnnotations updates the associated MachinePool annotation.
279+ func (s * ManagedMachinePoolScope ) UpdateCAPIMachinePoolAnnotations (key , value string ) {
280+ s .MachinePool .Annotations [key ] = value
281+ }
282+
283+ // RemoveCAPIMachinePoolAnnotations removes the associated MachinePool annotation.
284+ func (s * ManagedMachinePoolScope ) RemoveCAPIMachinePoolAnnotations (key string ) {
285+ delete (s .MachinePool .Annotations , key )
286+ }
287+
288+ // GetCAPIMachinePoolAnnotations gets the associated MachinePool annotation.
289+ func (s * ManagedMachinePoolScope ) GetCAPIMachinePoolAnnotation (key string ) (bool , string ) {
290+ value , ok := s .MachinePool .Annotations [key ]
291+ return ok , value
292+ }
0 commit comments