Skip to content
Snippets Groups Projects
Commit becfb5e9 authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Refactor

parent e4646677
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus,!78Resolve "Implement Quarkus/Kotlin protype"
...@@ -4,7 +4,7 @@ import io.fabric8.kubernetes.api.model.Service ...@@ -4,7 +4,7 @@ import io.fabric8.kubernetes.api.model.Service
import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient
class ServiceManager(client: NamespacedKubernetesClient) { class ServiceManager(client: NamespacedKubernetesClient) {
lateinit var client: NamespacedKubernetesClient var client: NamespacedKubernetesClient
init { init {
this.client = client this.client = client
......
...@@ -9,29 +9,49 @@ import mu.KotlinLogging ...@@ -9,29 +9,49 @@ import mu.KotlinLogging
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
class YamlLoader(client: NamespacedKubernetesClient) { class YamlLoader(client: NamespacedKubernetesClient) {
lateinit var client: NamespacedKubernetesClient var client: NamespacedKubernetesClient
init { init {
this.client = client this.client = client
} }
/**
* Parses a Service from a servive yaml
* @param path of the yaml file
* @return service from fabric8
*/
fun loadService(path: String): Service? { fun loadService(path: String): Service? {
val service = loadGenericRessource(path, { x: String -> client.services().load(x).get() }) val service = loadGenericRessource(path, { x: String -> client.services().load(x).get() })
return service return service
} }
/**
* Parses a Deployment from a Deployment yaml
* @param path of the yaml file
* @return Deployment from fabric8
*/
fun loadDeployment(path: String): Deployment? { fun loadDeployment(path: String): Deployment? {
val deployment = loadGenericRessource(path, { x: String -> client.apps().deployments().load(x).get() }) val deployment = loadGenericRessource(path, { x: String -> client.apps().deployments().load(x).get() })
return deployment return deployment
} }
/**
* Parses a ConfigMap from a ConfigMap yaml
* @param path of the yaml file
* @return ConfigMap from fabric8
*/
fun loadConfigmap(path: String): ConfigMap? { fun loadConfigmap(path: String): ConfigMap? {
val configMap = loadGenericRessource(path, { x: String -> client.configMaps().load(x).get() }) val configMap = loadGenericRessource(path, { x: String -> client.configMaps().load(x).get() })
return configMap return configMap
} }
fun <T> loadGenericRessource(path: String, f: (String) -> T): T? { /**
* Generic helper function to load a resource.
* @param path of the resource
* @param f fuction that shall be applied to the resource.
*/
private fun <T> loadGenericRessource(path: String, f: (String) -> T): T? {
var resource: T? = null var resource: T? = null
try { try {
......
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