Skip to content
Snippets Groups Projects
Commit 15128132 authored by Sören Henning's avatar Sören Henning
Browse files

Improve code readability

parent c2ce085d
No related branches found
No related tags found
No related merge requests found
Pipeline #6968 passed
...@@ -43,14 +43,14 @@ class ConfigMapResourceSet : ResourceSet, KubernetesResource { ...@@ -43,14 +43,14 @@ class ConfigMapResourceSet : ResourceSet, KubernetesResource {
resources resources
.map { .map {
Pair( Pair(
getKind(resource = it.value), getKind(resourceYaml = it.value),
it it
) )
} }
.map { .map {
Pair( Pair(
it.second.key, it.second.key, // filename
loader.loadK8sResource(it.first, it.second.value) loader.loadK8sResource(kind = it.first, resourceString = it.second.value) // K8s resource
) )
} }
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
...@@ -59,11 +59,11 @@ class ConfigMapResourceSet : ResourceSet, KubernetesResource { ...@@ -59,11 +59,11 @@ class ConfigMapResourceSet : ResourceSet, KubernetesResource {
} }
private fun getKind(resource: String): String { private fun getKind(resourceYaml: String): String {
val parser = YamlParserFromString() val parser = YamlParserFromString()
val resourceAsMap = parser.parse(resource, HashMap<String, String>()::class.java) val resourceAsMap = parser.parse(resourceYaml, HashMap<String, String>()::class.java)
return resourceAsMap?.get("kind") return resourceAsMap?.get("kind")
?: throw DeploymentFailedException("Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}") ?: throw DeploymentFailedException("Could not find 'kind' field of Kubernetes resource: ${resourceAsMap?.get("name")}")
} }
} }
\ No newline at end of file
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