Skip to content
Snippets Groups Projects
Commit 1415ee4f authored by Sören Henning's avatar Sören Henning
Browse files

Remove CustomResourceWrapper class

parent 0fca986f
No related branches found
No related tags found
1 merge request!257Allow Theodolite to deploy arbitrary resources
Pipeline #7077 passed
package theodolite.k8s
import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
import mu.KotlinLogging
private val logger = KotlinLogging.logger {}
@Deprecated("")
class CustomResourceWrapper(
val crAsMap: Map<String, String>,
private val context: CustomResourceDefinitionContext
) : KubernetesResource {
/**
* Deploy a service monitor
*
* @param client a namespaced Kubernetes client which are used to deploy the CR object.
*
* @throws java.io.IOException if the resource could not be deployed.
*/
fun deploy(client: NamespacedKubernetesClient) {
client.customResource(this.context)
.createOrReplace(client.configuration.namespace, this.crAsMap as Map<String, Any>)
}
/**
* Delete a service monitor
*
* @param client a namespaced Kubernetes client which are used to delete the CR object.
*/
fun delete(client: NamespacedKubernetesClient) {
try {
client.customResource(this.context)
.delete(client.configuration.namespace, this.getName())
} catch (e: Exception) {
logger.warn { "Could not delete custom resource" }
}
}
/**
* @throws NullPointerException if name or metadata is null
*/
fun getName(): String {
val metadataAsMap = this.crAsMap["metadata"]!! as Map<String, String>
return metadataAsMap["name"]!!
}
}
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