|
24 | 24 | import oracle.kubernetes.operator.work.Step;
|
25 | 25 | import oracle.kubernetes.weblogic.domain.v2.Domain;
|
26 | 26 | import oracle.kubernetes.weblogic.domain.v2.ServerSpec;
|
27 |
| -import org.apache.commons.collections.MapUtils; |
28 | 27 | import org.apache.commons.lang3.builder.EqualsBuilder;
|
29 | 28 |
|
30 | 29 | @SuppressWarnings("deprecation")
|
@@ -281,23 +280,19 @@ private static boolean isCurrentPodValid(V1Pod build, V1Pod current) {
|
281 | 280 | private static boolean isCurrentPodMetadataValid(V1ObjectMeta build, V1ObjectMeta current) {
|
282 | 281 | return VersionHelper.matchesResourceVersion(current, DEFAULT_DOMAIN_VERSION)
|
283 | 282 | && isRestartVersionValid(build, current)
|
284 |
| - && mapEquals(getCustomerLabels(current), getCustomerLabels(build)) |
285 |
| - && mapEquals(current.getAnnotations(), build.getAnnotations()); |
| 283 | + && KubernetesUtils.areLabelsValid(build, current) |
| 284 | + && KubernetesUtils.areAnnotationsValid(build, current); |
286 | 285 | }
|
287 | 286 |
|
288 | 287 | private static boolean isCurrentPodSpecValid(
|
289 | 288 | V1PodSpec build, V1PodSpec current, List<String> ignoring) {
|
290 | 289 | return Objects.equals(current.getSecurityContext(), build.getSecurityContext())
|
291 |
| - && mapEquals(current.getNodeSelector(), build.getNodeSelector()) |
| 290 | + && KubernetesUtils.mapEquals(current.getNodeSelector(), build.getNodeSelector()) |
292 | 291 | && equalSets(volumesWithout(current.getVolumes(), ignoring), build.getVolumes())
|
293 | 292 | && equalSets(current.getImagePullSecrets(), build.getImagePullSecrets())
|
294 | 293 | && areCompatible(build.getContainers(), current.getContainers(), ignoring);
|
295 | 294 | }
|
296 | 295 |
|
297 |
| - private static <K, V> boolean mapEquals(Map<K, V> first, Map<K, V> second) { |
298 |
| - return Objects.equals(first, second) || (MapUtils.isEmpty(first) && MapUtils.isEmpty(second)); |
299 |
| - } |
300 |
| - |
301 | 296 | private static boolean areCompatible(
|
302 | 297 | List<V1Container> build, List<V1Container> current, List<String> ignoring) {
|
303 | 298 | if (build != null) {
|
@@ -343,7 +338,8 @@ private static boolean equalSettings(V1Probe probe1, V1Probe probe2) {
|
343 | 338 | }
|
344 | 339 |
|
345 | 340 | private static boolean resourcesEqual(V1ResourceRequirements a, V1ResourceRequirements b) {
|
346 |
| - return mapEquals(getLimits(a), getLimits(b)) && mapEquals(getRequests(a), getRequests(b)); |
| 341 | + return KubernetesUtils.mapEquals(getLimits(a), getLimits(b)) |
| 342 | + && KubernetesUtils.mapEquals(getRequests(a), getRequests(b)); |
347 | 343 | }
|
348 | 344 |
|
349 | 345 | private static Map<String, Quantity> getLimits(V1ResourceRequirements requirements) {
|
@@ -390,17 +386,6 @@ private static List<V1VolumeMount> getVolumeMounts(V1Container container) {
|
390 | 386 | return Optional.ofNullable(container.getVolumeMounts()).orElse(Collections.emptyList());
|
391 | 387 | }
|
392 | 388 |
|
393 |
| - private static Map<String, String> getCustomerLabels(V1ObjectMeta metadata) { |
394 |
| - Map<String, String> result = new HashMap<>(); |
395 |
| - for (Map.Entry<String, String> entry : metadata.getLabels().entrySet()) |
396 |
| - if (!isOperatorLabel(entry)) result.put(entry.getKey(), entry.getValue()); |
397 |
| - return result; |
398 |
| - } |
399 |
| - |
400 |
| - private static boolean isOperatorLabel(Map.Entry<String, String> label) { |
401 |
| - return label.getKey().startsWith("weblogic."); |
402 |
| - } |
403 |
| - |
404 | 389 | private static boolean isRestartVersionValid(V1ObjectMeta build, V1ObjectMeta current) {
|
405 | 390 | return isLabelSame(build, current, LabelConstants.DOMAINRESTARTVERSION_LABEL)
|
406 | 391 | && isLabelSame(build, current, LabelConstants.CLUSTERRESTARTVERSION_LABEL)
|
|
0 commit comments