Search in sources :

Example 6 with CustomResourceDefinitionBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder in project entando-k8s-controller-coordinator by entando-k8s.

the class PodManagementTests method prepareCrds.

@BeforeEach
void prepareCrds() throws IOException {
    System.setProperty(ControllerCoordinatorProperty.ENTANDO_STORE_LOG_ENTRIES.getJvmSystemProperty(), "true");
    System.clearProperty(EntandoOperatorConfigProperty.ENTANDO_NAMESPACES_TO_OBSERVE.getJvmSystemProperty());
    System.clearProperty(ControllerCoordinatorProperty.ENTANDO_K8S_OPERATOR_VERSION.getJvmSystemProperty());
    System.clearProperty(ControllerCoordinatorProperty.ENTANDO_K8S_OPERATOR_VERSION_TO_REPLACE.getJvmSystemProperty());
    final CustomResourceDefinition testResourceDefinition = objectMapper.readValue(Thread.currentThread().getContextClassLoader().getResource("testresources.test.org.crd.yaml"), CustomResourceDefinition.class);
    clientDouble.getCluster().putCustomResourceDefinition(new CustomResourceDefinitionBuilder(testResourceDefinition).editMetadata().addToLabels(LabelNames.CRD_OF_INTEREST.getName(), "TestResource").addToAnnotations(AnnotationNames.CONTROLLER_IMAGE.getName(), "test/my-controller").addToAnnotations(AnnotationNames.SUPPORTED_CAPABILITIES.getName(), "dbms").endMetadata().build());
    LogInterceptor.listenToClass(EntandoResourceObserver.class);
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with CustomResourceDefinitionBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class StrimziBundleManagerTest method createKafkaCRDs.

private CustomResourceDefinition createKafkaCRDs() {
    CustomResourceDefinition crd = new CustomResourceDefinitionBuilder(Crds.kafka()).editMetadata().withName("kafkas.kafka.strimzi.io").withLabels(Map.of("app", "strimzi")).endMetadata().build();
    this.openShiftClient.apiextensions().v1().customResourceDefinitions().create(crd);
    return crd;
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)

Example 8 with CustomResourceDefinitionBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder in project strimzi by strimzi.

the class Crds method crd.

@SuppressWarnings({ "checkstyle:JavaNCSS" })
private static CustomResourceDefinition crd(Class<? extends CustomResource> cls) {
    String scope, plural, singular, group, kind, listKind;
    List<String> versions;
    CustomResourceSubresourceStatus status = null;
    if (cls.equals(Kafka.class)) {
        scope = Kafka.SCOPE;
        plural = Kafka.RESOURCE_PLURAL;
        singular = Kafka.RESOURCE_SINGULAR;
        group = Kafka.RESOURCE_GROUP;
        kind = Kafka.RESOURCE_KIND;
        listKind = Kafka.RESOURCE_LIST_KIND;
        versions = Kafka.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaConnect.class)) {
        scope = KafkaConnect.SCOPE;
        plural = KafkaConnect.RESOURCE_PLURAL;
        singular = KafkaConnect.RESOURCE_SINGULAR;
        group = KafkaConnect.RESOURCE_GROUP;
        kind = KafkaConnect.RESOURCE_KIND;
        listKind = KafkaConnect.RESOURCE_LIST_KIND;
        versions = KafkaConnect.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaTopic.class)) {
        scope = KafkaTopic.SCOPE;
        plural = KafkaTopic.RESOURCE_PLURAL;
        singular = KafkaTopic.RESOURCE_SINGULAR;
        group = KafkaTopic.RESOURCE_GROUP;
        kind = KafkaTopic.RESOURCE_KIND;
        listKind = KafkaTopic.RESOURCE_LIST_KIND;
        versions = KafkaTopic.VERSIONS;
    } else if (cls.equals(KafkaUser.class)) {
        scope = KafkaUser.SCOPE;
        plural = KafkaUser.RESOURCE_PLURAL;
        singular = KafkaUser.RESOURCE_SINGULAR;
        group = KafkaUser.RESOURCE_GROUP;
        kind = KafkaUser.RESOURCE_KIND;
        listKind = KafkaUser.RESOURCE_LIST_KIND;
        versions = KafkaUser.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaMirrorMaker.class)) {
        scope = KafkaMirrorMaker.SCOPE;
        plural = KafkaMirrorMaker.RESOURCE_PLURAL;
        singular = KafkaMirrorMaker.RESOURCE_SINGULAR;
        group = KafkaMirrorMaker.RESOURCE_GROUP;
        kind = KafkaMirrorMaker.RESOURCE_KIND;
        listKind = KafkaMirrorMaker.RESOURCE_LIST_KIND;
        versions = KafkaMirrorMaker.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaBridge.class)) {
        scope = KafkaBridge.SCOPE;
        plural = KafkaBridge.RESOURCE_PLURAL;
        singular = KafkaBridge.RESOURCE_SINGULAR;
        group = KafkaBridge.RESOURCE_GROUP;
        kind = KafkaBridge.RESOURCE_KIND;
        listKind = KafkaBridge.RESOURCE_LIST_KIND;
        versions = KafkaBridge.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaConnector.class)) {
        scope = KafkaConnector.SCOPE;
        plural = KafkaConnector.RESOURCE_PLURAL;
        singular = KafkaConnector.RESOURCE_SINGULAR;
        group = KafkaConnector.RESOURCE_GROUP;
        kind = KafkaConnector.RESOURCE_KIND;
        listKind = KafkaConnector.RESOURCE_LIST_KIND;
        versions = KafkaConnector.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaMirrorMaker2.class)) {
        scope = KafkaMirrorMaker2.SCOPE;
        plural = KafkaMirrorMaker2.RESOURCE_PLURAL;
        singular = KafkaMirrorMaker2.RESOURCE_SINGULAR;
        group = KafkaMirrorMaker2.RESOURCE_GROUP;
        kind = KafkaMirrorMaker2.RESOURCE_KIND;
        listKind = KafkaMirrorMaker2.RESOURCE_LIST_KIND;
        versions = KafkaMirrorMaker2.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaRebalance.class)) {
        scope = KafkaRebalance.SCOPE;
        plural = KafkaRebalance.RESOURCE_PLURAL;
        singular = KafkaRebalance.RESOURCE_SINGULAR;
        group = KafkaRebalance.RESOURCE_GROUP;
        kind = KafkaRebalance.RESOURCE_KIND;
        listKind = KafkaRebalance.RESOURCE_LIST_KIND;
        versions = KafkaRebalance.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(StrimziPodSet.class)) {
        scope = StrimziPodSet.SCOPE;
        plural = StrimziPodSet.RESOURCE_PLURAL;
        singular = StrimziPodSet.RESOURCE_SINGULAR;
        group = StrimziPodSet.RESOURCE_GROUP;
        kind = StrimziPodSet.RESOURCE_KIND;
        listKind = StrimziPodSet.RESOURCE_LIST_KIND;
        versions = StrimziPodSet.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else {
        throw new RuntimeException();
    }
    List<CustomResourceDefinitionVersion> crVersions = new ArrayList<>(versions.size());
    for (String apiVersion : versions) {
        crVersions.add(new CustomResourceDefinitionVersionBuilder().withName(apiVersion).withNewSubresources().withStatus(status).endSubresources().withNewSchema().withNewOpenAPIV3Schema().withType("object").withXKubernetesPreserveUnknownFields(true).endOpenAPIV3Schema().endSchema().withStorage("v1beta2".equals(apiVersion)).withServed(true).build());
    }
    return new CustomResourceDefinitionBuilder().withNewMetadata().withName(plural + "." + group).endMetadata().withNewSpec().withScope(scope).withGroup(group).withVersions(crVersions).withNewNames().withSingular(singular).withPlural(plural).withKind(kind).withListKind(listKind).endNames().endSpec().build();
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder) StrimziPodSet(io.strimzi.api.kafka.model.StrimziPodSet) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) ArrayList(java.util.ArrayList) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) CustomResourceDefinitionVersionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersionBuilder) CustomResourceSubresourceStatus(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceSubresourceStatus) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) CustomResourceDefinitionVersion(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersion) KafkaUser(io.strimzi.api.kafka.model.KafkaUser)

