diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/YamlLoader.kt b/theodolite-quarkus/src/main/kotlin/theodolite/YamlLoader.kt index ef3d16c32525a85f41ff8e8ee204e4101f4f3678..253710e39102d1d0b674d01b350ae6fb1d764e0f 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/YamlLoader.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/YamlLoader.kt @@ -1,12 +1,18 @@ package theodolite import io.fabric8.kubernetes.api.model.Service +import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging private val logger = KotlinLogging.logger {} class YamlLoader(client: NamespacedKubernetesClient) { - var client = client + lateinit var client: NamespacedKubernetesClient + + init{ + this.client = client + } + fun loadService(path: String): Service? { @@ -14,12 +20,31 @@ class YamlLoader(client: NamespacedKubernetesClient) { try { service = client.services().load(path).get() - }catch (e : Exception){ + } catch (e: Exception) { logger.info("You potentially misspeled the path: $path") logger.info("$e") } return service } -} + fun loadDeployment(path: String): Deployment? { + val deployment = loadGenericRessource(path,{x: String-> client.apps().deployments().load(x).get()}) + return deployment + } + + fun <T> loadGenericRessource(path: String, f: (String) -> T): T?{ + var service: T? = null + + try { + service = f(path) + } catch (e: Exception) { + logger.info("You potentially misspeled the path: $path") + logger.info("$e") + } + + return service + } + + } +}