All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.operatorsdk.deployment.BuildTimeHybridControllerConfiguration Maven / Gradle / Ivy

There is a newer version: 6.8.4
Show newest version
package io.quarkiverse.operatorsdk.deployment;

import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;

import io.quarkiverse.operatorsdk.common.ConfigurationUtils;
import io.quarkiverse.operatorsdk.runtime.BuildTimeControllerConfiguration;
import io.quarkiverse.operatorsdk.runtime.BuildTimeOperatorConfiguration;

class BuildTimeHybridControllerConfiguration {

    private final BuildTimeOperatorConfiguration operatorConfiguration;
    private final BuildTimeControllerConfiguration externalConfiguration;
    private final AnnotationInstance controllerAnnotation;

    public BuildTimeHybridControllerConfiguration(
            BuildTimeOperatorConfiguration operatorConfiguration, BuildTimeControllerConfiguration externalConfiguration,
            AnnotationInstance controllerAnnotation) {
        this.operatorConfiguration = operatorConfiguration;
        this.externalConfiguration = externalConfiguration;
        this.controllerAnnotation = controllerAnnotation;
    }

    boolean generationAware() {
        return ConfigurationUtils.extract(
                externalConfiguration,
                controllerAnnotation, BuildTimeControllerConfiguration::generationAware,
                "generationAwareEventProcessing",
                AnnotationValue::asBoolean,
                () -> operatorConfiguration.generationAware().orElse(true));
    }

    Set generateWithWatchedNamespaces(boolean wereNamespacesSet) {
        Set namespaces = null;
        if (externalConfiguration != null) {
            Optional> overrideNamespaces = externalConfiguration.generateWithWatchedNamespaces();
            if (overrideNamespaces.isPresent()) {
                namespaces = new HashSet<>(overrideNamespaces.get());
            }
        }

        // check if we have an operator-level configuration only if namespaces haven't been explicitly set already
        final var watchedNamespaces = operatorConfiguration.generateWithWatchedNamespaces();
        if (!wereNamespacesSet && namespaces == null && watchedNamespaces.isPresent()) {
            namespaces = new HashSet<>(watchedNamespaces.get());
        }

        return namespaces;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy