From 9e71cec2865a2ef1baecef6540f0375081a334cc Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Tue, 23 Nov 2021 13:06:06 +0100 Subject: [PATCH] fix non null problems iff name is not set --- docs/crd-docu.md | 2 ++ theodolite/crd/crd-benchmark.yaml | 1 + .../theodolite/benchmark/KubernetesBenchmark.kt | 1 + .../kotlin/theodolite/benchmark/ResourceSets.kt | 14 ++++++++------ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/crd-docu.md b/docs/crd-docu.md index bb41474ce..ed569f7a7 100644 --- a/docs/crd-docu.md +++ b/docs/crd-docu.md @@ -117,6 +117,8 @@ Resource Types: <td>string</td> <td> This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.<br/> + <br/> + <i>Default</i>: <br/> </td> <td>false</td> </tr><tr> diff --git a/theodolite/crd/crd-benchmark.yaml b/theodolite/crd/crd-benchmark.yaml index d3c271665..5df23b6bf 100644 --- a/theodolite/crd/crd-benchmark.yaml +++ b/theodolite/crd/crd-benchmark.yaml @@ -25,6 +25,7 @@ spec: name: description: This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten. type: string + default: "" resourceTypes: description: A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object. type: array diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index cbdaab0d3..69eca6b6e 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -1,5 +1,6 @@ package theodolite.benchmark +import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.client.DefaultKubernetesClient diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt b/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt index 19c080809..ba4dc3adb 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/ResourceSets.kt @@ -14,16 +14,18 @@ import theodolite.util.DeploymentFailedException @JsonInclude(JsonInclude.Include.NON_NULL) class ResourceSets: KubernetesResource { @JsonProperty("configMap") - lateinit var configMap: ConfigMapResourceSet + @JsonInclude(JsonInclude.Include.NON_NULL) + var configMap: ConfigMapResourceSet? = null @JsonProperty("fileSystem") - lateinit var fileSystem: FileSystemResourceSet + @JsonInclude(JsonInclude.Include.NON_NULL) + var fileSystem: FileSystemResourceSet? = null fun loadResourceSet(client: NamespacedKubernetesClient): Collection<Pair<String, KubernetesResource>> { - return if (::configMap.isInitialized) { - configMap.getResourceSet(client= client) - } else if (::fileSystem.isInitialized) { - fileSystem.getResourceSet(client= client ) + return if (::configMap != null) { + configMap?.getResourceSet(client= client) !! + } else if (::fileSystem != null) { + fileSystem?.getResourceSet(client= client ) !! } else { throw DeploymentFailedException("could not load resourceSet.") } -- GitLab