diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ConfigMapResourceSet.kt b/theodolite/src/main/kotlin/theodolite/benchmark/ConfigMapResourceSet.kt index 27e3206ad7b60d61cab94caaef8a3279d834fe65..d50caec12d664886bcd4411df80909ff875d8ec9 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/ConfigMapResourceSet.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/ConfigMapResourceSet.kt @@ -12,7 +12,7 @@ import java.lang.IllegalArgumentException @RegisterForReflection @JsonDeserialize -class ConfigMapResourceSet: ResourceSet, KubernetesResource { +class ConfigMapResourceSet : ResourceSet, KubernetesResource { lateinit var name: String lateinit var files: List<String> // load all files, iff files is not set @@ -31,7 +31,7 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource { throw DeploymentFailedException("Cannot find or read ConfigMap with name '$name'.", e) } - if (::files.isInitialized){ + if (::files.isInitialized) { resources = resources.filter { files.contains(it.key) } if (resources.size != files.size) { @@ -41,15 +41,20 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource { return try { resources - .map { Pair( - getKind(resource = it.value), - it) } + .map { + Pair( + getKind(resource = it.value), + it + ) + } .map { Pair( it.second.key, - loader.loadK8sResource(it.first, it.second.value)) } + loader.loadK8sResource(it.first, it.second.value) + ) + } } catch (e: IllegalArgumentException) { - throw DeploymentFailedException("Can not create resource set from specified configmap", e) + throw DeploymentFailedException("Cannot create resource set from specified ConfigMap", e) } } @@ -58,10 +63,7 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource { val parser = YamlParserFromString() val resourceAsMap = parser.parse(resource, HashMap<String, String>()::class.java) - return try { - resourceAsMap?.get("kind") !! - } catch (e: NullPointerException) { - throw DeploymentFailedException( "Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}", e) - } + return resourceAsMap?.get("kind") + ?: throw DeploymentFailedException("Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}") } } \ No newline at end of file