@@ -9,32 +9,32 @@ public class UpdateControl<P extends HasMetadata> extends BaseControl<UpdateCont
99 private final boolean updateStatus ;
1010 private final boolean updateResource ;
1111 private final boolean patchStatus ;
12- private final boolean patchResource ;
1312
1413 private UpdateControl (
15- P resource , boolean updateStatus , boolean updateResource , boolean patchStatus ,
16- boolean patchResource ) {
14+ P resource , boolean updateStatus , boolean updateResource , boolean patchStatus ) {
1715 if ((updateResource || updateStatus ) && resource == null ) {
1816 throw new IllegalArgumentException ("CustomResource cannot be null in case of update" );
1917 }
2018 this .resource = resource ;
2119 this .updateStatus = updateStatus ;
2220 this .updateResource = updateResource ;
2321 this .patchStatus = patchStatus ;
24- this .patchResource = patchResource ;
2522 }
2623
2724 /**
2825 * Creates an update control instance that instructs the framework to do an update on resource
2926 * itself, not on the status. Note that usually as a results of a reconciliation should be a
3027 * status update not an update to the resource itself.
3128 *
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+ *
3232 * @param <T> custom resource type
3333 * @param customResource customResource to use for update
3434 * @return initialized update control
3535 */
3636 public static <T extends HasMetadata > UpdateControl <T > updateResource (T customResource ) {
37- return new UpdateControl <>(customResource , false , true , false , false );
37+ return new UpdateControl <>(customResource , false , true , false );
3838 }
3939
4040 /**
@@ -53,7 +53,7 @@ public static <T extends HasMetadata> UpdateControl<T> updateResource(T customRe
5353 * @return UpdateControl instance
5454 */
5555 public static <T extends HasMetadata > UpdateControl <T > patchStatus (T customResource ) {
56- return new UpdateControl <>(customResource , true , false , true , false );
56+ return new UpdateControl <>(customResource , true , false , true );
5757 }
5858
5959 /**
@@ -69,7 +69,7 @@ public static <T extends HasMetadata> UpdateControl<T> patchStatus(T customResou
6969 * @return UpdateControl instance
7070 */
7171 public static <T extends HasMetadata > UpdateControl <T > updateStatus (T customResource ) {
72- return new UpdateControl <>(customResource , true , false , false , false );
72+ return new UpdateControl <>(customResource , true , false , false );
7373 }
7474
7575 /**
@@ -82,22 +82,37 @@ public static <T extends HasMetadata> UpdateControl<T> updateStatus(T customReso
8282 */
8383 public static <T extends HasMetadata > UpdateControl <T > updateResourceAndStatus (
8484 T customResource ) {
85- return new UpdateControl <>(customResource , true , true , false , false );
85+ return new UpdateControl <>(customResource , true , true , false );
8686 }
8787
88+ /**
89+ * Updates the resource - with optimistic locking - and patched the status without optimistic
90+ * locking in place.
91+ *
92+ * @param customResource
93+ * @return
94+ * @param <T>
95+ */
8896 public static <T extends HasMetadata > UpdateControl <T > updateResourceAndPatchStatus (
8997 T customResource ) {
90- return new UpdateControl <>(customResource , true , true , true , false );
98+ return new UpdateControl <>(customResource , true , true , true );
9199 }
92100
93- public static <T extends HasMetadata > UpdateControl <T > patchResourceAndStatus (
94- T customResource ) {
95- return new UpdateControl <>(customResource , true , true , true , false );
101+ /**
102+ * Market for removal, because of confusing name. It does not patch the resource just updates it.
103+ * This method is same as updateResourceAndPatchStatus.
104+ *
105+ * @param customResource to update
106+ * @return UpdateControl instance
107+ * @param <T> resource type
108+ */
109+ @ Deprecated (forRemoval = true )
110+ public static <T extends HasMetadata > UpdateControl <T > patchResourceAndStatus (T customResource ) {
111+ return updateResourceAndStatus (customResource );
96112 }
97113
98-
99114 public static <T extends HasMetadata > UpdateControl <T > noUpdate () {
100- return new UpdateControl <>(null , false , false , false , false );
115+ return new UpdateControl <>(null , false , false , false );
101116 }
102117
103118 public P getResource () {
@@ -116,15 +131,12 @@ public boolean isPatchStatus() {
116131 return patchStatus ;
117132 }
118133
119- public boolean isPatchResource () {
120- return patchResource ;
121- }
122-
123134 public boolean isNoUpdate () {
124135 return !updateResource && !updateStatus ;
125136 }
126137
127138 public boolean isUpdateResourceAndStatus () {
128139 return updateResource && updateStatus ;
129140 }
141+
130142}
0 commit comments