Search in sources :

Example 16 with CustomResourceDefinitionBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder in project kubernetes-client by fabric8io.

the class CustomResourceDefinitionIT method update.

@Test
public void update() {
    // When
    final CustomResourceDefinition result = client.apiextensions().v1().customResourceDefinitions().withName(name).edit(c -> new CustomResourceDefinitionBuilder(c).editSpec().editOrNewNames().addToShortNames("its").endNames().endSpec().build());
    // Then
    assertThat(result.getSpec().getNames().getShortNames()).containsExactlyInAnyOrder("its");
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) Test(org.junit.Test)

Example 17 with CustomResourceDefinitionBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder in project kubernetes-client by fabric8io.

the class CustomResourceDefinitionContext method v1beta1CRDFromCustomResourceType.

@SuppressWarnings("rawtypes")
public static CustomResourceDefinitionBuilder v1beta1CRDFromCustomResourceType(Class<? extends CustomResource> customResource) {
    try {
        final CustomResource instance = customResource.getDeclaredConstructor().newInstance();
        final String version = instance.getVersion();
        return new CustomResourceDefinitionBuilder().withNewMetadata().withName(instance.getCRDName()).endMetadata().withNewSpec().withGroup(instance.getGroup()).withVersion(// also set version to the first (and only) versions item
        version).addNewVersion().withName(version).withServed(instance.isServed()).withStorage(instance.isStorage()).endVersion().withScope(instance.getScope()).withNewNames().withKind(instance.getKind()).withPlural(instance.getPlural()).withSingular(instance.getSingular()).endNames().endSpec();
    } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
        throw KubernetesClientException.launderThrowable(e);
    }
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder) CustomResource(io.fabric8.kubernetes.client.CustomResource) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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