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

clean up, small enhancements

parent c3acad6c
No related branches found
No related tags found
1 merge request!168Enhance Code Quality
...@@ -7,7 +7,7 @@ import mu.KotlinLogging ...@@ -7,7 +7,7 @@ import mu.KotlinLogging
private val logger = KotlinLogging.logger {} 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 * Deploy a service monitor
* *
...@@ -41,9 +41,4 @@ class CustomResourceWrapper(val crAsMap: Map<String, String>, private val contex ...@@ -41,9 +41,4 @@ class CustomResourceWrapper(val crAsMap: Map<String, String>, private val contex
val metadataAsMap = this.crAsMap["metadata"]!! as Map<String, String> val metadataAsMap = this.crAsMap["metadata"]!! as Map<String, String>
return metadataAsMap["name"]!! return metadataAsMap["name"]!!
} }
fun getLabels(): Map<String, String>{
val metadataAsMap = this.crAsMap["metadata"]!! as Map<String, String>
return metadataAsMap["labels"]!! as Map<String, String>
}
} }
...@@ -24,7 +24,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { ...@@ -24,7 +24,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
* @return Service from fabric8 * @return Service from fabric8
*/ */
private fun loadService(path: String): Service { 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) { ...@@ -83,7 +83,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
* @return Deployment from fabric8 * @return Deployment from fabric8
*/ */
private fun loadDeployment(path: String): Deployment { 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) { ...@@ -92,7 +92,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
* @return ConfigMap from fabric8 * @return ConfigMap from fabric8
*/ */
private fun loadConfigmap(path: String): ConfigMap { 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) { ...@@ -101,7 +101,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
* @return StatefulSet from fabric8 * @return StatefulSet from fabric8
*/ */
private fun loadStatefulSet(path: String): KubernetesResource { 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) { ...@@ -117,7 +117,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
try { try {
resource = f(path) resource = f(path)
} catch (e: Exception) { } catch (e: Exception) {
logger.warn { "You potentially misspelled the path: $path" } logger.warn { "You potentially misspelled the path: $path" }
logger.warn { e } logger.warn { e }
} }
...@@ -146,7 +146,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { ...@@ -146,7 +146,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
"Benchmark" -> loadBenchmark(path) "Benchmark" -> loadBenchmark(path)
else -> { else -> {
logger.error { "Error during loading of unspecified resource Kind" } 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")
} }
} }
} }
......
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