Search in sources :

Example 1 with CSVMetadataHolder

use of io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder in project quarkus-operator-sdk by quarkiverse.

the class BundleGenerator method prepareGeneration.

public static List<ManifestsBuilder> prepareGeneration(BundleGenerationConfiguration bundleConfiguration, BuildTimeOperatorConfiguration operatorConfiguration, Map<CSVMetadataHolder, List<AugmentedResourceInfo>> csvGroups, List<CRDInfo> crds) {
    List<ManifestsBuilder> builders = new ArrayList<>();
    for (Map.Entry<CSVMetadataHolder, List<AugmentedResourceInfo>> entry : csvGroups.entrySet()) {
        final var labels = generateBundleLabels(entry.getKey(), bundleConfiguration, operatorConfiguration);
        builders.add(new CsvManifestsBuilder(entry.getKey(), entry.getValue()));
        builders.add(new AnnotationsManifestsBuilder(entry.getKey(), labels));
        builders.add(new BundleDockerfileManifestsBuilder(entry.getKey(), labels));
        entry.getValue().stream().map(controller -> findOwnedCustomResource(controller, crds)).filter(Objects::nonNull).map(crd -> new CustomResourceManifestsBuilder(entry.getKey(), crd)).forEach(builders::add);
    }
    return builders;
}
Also used : CRDInfo(io.quarkiverse.operatorsdk.runtime.CRDInfo) BundleDockerfileManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.BundleDockerfileManifestsBuilder) BuildTimeOperatorConfiguration(io.quarkiverse.operatorsdk.runtime.BuildTimeOperatorConfiguration) HashMap(java.util.HashMap) CSVMetadataHolder(io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder) ManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.ManifestsBuilder) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) BundleGenerationConfiguration(io.quarkiverse.operatorsdk.bundle.runtime.BundleGenerationConfiguration) Map(java.util.Map) AnnotationsManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.AnnotationsManifestsBuilder) CsvManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.CsvManifestsBuilder) CustomResourceManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.CustomResourceManifestsBuilder) BundleDockerfileManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.BundleDockerfileManifestsBuilder) ManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.ManifestsBuilder) AnnotationsManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.AnnotationsManifestsBuilder) CsvManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.CsvManifestsBuilder) CustomResourceManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.CustomResourceManifestsBuilder) CustomResourceManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.CustomResourceManifestsBuilder) ArrayList(java.util.ArrayList) BundleDockerfileManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.BundleDockerfileManifestsBuilder) CSVMetadataHolder(io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder) AnnotationsManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.AnnotationsManifestsBuilder) Objects(java.util.Objects) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) CsvManifestsBuilder(io.quarkiverse.operatorsdk.bundle.deployment.builders.CsvManifestsBuilder)

Example 2 with CSVMetadataHolder

use of io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder in project quarkus-operator-sdk by quarkiverse.

the class BundleProcessor method gatherCSVMetadata.

