@@ -8,24 +8,27 @@ public class UpdateControl<P extends HasMetadata> extends BaseControl<UpdateCont
88 private final P resource ;
99 private final boolean updateStatus ;
1010 private final boolean updateResource ;
11- private final boolean patch ;
11+ private final boolean patchStatus ;
1212
1313 private UpdateControl (
14- P resource , boolean updateStatus , boolean updateResource , boolean patch ) {
14+ P resource , boolean updateStatus , boolean updateResource , boolean patchStatus ) {
1515 if ((updateResource || updateStatus ) && resource == null ) {
1616 throw new IllegalArgumentException ("CustomResource cannot be null in case of update" );
1717 }
1818 this .resource = resource ;
1919 this .updateStatus = updateStatus ;
2020 this .updateResource = updateResource ;
21- this .patch = patch ;
21+ this .patchStatus = patchStatus ;
2222 }
2323
2424 /**
2525 * Creates an update control instance that instructs the framework to do an update on resource
2626 * itself, not on the status. Note that usually as a results of a reconciliation should be a
2727 * status update not an update to the resource itself.
2828 *
29+ * Using this update makes sure that the resource in the next reconciliation is the updated one -
30+ * this is not guaranteed by default if you do an update on a resource by the Kubernetes client.
31+ *
2932 * @param <T> custom resource type
3033 * @param customResource customResource to use for update
3134 * @return initialized update control
@@ -73,6 +76,9 @@ public static <T extends HasMetadata> UpdateControl<T> updateStatus(T customReso
7376 * As a results of this there will be two call to K8S API. First the custom resource will be
7477 * updates then the status sub-resource.
7578 *
79+ * Using this update makes sure that the resource in the next reconciliation is the updated one -
80+ * this is not guaranteed by default if you do an update on a resource by the Kubernetes client.
81+ *
7682 * @param <T> resource type
7783 * @param customResource - custom resource to use in both API calls
7884 * @return UpdateControl instance
@@ -82,11 +88,36 @@ public static <T extends HasMetadata> UpdateControl<T> updateResourceAndStatus(
8288 return new UpdateControl <>(customResource , true , true , false );
8389 }
8490
85- public static <T extends HasMetadata > UpdateControl <T > patchResourceAndStatus (
91+ /**
92+ * Updates the resource - with optimistic locking - and patches the status without optimistic
93+ * locking in place.
94+ *
95+ * Note that using this method, it is not guaranteed that the most recent updated resource will be
96+ * in case for next reconciliation.
97+ *
98+ * @param customResource to update
99+ * @return UpdateControl instance
100+ * @param <T> resource type
101+ */
102+ public static <T extends HasMetadata > UpdateControl <T > updateResourceAndPatchStatus (
86103 T customResource ) {
87104 return new UpdateControl <>(customResource , true , true , true );
88105 }
89106
107+ /**
108+ * Marked for removal, because of confusing name. It does not patch the resource but rather
109+ * updates it.
110+ *
111+ * @deprecated use {@link UpdateControl#updateResourceAndPatchStatus(HasMetadata)}
112+ *
113+ * @param customResource to update
114+ * @return UpdateControl instance
115+ * @param <T> resource type
116+ */
117+ @ Deprecated (forRemoval = true )
118+ public static <T extends HasMetadata > UpdateControl <T > patchResourceAndStatus (T customResource ) {
119+ return updateResourceAndStatus (customResource );
120+ }
90121
91122 public static <T extends HasMetadata > UpdateControl <T > noUpdate () {
92123 return new UpdateControl <>(null , false , false , false );
@@ -104,8 +135,8 @@ public boolean isUpdateResource() {
104135 return updateResource ;
105136 }
106137
107- public boolean isPatch () {
108- return patch ;
138+ public boolean isPatchStatus () {
139+ return patchStatus ;
109140 }
110141
111142 public boolean isNoUpdate () {
@@ -115,4 +146,5 @@ public boolean isNoUpdate() {
115146 public boolean isUpdateResourceAndStatus () {
116147 return updateResource && updateStatus ;
117148 }
149+
118150}
0 commit comments