Example 9 with CustomResourceDefinitionBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder in project strimzi-kafka-operator by strimzi.

the class Crds method crd.

@SuppressWarnings({ "checkstyle:JavaNCSS" })
private static CustomResourceDefinition crd(Class<? extends CustomResource> cls) {
    String scope, plural, singular, group, kind, listKind;
    List<String> versions;
    CustomResourceSubresourceStatus status = null;
    if (cls.equals(Kafka.class)) {
        scope = Kafka.SCOPE;
        plural = Kafka.RESOURCE_PLURAL;
        singular = Kafka.RESOURCE_SINGULAR;
        group = Kafka.RESOURCE_GROUP;
        kind = Kafka.RESOURCE_KIND;
        listKind = Kafka.RESOURCE_LIST_KIND;
        versions = Kafka.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaConnect.class)) {
        scope = KafkaConnect.SCOPE;
        plural = KafkaConnect.RESOURCE_PLURAL;
        singular = KafkaConnect.RESOURCE_SINGULAR;
        group = KafkaConnect.RESOURCE_GROUP;
        kind = KafkaConnect.RESOURCE_KIND;
        listKind = KafkaConnect.RESOURCE_LIST_KIND;
        versions = KafkaConnect.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaTopic.class)) {
        scope = KafkaTopic.SCOPE;
        plural = KafkaTopic.RESOURCE_PLURAL;
        singular = KafkaTopic.RESOURCE_SINGULAR;
        group = KafkaTopic.RESOURCE_GROUP;
        kind = KafkaTopic.RESOURCE_KIND;
        listKind = KafkaTopic.RESOURCE_LIST_KIND;
        versions = KafkaTopic.VERSIONS;
    } else if (cls.equals(KafkaUser.class)) {
        scope = KafkaUser.SCOPE;
        plural = KafkaUser.RESOURCE_PLURAL;
        singular = KafkaUser.RESOURCE_SINGULAR;
        group = KafkaUser.RESOURCE_GROUP;
        kind = KafkaUser.RESOURCE_KIND;
        listKind = KafkaUser.RESOURCE_LIST_KIND;
        versions = KafkaUser.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaMirrorMaker.class)) {
        scope = KafkaMirrorMaker.SCOPE;
        plural = KafkaMirrorMaker.RESOURCE_PLURAL;
        singular = KafkaMirrorMaker.RESOURCE_SINGULAR;
        group = KafkaMirrorMaker.RESOURCE_GROUP;
        kind = KafkaMirrorMaker.RESOURCE_KIND;
        listKind = KafkaMirrorMaker.RESOURCE_LIST_KIND;
        versions = KafkaMirrorMaker.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaBridge.class)) {
        scope = KafkaBridge.SCOPE;
        plural = KafkaBridge.RESOURCE_PLURAL;
        singular = KafkaBridge.RESOURCE_SINGULAR;
        group = KafkaBridge.RESOURCE_GROUP;
        kind = KafkaBridge.RESOURCE_KIND;
        listKind = KafkaBridge.RESOURCE_LIST_KIND;
        versions = KafkaBridge.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaConnector.class)) {
        scope = KafkaConnector.SCOPE;
        plural = KafkaConnector.RESOURCE_PLURAL;
        singular = KafkaConnector.RESOURCE_SINGULAR;
        group = KafkaConnector.RESOURCE_GROUP;
        kind = KafkaConnector.RESOURCE_KIND;
        listKind = KafkaConnector.RESOURCE_LIST_KIND;
        versions = KafkaConnector.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaMirrorMaker2.class)) {
        scope = KafkaMirrorMaker2.SCOPE;
        plural = KafkaMirrorMaker2.RESOURCE_PLURAL;
        singular = KafkaMirrorMaker2.RESOURCE_SINGULAR;
        group = KafkaMirrorMaker2.RESOURCE_GROUP;
        kind = KafkaMirrorMaker2.RESOURCE_KIND;
        listKind = KafkaMirrorMaker2.RESOURCE_LIST_KIND;
        versions = KafkaMirrorMaker2.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(KafkaRebalance.class)) {
        scope = KafkaRebalance.SCOPE;
        plural = KafkaRebalance.RESOURCE_PLURAL;
        singular = KafkaRebalance.RESOURCE_SINGULAR;
        group = KafkaRebalance.RESOURCE_GROUP;
        kind = KafkaRebalance.RESOURCE_KIND;
        listKind = KafkaRebalance.RESOURCE_LIST_KIND;
        versions = KafkaRebalance.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else if (cls.equals(StrimziPodSet.class)) {
        scope = StrimziPodSet.SCOPE;
        plural = StrimziPodSet.RESOURCE_PLURAL;
        singular = StrimziPodSet.RESOURCE_SINGULAR;
        group = StrimziPodSet.RESOURCE_GROUP;
        kind = StrimziPodSet.RESOURCE_KIND;
        listKind = StrimziPodSet.RESOURCE_LIST_KIND;
        versions = StrimziPodSet.VERSIONS;
        status = new CustomResourceSubresourceStatus();
    } else {
        throw new RuntimeException();
    }
    List<CustomResourceDefinitionVersion> crVersions = new ArrayList<>(versions.size());
    for (String apiVersion : versions) {
        crVersions.add(new CustomResourceDefinitionVersionBuilder().withName(apiVersion).withNewSubresources().withStatus(status).endSubresources().withNewSchema().withNewOpenAPIV3Schema().withType("object").withXKubernetesPreserveUnknownFields(true).endOpenAPIV3Schema().endSchema().withStorage("v1beta2".equals(apiVersion)).withServed(true).build());
    }
    return new CustomResourceDefinitionBuilder().withNewMetadata().withName(plural + "." + group).endMetadata().withNewSpec().withScope(scope).withGroup(group).withVersions(crVersions).withNewNames().withSingular(singular).withPlural(plural).withKind(kind).withListKind(listKind).endNames().endSpec().build();
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder) StrimziPodSet(io.strimzi.api.kafka.model.StrimziPodSet) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) ArrayList(java.util.ArrayList) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) CustomResourceDefinitionVersionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersionBuilder) CustomResourceSubresourceStatus(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceSubresourceStatus) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) CustomResourceDefinitionVersion(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersion) KafkaUser(io.strimzi.api.kafka.model.KafkaUser)

