Search in sources :

Example 1 with Xp7ConfigSpec

use of com.enonic.kubernetes.client.v1.xp7config.Xp7ConfigSpec in project xp-operator by enonic.

the class CrudTest method v1xp7Config.

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

Aggregations

Xp7Config (com.enonic.kubernetes.client.v1.xp7config.Xp7Config)1 Xp7ConfigSpec (com.enonic.kubernetes.client.v1.xp7config.Xp7ConfigSpec)1 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)1 CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)1 CustomResource (io.fabric8.kubernetes.client.CustomResource)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 Test (org.junit.jupiter.api.Test)1