From 8f4ab83b0e3ac4ad08f1d2e7c8f2fe74b3aca754 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Mon, 12 Jul 2021 13:03:42 +0200 Subject: [PATCH] clean up, small enhancements --- .../kotlin/theodolite/k8s/CustomResourceWrapper.kt | 7 +------ .../main/kotlin/theodolite/k8s/K8sResourceLoader.kt | 12 ++++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt index 31a95be04..f26220162 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt @@ -7,7 +7,7 @@ import mu.KotlinLogging private val logger = KotlinLogging.logger {} -class CustomResourceWrapper(val crAsMap: Map<String, String>, private val context: CustomResourceDefinitionContext) : KubernetesResource { +class CustomResourceWrapper(private val crAsMap: Map<String, String>, private val context: CustomResourceDefinitionContext) : KubernetesResource { /** * Deploy a service monitor * @@ -41,9 +41,4 @@ class CustomResourceWrapper(val crAsMap: Map<String, String>, private val contex val metadataAsMap = this.crAsMap["metadata"]!! as Map<String, String> return metadataAsMap["name"]!! } - - fun getLabels(): Map<String, String>{ - val metadataAsMap = this.crAsMap["metadata"]!! as Map<String, String> - return metadataAsMap["labels"]!! as Map<String, String> - } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt index ab4bef3ea..d231c70c0 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt @@ -24,7 +24,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return Service from fabric8 */ private fun loadService(path: String): Service { - return loadGenericResource(path) { x: String -> client.services().load(x).get() } + return loadGenericResource(path) {client.services().load(it).get() } } @@ -83,7 +83,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return Deployment from fabric8 */ private fun loadDeployment(path: String): Deployment { - return loadGenericResource(path) { x: String -> client.apps().deployments().load(x).get() } + return loadGenericResource(path) {client.apps().deployments().load(it).get() } } /** @@ -92,7 +92,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return ConfigMap from fabric8 */ private fun loadConfigmap(path: String): ConfigMap { - return loadGenericResource(path) { x: String -> client.configMaps().load(x).get() } + return loadGenericResource(path) {client.configMaps().load(it).get() } } /** @@ -101,7 +101,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { * @return StatefulSet from fabric8 */ private fun loadStatefulSet(path: String): KubernetesResource { - return loadGenericResource(path) { x: String -> client.apps().statefulSets().load(x).get() } + return loadGenericResource(path) {client.apps().statefulSets().load(it).get() } } @@ -117,7 +117,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { try { resource = f(path) } catch (e: Exception) { - logger.warn { "You potentially misspelled the path: $path" } + logger.warn { "You potentially misspelled the path: $path" } logger.warn { e } } @@ -146,7 +146,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { "Benchmark" -> loadBenchmark(path) else -> { logger.error { "Error during loading of unspecified resource Kind" } - throw java.lang.IllegalArgumentException("error while loading resource with kind: $kind") + throw IllegalArgumentException("error while loading resource with kind: $kind") } } } -- GitLab