use of io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionNames 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.v1.CustomResourceDefinitionNames in project kubernetes-client by fabric8io.
the class CustomResourceDefinitionContextTest method v1beta1CRDFromCustomResourceType.
@Test
@DisplayName("v1beta1CRDFromCustomResourceType correctly generates CRD builder for v1beta1 version")
void v1beta1CRDFromCustomResourceType() {
final CustomResourceDefinition crd = CustomResourceDefinitionContext.v1beta1CRDFromCustomResourceType(Good.class).build();
final CustomResourceDefinitionSpec spec = crd.getSpec();
final CustomResourceDefinitionNames names = spec.getNames();
final String plural = "goods";
Assertions.assertEquals(plural, names.getPlural());
Assertions.assertEquals("good", names.getSingular());
Assertions.assertEquals("Good", names.getKind());
Assertions.assertEquals(plural + "." + Good.GROUP, crd.getMetadata().getName());
Assertions.assertEquals(Good.VERSION, spec.getVersion());
Assertions.assertEquals(Good.VERSION, spec.getVersions().get(0).getName());
}
Aggregations