Skip to content

Commit

Permalink
refactor: remove now unneeded code
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Laprun <[email protected]>
  • Loading branch information
metacosm committed Aug 12, 2024
1 parent c258317 commit 4e9fc89
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.AdditionalIndexedClassesBuildItem;
import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.ConsoleCommandBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
Expand Down Expand Up @@ -197,30 +196,6 @@ AnnotationConfigurablesBuildItem gatherAnnotationConfigurables(
return new AnnotationConfigurablesBuildItem(configurableInfos);
}

/**
* Gathers the CustomResource implementations that are not part of the application index because they are part of an
* external, reusable module for example.
*
* Note that this will be obsolete once <a href="https://github.com/quarkusio/quarkus/pull/38586">Quarkus #38586</a> is
* usable
*
* @param combinedIndexBuildItem
* @param applicationIndexBuildItem
* @param reflectiveClassProducer
*/
@BuildStep
void gatherOutOfAppCustomResourceImplementations(CombinedIndexBuildItem combinedIndexBuildItem,
ApplicationIndexBuildItem applicationIndexBuildItem,
BuildProducer<QOSDKReflectiveClassBuildItem> reflectiveClassProducer) {
final var combinedIndex = combinedIndexBuildItem.getIndex();
final var appIndex = applicationIndexBuildItem.getIndex();

// only add the CRs found in the combined index that were not already in the application one since Quarkus should already handle these
final var crsFromCombined = combinedIndex.getAllKnownSubclasses(Constants.CUSTOM_RESOURCE);
crsFromCombined.removeAll(appIndex.getAllKnownSubclasses(Constants.CUSTOM_RESOURCE));
crsFromCombined.forEach(ci -> reflectiveClassProducer.produce(new QOSDKReflectiveClassBuildItem(ci.name().toString())));
}

@BuildStep
void registerClassesForReflection(
List<QOSDKReflectiveClassBuildItem> toRegister,
Expand Down Expand Up @@ -268,7 +243,6 @@ void initializeRuntimeNamespacesFromBuildTimeValues(
ControllerConfigurationsBuildItem configurations,
BuildProducer<RunTimeConfigurationDefaultBuildItem> runtimeConfig) {
configurations.getControllerConfigs().forEach((name, configuration) -> {
@SuppressWarnings("unchecked")
final var namespaces = String.join(",", configuration.getInformerConfig().getNamespaces());
runtimeConfig.produce(new RunTimeConfigurationDefaultBuildItem(
"quarkus.operator-sdk.controllers." + configuration.getName() + ".namespaces",
Expand All @@ -280,7 +254,6 @@ void initializeRuntimeNamespacesFromBuildTimeValues(
private void registerAssociatedClassesForReflection(BuildProducer<ReflectiveHierarchyBuildItem> reflectionClasses,
BuildProducer<ForceNonWeakReflectiveClassBuildItem> forcedReflectionClasses,
Set<String> classNamesToRegister) {
// todo: use builder API when/if https://github.com/quarkusio/quarkus/pull/38679 is available
classNamesToRegister.forEach(cn -> {
reflectionClasses.produce(
ReflectiveHierarchyBuildItem.builder(Type.create(DotName.createSimple(cn), Type.Kind.CLASS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,6 @@ static QuarkusControllerConfiguration createConfiguration(
// compute workflow and set it
initializeWorkflowIfNeeded(configuration, reconcilerInfo, index);

// need to set the namespaces after the dependents have been set so that they can be properly updated if needed
// however, we need to do it in a way that doesn't reset whether the namespaces were set by the user or not
configuration.propagateNamespacesToDependents();

log.infov(
"Processed ''{0}'' reconciler named ''{1}'' for ''{2}'' resource (version ''{3}'')",
reconcilerClassName, name, resourceFullName, HasMetadata.getApiVersion(resourceClass));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,6 @@ void setNamespaces(Set<String> namespaces) {
.withNamespaces(namespaces)
.buildForController());
wereNamespacesSet = true;
// propagate namespace changes to the dependents' config if needed
propagateNamespacesToDependents();
}
}

/**
* Record potentially user-set namespaces, updating the dependent resources, which should have been set before this method
* is called. Note that this method won't affect the status of whether the namespaces were set by the user or not, as this
* should have been recorded already when the instance was created.
* This method, while public for visibility purpose from the deployment module, should be considered internal and *NOT* be
* called from user code.
*/
@SuppressWarnings("unchecked")
public void propagateNamespacesToDependents() {
if (workflow != null) {
dependentsMetadata().forEach((unused, spec) -> {
final var config = spec.getConfiguration().orElse(null);
if (config instanceof QuarkusKubernetesDependentResourceConfig qConfig) {
qConfig.setNamespaces(informerConfig.getNamespaces());
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkiverse.operatorsdk.runtime;

import java.util.Set;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.javaoperatorsdk.operator.api.config.informer.InformerConfiguration;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependentResourceConfig;
Expand Down Expand Up @@ -32,8 +30,4 @@ public Boolean isUseSSA() {
public InformerConfiguration<R> getInformerConfig() {
return informerConfig();
}

void setNamespaces(Set<String> namespaces) {
// todo: remove?
}
}

0 comments on commit 4e9fc89

Please sign in to comment.