@@ -143,18 +143,16 @@ func (h *Helper) Patch(ctx context.Context, obj client.Object, opts ...Option) e
143
143
return errors .Wrapf (err , "failed to patch %s %s: failed to convert after object to Unstructured" , h .gvk .Kind , klog .KObj (h .beforeObject ))
144
144
}
145
145
146
- // Determine if the object has status.
147
- if unstructuredHasStatus (h .after ) {
148
- if options .IncludeStatusObservedGeneration {
149
- // Set status.observedGeneration if we're asked to do so.
150
- if err := unstructured .SetNestedField (h .after .Object , h .after .GetGeneration (), "status" , "observedGeneration" ); err != nil {
151
- return errors .Wrapf (err , "failed to patch %s %s: failed to set .status.observedGeneration" , h .gvk .Kind , klog .KObj (h .beforeObject ))
152
- }
146
+ // Include .status.observedGeneration if IncludeStatusObservedGeneration is set.
147
+ if options .IncludeStatusObservedGeneration {
148
+ // Set status.observedGeneration if we're asked to do so.
149
+ if err := unstructured .SetNestedField (h .after .Object , h .after .GetGeneration (), "status" , "observedGeneration" ); err != nil {
150
+ return errors .Wrapf (err , "failed to patch %s %s: failed to set .status.observedGeneration" , h .gvk .Kind , klog .KObj (h .beforeObject ))
151
+ }
153
152
154
- // Restore the changes back to the original object.
155
- if err := runtime .DefaultUnstructuredConverter .FromUnstructured (h .after .Object , obj ); err != nil {
156
- return errors .Wrapf (err , "failed to patch %s %s: failed to converted object from Unstructured" , h .gvk .Kind , klog .KObj (h .beforeObject ))
157
- }
153
+ // Restore the changes back to the original object.
154
+ if err := runtime .DefaultUnstructuredConverter .FromUnstructured (h .after .Object , obj ); err != nil {
155
+ return errors .Wrapf (err , "failed to patch %s %s: failed to converted object from Unstructured" , h .gvk .Kind , klog .KObj (h .beforeObject ))
158
156
}
159
157
}
160
158
0 commit comments