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

Minor code quality fixes

parent c4283e7b
No related branches found
No related tags found
No related merge requests found
Pipeline #6138 failed
...@@ -12,7 +12,7 @@ import java.lang.IllegalArgumentException ...@@ -12,7 +12,7 @@ import java.lang.IllegalArgumentException
@RegisterForReflection @RegisterForReflection
@JsonDeserialize @JsonDeserialize
class ConfigMapResourceSet: ResourceSet, KubernetesResource { class ConfigMapResourceSet : ResourceSet, KubernetesResource {
lateinit var name: String lateinit var name: String
lateinit var files: List<String> // load all files, iff files is not set lateinit var files: List<String> // load all files, iff files is not set
...@@ -31,7 +31,7 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource { ...@@ -31,7 +31,7 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource {
throw DeploymentFailedException("Cannot find or read ConfigMap with name '$name'.", e) throw DeploymentFailedException("Cannot find or read ConfigMap with name '$name'.", e)
} }
if (::files.isInitialized){ if (::files.isInitialized) {
resources = resources.filter { files.contains(it.key) } resources = resources.filter { files.contains(it.key) }
if (resources.size != files.size) { if (resources.size != files.size) {
...@@ -41,15 +41,20 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource { ...@@ -41,15 +41,20 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource {
return try { return try {
resources resources
.map { Pair( .map {
getKind(resource = it.value), Pair(
it) } getKind(resource = it.value),
it
)
}
.map { .map {
Pair( Pair(
it.second.key, it.second.key,
loader.loadK8sResource(it.first, it.second.value)) } loader.loadK8sResource(it.first, it.second.value)
)
}
} catch (e: IllegalArgumentException) { } 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 { ...@@ -58,10 +63,7 @@ class ConfigMapResourceSet: ResourceSet, KubernetesResource {
val parser = YamlParserFromString() val parser = YamlParserFromString()
val resourceAsMap = parser.parse(resource, HashMap<String, String>()::class.java) val resourceAsMap = parser.parse(resource, HashMap<String, String>()::class.java)
return try { return resourceAsMap?.get("kind")
resourceAsMap?.get("kind") !! ?: throw DeploymentFailedException("Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}")
} catch (e: NullPointerException) {
throw DeploymentFailedException( "Could not find field kind of Kubernetes resource: ${resourceAsMap?.get("name")}", e)
}
} }
} }
\ 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