Search in sources :

Example 91 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project stackgres by ongres.

the class CrdMatchTest method customResourcesYamlDefinitionsPlural_ShouldMatchWithPluralInJavaDefinition.

@Test
void customResourcesYamlDefinitionsPlural_ShouldMatchWithPluralInJavaDefinition() throws IOException {
    withEveryYaml(crdTree -> {
        JsonNode crdNames = crdTree.get("spec").get("names");
        String declaredPlural = crdNames.get("plural").asText();
        CustomResourceDefinition definition = getDefinition(crdTree);
        assertEquals(declaredPlural, definition.getSpec().getNames().getPlural());
        Class<? extends CustomResource> clazz = getCustomResourceClass(crdTree);
        String plural = HasMetadata.getPlural(clazz);
        assertEquals(declaredPlural, plural, "Kind : " + HasMetadata.getKind(clazz));
    });
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.jupiter.api.Test)

Example 92 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project stackgres by ongres.

the class CrdMatchTest method customResourcesYamlNamespaced_ShouldMatchWithNamespacedInJavaDefinition.

@Test
void customResourcesYamlNamespaced_ShouldMatchWithNamespacedInJavaDefinition() throws IOException {
    withEveryYaml(crdTree -> {
        JsonNode metadataName = crdTree.get("spec").get("scope");
        CustomResourceDefinition definition = getDefinition(crdTree);
        assertEquals(metadataName.asText(), definition.getSpec().getScope());
    });
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.jupiter.api.Test)

Example 93 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.

the class SchemaTest method v1Xp7App.

@Test
void v1Xp7App() throws IOException {
    CustomResourceDefinition customResourceDefinition = loadCRD("/crds/apps.yaml");
    JSONSchemaProps schema = loadSchema("/schema/v1/xp7app/xp7App.json");
    assertSchema(getSchemaVersion(customResourceDefinition, "v1"), schema);
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) JSONSchemaProps(io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps) Test(org.junit.jupiter.api.Test)

Example 94 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.

the class SchemaTest method v1Xp7Deployment.

@Test
void v1Xp7Deployment() throws IOException {
    CustomResourceDefinition customResourceDefinition = loadCRD("/crds/deployments.yaml");
    JSONSchemaProps schema = loadSchema("/schema/v1/xp7deployment/xp7Deployment.json");
    assertSchema(getSchemaVersion(customResourceDefinition, "v1"), schema);
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) JSONSchemaProps(io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps) Test(org.junit.jupiter.api.Test)

Example 95 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.

the class CrudTest method v1Xp7App.

@Test
void v1Xp7App() throws IOException, URISyntaxException {
    EnonicKubernetesClient client = new DefaultEnonicKubernetesClient(server.getClient());
    CustomResourceDefinition crd = client.k8s().apiextensions().v1().customResourceDefinitions().load(getClass().getResourceAsStream("/crds/apps.yaml")).get();
    client.k8s().apiextensions().v1().customResourceDefinitions().create(crd);
    // Create crd client
    MixedOperation<Xp7App, Xp7App.Xp7AppList, Resource<Xp7App>> crdClient = client.enonic().v1().crds().xp7apps();
    // Create resource
    ObjectMetaBuilder metadataBuilder = new ObjectMetaBuilder().withNamespace("test").withName("test-name");
    Xp7App resource = new Xp7App().withSpec(new Xp7AppSpec().withUrl("test"));
    resource.setMetadata(metadataBuilder.build());
    assertCrd(resource, "/crud-app.json");
    // Send to server
    crdClient.create(resource);
    // List
    Xp7App.Xp7AppList list = crdClient.list();
    assertNotNull(list);
    assertEquals(1, list.getItems().size());
    assertEqualsCrd(resource, list.getItems().get(0));
    // Fetch from server
    Xp7App get = crdClient.withName("test-name").get();
    assertNotNull(get);
    assertEqualsCrd(resource, get);
    // Test put
    resource.setMetadata(metadataBuilder.withLabels(Map.of("test2", "test2")).build());
    resource.setSpec(new Xp7AppSpec().withUrl("test"));
    crdClient.withName("test-name").replace(resource);
    // Delete from server
    assertTrue(crdClient.withName("test-name").delete());
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) Resource(io.fabric8.kubernetes.client.dsl.Resource) CustomResource(io.fabric8.kubernetes.client.CustomResource) Xp7AppSpec(com.enonic.kubernetes.client.v1.xp7app.Xp7AppSpec) Xp7App(com.enonic.kubernetes.client.v1.xp7app.Xp7App) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)60 Test (org.junit.jupiter.api.Test)49 CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition)30 Description (io.qameta.allure.Description)12 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)11 IOException (java.io.IOException)11 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)10 CustomResourceDefinitionBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder)10 Resource (io.fabric8.kubernetes.client.dsl.Resource)10 CustomResourceDefinitionContext (io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext)10 ArrayList (java.util.ArrayList)10 BeforeEach (org.junit.jupiter.api.BeforeEach)10 CustomResource (io.fabric8.kubernetes.client.CustomResource)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)7 StartupEvent (io.quarkus.runtime.StartupEvent)7 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)6 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)6 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)6