Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update JOSDK to 4.9.4 #940

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@
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;

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;
Expand Down Expand Up @@ -107,6 +102,7 @@ private static String getKeyFor(PolicyRule rule) {
+ rule.getResources().stream().sorted().collect(Collectors.joining("-"));
}

@SuppressWarnings("unchecked")
private static Set<PolicyRule> getClusterRolePolicyRulesFromDependentResources(QuarkusControllerConfiguration<?> cri) {
Set<PolicyRule> rules = new LinkedHashSet<>();
final Map<String, DependentResourceSpecMetadata<?, ?, ?>> dependentsMetadata = cri.getDependentsMetadata();
Expand All @@ -133,21 +129,19 @@ private static Set<PolicyRule> 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<? extends KubernetesDependentResource>) dependentResourceClass,
KubernetesDependentResource.class, ADD_CLUSTER_ROLES_DECORATOR);

if (kubeResource instanceof GenericKubernetesDependentResource<? extends HasMetadata> 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) {
Expand All @@ -166,21 +160,6 @@ private static Set<PolicyRule> getClusterRolePolicyRulesFromDependentResources(Q
return rules;
}

private static boolean isUsingSSA(KubernetesDependentResource<?, ?> dependentResource,
ConfigurationService configurationService) {
if (dependentResource instanceof ResourceUpdaterMatcher) {
return false;
}
Optional<Boolean> 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();
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>Quarkus - Operator SDK - Parent</name>
<properties>
<quarkus.version>3.14.1</quarkus.version>
<java-operator-sdk.version>4.9.3</java-operator-sdk.version>
<java-operator-sdk.version>4.9.4</java-operator-sdk.version>
</properties>
<scm>
<connection>:git:git@github.com:quarkiverse/quarkus-operator-sdk.git</connection>
Expand Down