Example 10 with CustomResourceDefinitionBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder in project entando-k8s-controller-coordinator by entando-k8s.

the class LivenessTests method prepareCrds.

@BeforeEach
void prepareCrds() throws IOException {
    System.setProperty(ControllerCoordinatorProperty.ENTANDO_STORE_LOG_ENTRIES.getJvmSystemProperty(), "true");
    System.clearProperty(EntandoOperatorConfigProperty.ENTANDO_NAMESPACES_TO_OBSERVE.getJvmSystemProperty());
    System.clearProperty(ControllerCoordinatorProperty.ENTANDO_K8S_OPERATOR_VERSION.getJvmSystemProperty());
    System.clearProperty(ControllerCoordinatorProperty.ENTANDO_K8S_OPERATOR_VERSION_TO_REPLACE.getJvmSystemProperty());
    final CustomResourceDefinition testResourceDefinition = objectMapper.readValue(Thread.currentThread().getContextClassLoader().getResource("testresources.test.org.crd.yaml"), CustomResourceDefinition.class);
    clientDouble.getCluster().putCustomResourceDefinition(new CustomResourceDefinitionBuilder(testResourceDefinition).editMetadata().addToLabels(LabelNames.CRD_OF_INTEREST.getName(), "TestResource").addToAnnotations(AnnotationNames.CONTROLLER_IMAGE.getName(), "test/my-controller").addToAnnotations(AnnotationNames.SUPPORTED_CAPABILITIES.getName(), "dbms").endMetadata().build());
    LogInterceptor.listenToClass(Liveness.class);
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition)12 CustomResourceDefinitionBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder)11 Test (org.junit.jupiter.api.Test)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)7 Description (io.qameta.allure.Description)7 StartupEvent (io.quarkus.runtime.StartupEvent)7 CustomResourceDefinitionBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder)4 SerializedEntandoResource (org.entando.kubernetes.controller.spi.client.SerializedEntandoResource)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)3 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)3 ProvidedCapability (org.entando.kubernetes.model.capability.ProvidedCapability)3 ProvidedCapabilityBuilder (org.entando.kubernetes.model.capability.ProvidedCapabilityBuilder)3 CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)2 CustomResourceDefinitionVersion (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersion)2 CustomResourceDefinitionVersionBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersionBuilder)2 CustomResourceSubresourceStatus (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceSubresourceStatus)2 KafkaBridge (io.strimzi.api.kafka.model.KafkaBridge)2 KafkaConnect (io.strimzi.api.kafka.model.KafkaConnect)2