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");
}
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);
}
}
Aggregations