Search in sources :

Example 1 with DomainSpecCertificate

use of com.enonic.kubernetes.client.v1.domain.DomainSpecCertificate in project xp-operator by enonic.

the class CrudTest method v1Domain.

@Test
void v1Domain() throws IOException, URISyntaxException {
    EnonicKubernetesClient client = new DefaultEnonicKubernetesClient(server.getClient());
    // Create crd
    CustomResourceDefinition crd = client.k8s().apiextensions().v1().customResourceDefinitions().load(getClass().getResourceAsStream("/crds/domains.yaml")).get();
    client.k8s().apiextensions().v1().customResourceDefinitions().create(crd);
    // Create crd client
    MixedOperation<Domain, Domain.DomainList, Resource<Domain>> crdClient = client.enonic().v1().crds().domains();
    // Create resource
    ObjectMetaBuilder metadataBuilder = new ObjectMetaBuilder().withName("test-name");
    Domain resource = new Domain().withSpec(new DomainSpec().withHost("test.host.com").withCdn(true).withDnsRecord(true).withDomainSpecCertificate(new DomainSpecCertificate().withAuthority(DomainSpecCertificate.Authority.SELF_SIGNED)));
    resource.setMetadata(metadataBuilder.build());
    assertCrd(resource, "/crud-domain.json");
    // Send to server
    crdClient.create(resource);
    // List
    Domain.DomainList list = crdClient.list();
    assertNotNull(list);
    assertEquals(1, list.getItems().size());
    assertEqualsCrd(resource, list.getItems().get(0));
    // Fetch from server
    Domain get = crdClient.withName("test-name").get();
    assertNotNull(get);
    assertEquals(resource, get);
    // Test put
    resource.setMetadata(metadataBuilder.withLabels(Map.of("test2", "test2")).build());
    resource.setSpec(resource.getSpec().withHost("new.host.com"));
    crdClient.withName("test-name").replace(resource);
    // Delete from server
    assertTrue(crdClient.withName("test-name").delete());
}
Also used : DomainSpec(com.enonic.kubernetes.client.v1.domain.DomainSpec) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) Resource(io.fabric8.kubernetes.client.dsl.Resource) CustomResource(io.fabric8.kubernetes.client.CustomResource) DomainSpecCertificate(com.enonic.kubernetes.client.v1.domain.DomainSpecCertificate) Domain(com.enonic.kubernetes.client.v1.domain.Domain) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

Domain (com.enonic.kubernetes.client.v1.domain.Domain)1 DomainSpec (com.enonic.kubernetes.client.v1.domain.DomainSpec)1 DomainSpecCertificate (com.enonic.kubernetes.client.v1.domain.DomainSpecCertificate)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