From e1300c85a551a1b26a95d5ff0e78fbc3c2ad6f4f Mon Sep 17 00:00:00 2001 From: Summers Pittman Date: Thu, 9 Dec 2021 12:32:43 -0500 Subject: [PATCH] chore: autoformat --- .../com/openshift/cloud/RHOASOperator.java | 28 +++++++++++-------- .../cloud/beans/KafkaK8sClients.java | 5 ++-- .../AbstractCloudServicesController.java | 21 +++++++------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/source/rhoas/src/main/java/com/openshift/cloud/RHOASOperator.java b/source/rhoas/src/main/java/com/openshift/cloud/RHOASOperator.java index e011b9b1..9805a3b7 100755 --- a/source/rhoas/src/main/java/com/openshift/cloud/RHOASOperator.java +++ b/source/rhoas/src/main/java/com/openshift/cloud/RHOASOperator.java @@ -81,28 +81,32 @@ public int run(String... args) throws Exception { private void cleanupDeletedLegacyFinalizers() { - //Clean up legacy Finalizers for deleted resources - //We removed finalizers for several types, but didn't correctly remove them from instanced resources in k8s - //if those resources were deleted then we need to remove the finalizers here outside of the normal reconsiliation loop + // Clean up legacy Finalizers for deleted resources + // We removed finalizers for several types, but didn't correctly remove them from instanced + // resources in k8s + // if those resources were deleted then we need to remove the finalizers here outside of the + // normal reconsiliation loop var srcs = new ArrayList<>(client.serviceRegistryConnection().list().getItems()); srcs.removeIf(item -> !item.isMarkedForDeletion()); - srcs.forEach(src->src.removeFinalizer("serviceregistryconnections.rhoas.redhat.com/finalizer")); - srcs.forEach(src->client.serviceRegistryConnection().createOrReplace(src)); + srcs.forEach( + src -> src.removeFinalizer("serviceregistryconnections.rhoas.redhat.com/finalizer")); + srcs.forEach(src -> client.serviceRegistryConnection().createOrReplace(src)); - var csrs = new ArrayList<>(client.cloudServicesRequest().list().getItems()); + var csrs = new ArrayList<>(client.cloudServicesRequest().list().getItems()); csrs.removeIf(item -> !item.isMarkedForDeletion()); - csrs.forEach(csr->csr.removeFinalizer("cloudservicesrequests.rhoas.redhat.com/finalizer")); - csrs.forEach(csr->client.cloudServicesRequest().createOrReplace(csr)); + csrs.forEach(csr -> csr.removeFinalizer("cloudservicesrequests.rhoas.redhat.com/finalizer")); + csrs.forEach(csr -> client.cloudServicesRequest().createOrReplace(csr)); var akcs = new ArrayList<>(client.kafkaConnection().list().getItems()); akcs.removeIf(item -> !item.isMarkedForDeletion()); - akcs.forEach(akc->akc.removeFinalizer("kafkaconnections.rhoas.redhat.com/finalizer")); - akcs.forEach(akc->client.kafkaConnection().createOrReplace(akc)); + akcs.forEach(akc -> akc.removeFinalizer("kafkaconnections.rhoas.redhat.com/finalizer")); + akcs.forEach(akc -> client.kafkaConnection().createOrReplace(akc)); var csars = new ArrayList<>(client.cloudServiceAccountRequest().list().getItems()); csars.removeIf(item -> !item.isMarkedForDeletion()); - csars.forEach(csar->csar.removeFinalizer("cloudserviceaccountrequests.rhoas.redhat.com/finalizer")); - csars.forEach(csar->client.cloudServiceAccountRequest().createOrReplace(csar)); + csars.forEach( + csar -> csar.removeFinalizer("cloudserviceaccountrequests.rhoas.redhat.com/finalizer")); + csars.forEach(csar -> client.cloudServiceAccountRequest().createOrReplace(csar)); } diff --git a/source/rhoas/src/main/java/com/openshift/cloud/beans/KafkaK8sClients.java b/source/rhoas/src/main/java/com/openshift/cloud/beans/KafkaK8sClients.java index a9abc4c3..72dd33d2 100644 --- a/source/rhoas/src/main/java/com/openshift/cloud/beans/KafkaK8sClients.java +++ b/source/rhoas/src/main/java/com/openshift/cloud/beans/KafkaK8sClients.java @@ -121,13 +121,14 @@ public MixedOperation> serviceRegistryConnection() { KubernetesDeserializer.registerCustomKind(getApiVersion(ServiceRegistryConnection.class), srcCrd.getKind(), ServiceRegistryConnection.class); - return client.resources(ServiceRegistryConnection.class, ServiceRegistryConnectionList.class); + return client.resources(ServiceRegistryConnection.class, ServiceRegistryConnectionList.class); } private CustomResourceDefinition initCloudServiceAccountRequestCRDAndClient( diff --git a/source/rhoas/src/main/java/com/openshift/cloud/controllers/AbstractCloudServicesController.java b/source/rhoas/src/main/java/com/openshift/cloud/controllers/AbstractCloudServicesController.java index 945ff689..184e2d07 100644 --- a/source/rhoas/src/main/java/com/openshift/cloud/controllers/AbstractCloudServicesController.java +++ b/source/rhoas/src/main/java/com/openshift/cloud/controllers/AbstractCloudServicesController.java @@ -25,12 +25,11 @@ public abstract class AbstractCloudServicesController public static final String COMPONENT_LABEL_KEY = "app.kubernetes.io/component"; public static final String MANAGED_BY_LABEL_KEY = "app.kubernetes.io/managed-by"; - public static final List LEGACY_FINALIZERS = List.of( - "cloudservicesrequests.rhoas.redhat.com/finalizer", - "cloudserviceaccountrequests.rhoas.redhat.com/finalizer", - "kafkaconnections.rhoas.redhat.com/finalizer", - "serviceregistryconnections.rhoas.redhat.com/finalizer" - ); + public static final List LEGACY_FINALIZERS = + List.of("cloudservicesrequests.rhoas.redhat.com/finalizer", + "cloudserviceaccountrequests.rhoas.redhat.com/finalizer", + "kafkaconnections.rhoas.redhat.com/finalizer", + "serviceregistryconnections.rhoas.redhat.com/finalizer"); public static final String COMPONENT_LABEL_VALUE = "external-service"; public static final String MANAGED_BY_LABEL_VALUE = "rhoas"; @@ -110,21 +109,23 @@ private boolean requiresLabelUpdate(T resource) { } /** - * We used to have finalizers for some classes, but these were removed. - * This method checks to see if a legacy finalizer is attatched and removes it. + * We used to have finalizers for some classes, but these were removed. This method checks to see + * if a legacy finalizer is attatched and removes it. * * @param resource * @return if a finalizer should be removed */ private boolean shouldRemoveFinalizer(T resource) { var finalizers = resource.getMetadata().getFinalizers(); - var toRemove = finalizers.stream().filter(finalizer -> LEGACY_FINALIZERS.contains(finalizer)).collect(Collectors.toList()); + var toRemove = finalizers.stream().filter(finalizer -> LEGACY_FINALIZERS.contains(finalizer)) + .collect(Collectors.toList()); return toRemove.size() > 0; } private void removeFinalizer(T resource) { var finalizers = resource.getMetadata().getFinalizers(); - var toRemove = finalizers.stream().filter(finalizer -> LEGACY_FINALIZERS.contains(finalizer)).collect(Collectors.toList()); + var toRemove = finalizers.stream().filter(finalizer -> LEGACY_FINALIZERS.contains(finalizer)) + .collect(Collectors.toList()); LOG.warning("Found legacy Finalizers " + toRemove); toRemove.forEach(finalizer -> resource.removeFinalizer(finalizer)); }