Skip to content
Snippets Groups Projects
Commit 96117634 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

Add comments

parent ceeeb84f
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!101Add Service Monitor,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
......@@ -4,11 +4,26 @@ import io.fabric8.kubernetes.client.CustomResource
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
class K8sCustomResourceWrapper(private val map : Map<String,String>) : CustomResource() {
/**
* Fabric8 handles custom resources as plain HashMaps. These need to be handled differently than normal
* Kubernetes resources. The K8sCustomResourceWrapper class provides a wrapper to deploy and delete
* custom resources in a uniform way.
*
* @property map custom resource as plain hashmap
* @constructor Create empty K8s custom resource wrapper
*/
class K8sCustomResourceWrapper(private val map : Map<String,String>) : CustomResource() {
/**
* Deploy a custom resource
*
* @param client a namespaced Kubernetes client which are used to deploy the CR object.
*/
fun deploy(client : NamespacedKubernetesClient){
val kind = this.map["kind"]
// Search the CustomResourceDefinition to which the CR Object belongs.
// This should be exactly one if the CRD is registered for Kubernetes, zero otherwise.
val crds = client.apiextensions().v1beta1().customResourceDefinitions().list()
crds.items
.filter { crd -> crd.toString().contains("kind=$kind") }
......@@ -18,6 +33,11 @@ class K8sCustomResourceWrapper(private val map : Map<String,String>) : CustomRes
}
}
/**
* Delete a custom resource
*
* @param client a namespaced Kubernetes client which are used to delete the CR object.
*/
fun delete(client : NamespacedKubernetesClient){
val kind = this.map["kind"]
val metadata = this.map["metadata"] as HashMap<String,String>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment