use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project jkube-integration-tests by jkubeio.
the class CustomResourceApp method assertFrameworkCustomResourceDefinitionApplied.
protected void assertFrameworkCustomResourceDefinitionApplied(JKubeCase jKubeCase) {
CustomResourceDefinition crd = jKubeCase.getKubernetesClient().apiextensions().v1().customResourceDefinitions().withName(FRAMEWORKS_CRD).get();
assertThat(crd, notNullValue());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project stackgres by ongres.
the class CrdLoaderImplTest method scanDefinitions.
@Test
void scanDefinitions() {
List<CustomResourceDefinition> definitions = crdLoader.scanDefinitions();
assertEquals(crdFolder.list((file, name) -> name.endsWith(".yaml")).length, definitions.size());
List<CustomResourceDefinition> customResourceDefinitions = Arrays.stream(crdFolder.listFiles((file, name) -> name.endsWith(".yaml"))).map(file -> {
try {
return mapper.readValue(file, CustomResourceDefinition.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
definitions.forEach(def -> {
var customResourceDefinition = customResourceDefinitions.stream().filter(crd -> crd.getMetadata().getName().equals(def.getMetadata().getName())).findFirst().orElseThrow(() -> new RuntimeException("There is no definition with name " + def.getMetadata().getName()));
final CustomResourceDefinitionNames names = customResourceDefinition.getSpec().getNames();
assertEquals(names.getKind(), def.getSpec().getNames().getKind());
assertEquals(names.getSingular(), def.getSpec().getNames().getSingular());
});
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project stackgres by ongres.
the class WebhookConfiguratorImplTest method configureWebhook_shouldNotFail.
@Test
void configureWebhook_shouldNotFail() {
var definition = crdFinder.scanDefinitions().get(0);
final String certificate = StringUtil.generateRandom();
ArgumentCaptor<CustomResourceDefinition> crdCaptor = ArgumentCaptor.forClass(CustomResourceDefinition.class);
when(crdWriter.update(crdCaptor.capture())).thenReturn(definition);
webhookConfigurator.configureWebhook(definition.getMetadata().getName(), certificate);
CustomResourceDefinition crd = crdCaptor.getValue();
final CustomResourceDefinitionSpec spec = crd.getSpec();
final CustomResourceConversion conversion = spec.getConversion();
final WebhookClientConfig clientConfig = conversion.getWebhook().getClientConfig();
final ServiceReference service = clientConfig.getService();
assertEquals("Webhook", conversion.getStrategy());
assertEquals(OPERATOR_NAME, service.getName());
assertEquals(OPERATOR_NAMESPACE, service.getNamespace());
assertEquals("/stackgres/conversion/" + definition.getSpec().getNames().getSingular(), service.getPath());
assertEquals(certificate, clientConfig.getCaBundle());
assertFalse(spec.getPreserveUnknownFields());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project stackgres by ongres.
the class KubernetesServerSupplier method get.
@Override
public synchronized KubernetesServer get() {
if (server == null) {
server = new KubernetesServer(true, true);
server.before();
final NamespacedKubernetesClient client = server.getClient();
File file = CrdUtils.getCrdsFolder();
for (File crdFile : Optional.ofNullable(file.listFiles()).orElse(new File[0])) {
if (!crdFile.getName().endsWith(".yaml")) {
continue;
}
CustomResourceDefinition crd = client.apiextensions().v1().customResourceDefinitions().load(crdFile).get();
client.apiextensions().v1().customResourceDefinitions().create(crd);
}
}
return server;
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project stackgres by ongres.
the class CrdMatchTest method customResourcesYamlMetadataName_ShouldMatchWithNameInJavaDefinition.
@Test
void customResourcesYamlMetadataName_ShouldMatchWithNameInJavaDefinition() throws IOException {
withEveryYaml(crdTree -> {
JsonNode metadataName = crdTree.get("metadata").get("name");
CustomResourceDefinition definition = getDefinition(crdTree);
assertEquals(metadataName.asText(), definition.getMetadata().getName());
Class<? extends CustomResource> clazz = getCustomResourceClass(crdTree);
String name = CustomResource.getCRDName(clazz);
assertEquals(metadataName.asText(), name, "Kind : " + HasMetadata.getKind(clazz));
});
}
Aggregations