@SuppressWarnings("unchecked")
@BuildStep
CSVMetadataBuildItem gatherCSVMetadata(ApplicationInfoBuildItem configuration, BundleGenerationConfiguration bundleConfiguration, CombinedIndexBuildItem combinedIndexBuildItem, ConfigurationServiceBuildItem configurations) {
    final var controllerConfigs = configurations.getControllerConfigs();
    final var index = combinedIndexBuildItem.getIndex();
    final var operatorCsvMetadata = getCSVMetadataForOperator(bundleConfiguration.packageName.orElse(configuration.getName()), index);
    final var csvGroups = new HashMap<CSVMetadataHolder, List<AugmentedResourceInfo>>();
    ClassUtils.getKnownReconcilers(index, log).forEach(reconcilerInfo -> {
        // figure out which group should be used to generate CSV
        final var name = reconcilerInfo.name();
        log.debugv("Processing reconciler: {0}", name);
        final var config = controllerConfigs.get(name);
        if (config == null) {
            throw new IllegalStateException("Missing configuration for reconciler " + name);
        }
        // Check whether the reconciler must be shipped using a custom bundle
        CSVMetadataHolder csvMetadata = getCsvMetadataFromAnnotation(operatorCsvMetadata, reconcilerInfo.classInfo()).orElse(operatorCsvMetadata);
        final var resourceFullName = config.getResourceTypeName();
        final var resourceInfo = ResourceInfo.createFrom(config.getResourceClass(), resourceFullName, name, config.getSpecClassName(), config.getStatusClassName());
        csvGroups.computeIfAbsent(csvMetadata, m -> new ArrayList<>()).add(new AugmentedResourceInfo(resourceInfo, csvMetadata.name));
    });
    return new CSVMetadataBuildItem(csvGroups);
}
Also used : ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) ClassUtils(io.quarkiverse.operatorsdk.common.ClassUtils) Logger(org.jboss.logging.Logger) DotName(org.jboss.jandex.DotName) Role(io.fabric8.kubernetes.api.model.rbac.Role) HashMap(java.util.HashMap) ClassInfo(org.jboss.jandex.ClassInfo) CSVMetadataHolder(io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) GeneratedCRDInfoBuildItem(io.quarkiverse.operatorsdk.deployment.GeneratedCRDInfoBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) ArrayList(java.util.ArrayList) GeneratedKubernetesResourceBuildItem(io.quarkus.kubernetes.spi.GeneratedKubernetesResourceBuildItem) RoleBinding(io.fabric8.kubernetes.api.model.rbac.RoleBinding) BuildStep(io.quarkus.deployment.annotations.BuildStep) BundleGenerationConfiguration(io.quarkiverse.operatorsdk.bundle.runtime.BundleGenerationConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) ConfigurationUtils(io.quarkiverse.operatorsdk.common.ConfigurationUtils) LinkedList(java.util.LinkedList) Path(java.nio.file.Path) IndexView(org.jboss.jandex.IndexView) AnnotationValue(org.jboss.jandex.AnnotationValue) ResourceInfo(io.quarkiverse.operatorsdk.runtime.ResourceInfo) BuildTimeOperatorConfiguration(io.quarkiverse.operatorsdk.runtime.BuildTimeOperatorConfiguration) IOException(java.io.IOException) Serialization(io.dekorate.utils.Serialization) ConfigurationServiceBuildItem(io.quarkiverse.operatorsdk.deployment.ConfigurationServiceBuildItem) Collectors(java.util.stream.Collectors) CSVMetadata(io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadata) Objects(java.util.Objects) List(java.util.List) SharedCSVMetadata(io.quarkiverse.operatorsdk.bundle.runtime.SharedCSVMetadata) OutputTargetBuildItem(io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ApplicationInfoBuildItem(io.quarkus.deployment.builditem.ApplicationInfoBuildItem) GeneratedFileSystemResourceBuildItem(io.quarkus.deployment.builditem.GeneratedFileSystemResourceBuildItem) ClusterRole(io.fabric8.kubernetes.api.model.rbac.ClusterRole) ALL_VERBS(io.quarkiverse.operatorsdk.deployment.AddClusterRolesDecorator.ALL_VERBS) Optional(java.util.Optional) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) CSVMetadataHolder(io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 3 with CSVMetadataHolder

use of io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder in project quarkus-operator-sdk by quarkiverse.

the class BundleProcessor method getCSVMetadataForOperator.

private CSVMetadataHolder getCSVMetadataForOperator(String name, IndexView index) {
    CSVMetadataHolder csvMetadata = new CSVMetadataHolder(name);
    csvMetadata = aggregateMetadataFromSharedCsvMetadata(csvMetadata, index);
    return csvMetadata;
}
Also used : CSVMetadataHolder(io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder)

Aggregations

CSVMetadataHolder (io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadataHolder)3 BundleGenerationConfiguration (io.quarkiverse.operatorsdk.bundle.runtime.BundleGenerationConfiguration)2 BuildTimeOperatorConfiguration (io.quarkiverse.operatorsdk.runtime.BuildTimeOperatorConfiguration)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Objects (java.util.Objects)2 Serialization (io.dekorate.utils.Serialization)1 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)1 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)1 ClusterRole (io.fabric8.kubernetes.api.model.rbac.ClusterRole)1 ClusterRoleBinding (io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding)1 Role (io.fabric8.kubernetes.api.model.rbac.Role)1 RoleBinding (io.fabric8.kubernetes.api.model.rbac.RoleBinding)1 AnnotationsManifestsBuilder (io.quarkiverse.operatorsdk.bundle.deployment.builders.AnnotationsManifestsBuilder)1 BundleDockerfileManifestsBuilder (io.quarkiverse.operatorsdk.bundle.deployment.builders.BundleDockerfileManifestsBuilder)1 CsvManifestsBuilder (io.quarkiverse.operatorsdk.bundle.deployment.builders.CsvManifestsBuilder)1 CustomResourceManifestsBuilder (io.quarkiverse.operatorsdk.bundle.deployment.builders.CustomResourceManifestsBuilder)1 ManifestsBuilder (io.quarkiverse.operatorsdk.bundle.deployment.builders.ManifestsBuilder)1 CSVMetadata (io.quarkiverse.operatorsdk.bundle.runtime.CSVMetadata)1