@@ -9,32 +9,32 @@ public class UpdateControl<P extends HasMetadata> extends BaseControl<UpdateCont
9
9
private final boolean updateStatus ;
10
10
private final boolean updateResource ;
11
11
private final boolean patchStatus ;
12
- private final boolean patchResource ;
13
12
14
13
private UpdateControl (
15
- P resource , boolean updateStatus , boolean updateResource , boolean patchStatus ,
16
- boolean patchResource ) {
14
+ P resource , boolean updateStatus , boolean updateResource , boolean patchStatus ) {
17
15
if ((updateResource || updateStatus ) && resource == null ) {
18
16
throw new IllegalArgumentException ("CustomResource cannot be null in case of update" );
19
17
}
20
18
this .resource = resource ;
21
19
this .updateStatus = updateStatus ;
22
20
this .updateResource = updateResource ;
23
21
this .patchStatus = patchStatus ;
24
- this .patchResource = patchResource ;
25
22
}
26
23
27
24
/**
28
25
* Creates an update control instance that instructs the framework to do an update on resource
29
26
* itself, not on the status. Note that usually as a results of a reconciliation should be a
30
27
* status update not an update to the resource itself.
31
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
+ *
32
32
* @param <T> custom resource type
33
33
* @param customResource customResource to use for update
34
34
* @return initialized update control
35
35
*/
36
36
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 );
38
38
}
39
39
40
40
/**
@@ -53,7 +53,7 @@ public static <T extends HasMetadata> UpdateControl<T> updateResource(T customRe
53
53
* @return UpdateControl instance
54
54
*/
55
55
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 );
57
57
}
58
58
59
59
/**
@@ -69,7 +69,7 @@ public static <T extends HasMetadata> UpdateControl<T> patchStatus(T customResou
69
69
* @return UpdateControl instance
70
70
*/
71
71
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 );
73
73
}
74
74
75
75
/**
@@ -82,22 +82,37 @@ public static <T extends HasMetadata> UpdateControl<T> updateStatus(T customReso
82
82
*/
83
83
public static <T extends HasMetadata > UpdateControl <T > updateResourceAndStatus (
84
84
T customResource ) {
85
- return new UpdateControl <>(customResource , true , true , false , false );
85
+ return new UpdateControl <>(customResource , true , true , false );
86
86
}
87
87
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
+ */
88
96
public static <T extends HasMetadata > UpdateControl <T > updateResourceAndPatchStatus (
89
97
T customResource ) {
90
- return new UpdateControl <>(customResource , true , true , true , false );
98
+ return new UpdateControl <>(customResource , true , true , true );
91
99
}
92
100
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 );
96
112
}
97
113
98
-
99
114
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 );
101
116
}
102
117
103
118
public P getResource () {
@@ -116,15 +131,12 @@ public boolean isPatchStatus() {
116
131
return patchStatus ;
117
132
}
118
133
119
- public boolean isPatchResource () {
120
- return patchResource ;
121
- }
122
-
123
134
public boolean isNoUpdate () {
124
135
return !updateResource && !updateStatus ;
125
136
}
126
137
127
138
public boolean isUpdateResourceAndStatus () {
128
139
return updateResource && updateStatus ;
129
140
}
141
+
130
142
}
0 commit comments