use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project kubernetes-client by fabric8io.
the class V1CustomResourceDefinitionTest method testCreate.
@Test
void testCreate() {
server.expect().post().withPath("/apis/apiextensions.k8s.io/v1/customresourcedefinitions").andReturn(HttpURLConnection.HTTP_OK, customResourceDefinition).once();
CustomResourceDefinition crd = client.apiextensions().v1().customResourceDefinitions().createOrReplace(customResourceDefinition);
assertNotNull(crd);
assertEquals("sparkclusters.radanalytics.io", crd.getMetadata().getName());
// Assertion to test behavior in https://github.com/fabric8io/kubernetes-client/issues/1486
assertNull(crd.getSpec().getVersions().get(0).getSchema().getOpenAPIV3Schema().getDependencies());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project yakc by manusa.
the class CustomResourceDefinitionV1IT method deleteCustomResourceDefinition.
@Test
@DisplayName("deleteCustomResourceDefinition, should delete existing CustomResourceDefinition")
void deleteCustomResourceDefinition() throws IOException {
// When
final CustomResourceDefinition result = KC.create(ApiextensionsV1Api.class).deleteCustomResourceDefinition(customResourceDefinitionName).get(// Swagger/OpenAPI is wrong
CustomResourceDefinition.class);
// Then
assertThat(result).isNotNull();
assertThat(result.getMetadata().getDeletionTimestamp()).isNotNull();
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition 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());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.
the class CrudTest method assertContext.
private void assertContext(final CustomResourceDefinition customResourceDefinition, final CustomResourceDefinitionContext customResourceDefinitionContext) {
String version = null;
for (CustomResourceDefinitionVersion v : customResourceDefinition.getSpec().getVersions()) {
if (v.getName().equals(customResourceDefinitionContext.getVersion())) {
version = v.getName();
}
}
assertEquals(String.format("%s.%s", customResourceDefinition.getSpec().getNames().getPlural(), customResourceDefinition.getSpec().getGroup()), customResourceDefinitionContext.getName());
assertEquals(customResourceDefinition.getSpec().getGroup(), customResourceDefinitionContext.getGroup());
assertEquals(customResourceDefinition.getSpec().getScope(), customResourceDefinitionContext.getScope());
assertEquals(customResourceDefinition.getSpec().getNames().getPlural(), customResourceDefinitionContext.getPlural());
assertEquals(customResourceDefinition.getSpec().getVersions().get(0).getName(), customResourceDefinitionContext.getVersion());
assertEquals(customResourceDefinition.getSpec().getNames().getKind(), customResourceDefinitionContext.getKind());
assertEquals(version, customResourceDefinitionContext.getVersion());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition 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());
}
Aggregations