diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CustomRessourceTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CustomRessourceTest.kt index 81de3b73b3875da54b973b5e1aa2407949f9dd9b..b3ea2c01feaef6a274dbc3bb9656f50db34d2355 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/CustomRessourceTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CustomRessourceTest.kt @@ -12,7 +12,9 @@ import io.fabric8.kubernetes.client.CustomResource import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.internal.KubernetesDeserializer +import theodolite.util.YamlParser import java.io.File +import java.io.IOException import javax.json.Json @@ -81,4 +83,22 @@ class CustomRessourceTest { println(crd) } + + @Test + fun testTypelessAPI() { + try { + DefaultKubernetesClient().use { client -> + val svmAsMap = YamlParser().parse(path + "uc1-service-monitor.yaml", HashMap<String, String>()::class.java) + val kind = svmAsMap?.get("kind") + val crds = client.apiextensions().v1beta1().customResourceDefinitions().list() + crds.items + .filter { crd -> crd.toString().contains("kind=$kind") } // the filtered list should contain exactly 1 element, iff the CRD is known. TODO("Check if there is a case in which the list contains more than 1 element") + .map { crd -> CustomResourceDefinitionContext.fromCrd(crd)} + .forEach {context -> client.customResource(context).createOrReplace("default", svmAsMap as Map<String, Any>?)} + + } + } catch (e: IOException) { + e.printStackTrace() + } + } } \ No newline at end of file