From 1900f9498b73f0efcfb164e0fdc44a13bc90033b Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Thu, 29 Aug 2024 21:07:45 +0200 Subject: [PATCH] chore(deps): update JOSDK to 4.9.4 Signed-off-by: Chris Laprun --- .../deployment/AddClusterRolesDecorator.java | 29 +++---------------- pom.xml | 2 +- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/AddClusterRolesDecorator.java b/core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/AddClusterRolesDecorator.java index 1951ae7c..ace2d504 100644 --- a/core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/AddClusterRolesDecorator.java +++ b/core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/AddClusterRolesDecorator.java @@ -6,7 +6,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; @@ -14,22 +13,18 @@ import org.jboss.logging.Logger; import io.dekorate.kubernetes.decorator.ResourceProvidingDecorator; -import io.fabric8.kubernetes.api.Pluralize; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesListBuilder; import io.fabric8.kubernetes.api.model.rbac.ClusterRole; import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBuilder; import io.fabric8.kubernetes.api.model.rbac.PolicyRule; import io.fabric8.kubernetes.api.model.rbac.PolicyRuleBuilder; -import io.javaoperatorsdk.operator.api.config.ConfigurationService; import io.javaoperatorsdk.operator.api.config.Utils; import io.javaoperatorsdk.operator.api.reconciler.dependent.Deleter; import io.javaoperatorsdk.operator.processing.dependent.Creator; import io.javaoperatorsdk.operator.processing.dependent.Updater; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.GenericKubernetesDependentResource; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependentResource; -import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependentResourceConfig; -import io.javaoperatorsdk.operator.processing.dependent.kubernetes.ResourceUpdaterMatcher; import io.quarkiverse.operatorsdk.annotations.RBACVerbs; import io.quarkiverse.operatorsdk.runtime.DependentResourceSpecMetadata; import io.quarkiverse.operatorsdk.runtime.QuarkusControllerConfiguration; @@ -107,6 +102,7 @@ private static String getKeyFor(PolicyRule rule) { + rule.getResources().stream().sorted().collect(Collectors.joining("-")); } + @SuppressWarnings("unchecked") private static Set getClusterRolePolicyRulesFromDependentResources(QuarkusControllerConfiguration cri) { Set rules = new LinkedHashSet<>(); final Map> dependentsMetadata = cri.getDependentsMetadata(); @@ -133,7 +129,7 @@ private static Set getClusterRolePolicyRulesFromDependentResources(Q // Check if we're dealing with typeless Kubernetes resource or if we need to deal with SSA if (KubernetesDependentResource.class.isAssignableFrom(dependentResourceClass)) { try { - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") var kubeResource = Utils.instantiate( (Class) dependentResourceClass, KubernetesDependentResource.class, ADD_CLUSTER_ROLES_DECORATOR); @@ -141,13 +137,11 @@ private static Set getClusterRolePolicyRulesFromDependentResources(Q if (kubeResource instanceof GenericKubernetesDependentResource genericKubeRes) { final var gvk = genericKubeRes.getGroupVersionKind(); resourceGroup = gvk.getGroup(); - // todo: use plural form on GVK if available, see https://github.com/operator-framework/java-operator-sdk/pull/2515 - resourcePlural = Pluralize.toPlural(gvk.getKind()); + resourcePlural = gvk.getPluralOrDefault(); } // if we use SSA and the dependent resource class is not excluded from using SSA, we also need PATCH permissions for finalizer - // todo: replace by using ConfigurationService.isUsingSSA once available see https://github.com/operator-framework/java-operator-sdk/pull/2516 - if (isUsingSSA(kubeResource, cri.getConfigurationService())) { + if (cri.getConfigurationService().shouldUseSSA(kubeResource)) { verbs.add(RBACVerbs.PATCH); } } catch (Exception e) { @@ -166,21 +160,6 @@ private static Set getClusterRolePolicyRulesFromDependentResources(Q return rules; } - private static boolean isUsingSSA(KubernetesDependentResource dependentResource, - ConfigurationService configurationService) { - if (dependentResource instanceof ResourceUpdaterMatcher) { - return false; - } - Optional useSSAConfig = dependentResource.configuration() - .flatMap(KubernetesDependentResourceConfig::useSSA); - // don't use SSA for certain resources by default, only if explicitly overriden - if (useSSAConfig.isEmpty() - && configurationService.defaultNonSSAResource().contains(dependentResource.resourceType())) { - return false; - } - return useSSAConfig.orElse(configurationService.ssaBasedCreateUpdateMatchForDependentResources()); - } - private static PolicyRule getClusterRolePolicyRuleFromPrimaryResource(QuarkusControllerConfiguration cri) { final var rule = new PolicyRuleBuilder(); final var resourceClass = cri.getResourceClass(); diff --git a/pom.xml b/pom.xml index cba21a6b..3a53432a 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ Quarkus - Operator SDK - Parent 3.14.1 - 4.9.3 + 4.9.4 :git:git@github.com:quarkiverse/quarkus-operator-sdk.git