File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,12 @@ func (scope *machineReconcileScope) patchHardwareAnnotations(hw *tinkv1.Hardware
9696}
9797
9898func (scope * machineReconcileScope ) takeHardwareOwnership (hw * tinkv1.Hardware ) error {
99- if len (hw .Labels ) == 0 {
99+ patchHelper , err := patch .NewHelper (hw , scope .client )
100+ if err != nil {
101+ return fmt .Errorf ("initializing patch helper for selected hardware: %w" , err )
102+ }
103+
104+ if hw .Labels == nil {
100105 hw .Labels = map [string ]string {}
101106 }
102107
@@ -106,8 +111,8 @@ func (scope *machineReconcileScope) takeHardwareOwnership(hw *tinkv1.Hardware) e
106111 // Add finalizer to hardware as well to make sure we release it before Machine object is removed.
107112 controllerutil .AddFinalizer (hw , infrastructurev1 .MachineFinalizer )
108113
109- if err := scope . client . Update (scope .ctx , hw ); err != nil {
110- return fmt .Errorf ("updating Hardware object: %w" , err )
114+ if err := patchHelper . Patch (scope .ctx , hw ); err != nil {
115+ return fmt .Errorf ("patching Hardware object: %w" , err )
111116 }
112117
113118 return nil
You can’t perform that action at this time.
0 commit comments