@@ -8,24 +8,27 @@ public class UpdateControl<P extends HasMetadata> extends BaseControl<UpdateCont
8
8
private final P resource ;
9
9
private final boolean updateStatus ;
10
10
private final boolean updateResource ;
11
- private final boolean patch ;
11
+ private final boolean patchStatus ;
12
12
13
13
private UpdateControl (
14
- P resource , boolean updateStatus , boolean updateResource , boolean patch ) {
14
+ P resource , boolean updateStatus , boolean updateResource , boolean patchStatus ) {
15
15
if ((updateResource || updateStatus ) && resource == null ) {
16
16
throw new IllegalArgumentException ("CustomResource cannot be null in case of update" );
17
17
}
18
18
this .resource = resource ;
19
19
this .updateStatus = updateStatus ;
20
20
this .updateResource = updateResource ;
21
- this .patch = patch ;
21
+ this .patchStatus = patchStatus ;
22
22
}
23
23
24
24
/**
25
25
* Creates an update control instance that instructs the framework to do an update on resource
26
26
* itself, not on the status. Note that usually as a results of a reconciliation should be a
27
27
* status update not an update to the resource itself.
28
28
*
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
+ *
29
32
* @param <T> custom resource type
30
33
* @param customResource customResource to use for update
31
34
* @return initialized update control
@@ -73,6 +76,9 @@ public static <T extends HasMetadata> UpdateControl<T> updateStatus(T customReso
73
76
* As a results of this there will be two call to K8S API. First the custom resource will be
74
77
* updates then the status sub-resource.
75
78
*
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
+ *
76
82
* @param <T> resource type
77
83
* @param customResource - custom resource to use in both API calls
78
84
* @return UpdateControl instance
@@ -82,11 +88,36 @@ public static <T extends HasMetadata> UpdateControl<T> updateResourceAndStatus(
82
88
return new UpdateControl <>(customResource , true , true , false );
83
89
}
84
90
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 (
86
103
T customResource ) {
87
104
return new UpdateControl <>(customResource , true , true , true );
88
105
}
89
106
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
+ }
90
121
91
122
public static <T extends HasMetadata > UpdateControl <T > noUpdate () {
92
123
return new UpdateControl <>(null , false , false , false );
@@ -104,8 +135,8 @@ public boolean isUpdateResource() {
104
135
return updateResource ;
105
136
}
106
137
107
- public boolean isPatch () {
108
- return patch ;
138
+ public boolean isPatchStatus () {
139
+ return patchStatus ;
109
140
}
110
141
111
142
public boolean isNoUpdate () {
@@ -115,4 +146,5 @@ public boolean isNoUpdate() {
115
146
public boolean isUpdateResourceAndStatus () {
116
147
return updateResource && updateStatus ;
117
148
}
149
+
118
150
}
0 commit comments