diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt index 9ca6570ff56a673ffde144b68d3f3d9c90913ef9..58dd95e9d582911a209a1173a0f58f8fac729c86 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt @@ -1,6 +1,7 @@ package theodolite.patcher import io.fabric8.kubernetes.api.model.KubernetesResource +import theodolite.util.DeploymentFailedException import theodolite.util.PatcherDefinition /** @@ -27,7 +28,9 @@ class PatcherFactory { k8sResources: List<Pair<String, KubernetesResource>> ): Patcher { val resource = - k8sResources.filter { it.first == patcherDefinition.resource }.map { resource -> resource.second }[0] + k8sResources.filter { it.first == patcherDefinition.resource }.map { resource -> resource.second }.firstOrNull() + ?: throw DeploymentFailedException("Could not find resource ${patcherDefinition.resource}") + return when (patcherDefinition.type) { "ReplicaPatcher" -> ReplicaPatcher(resource) "NumNestedGroupsLoadGeneratorReplicaPatcher" -> NumNestedGroupsLoadGeneratorReplicaPatcher(resource) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/DeploymentFailedException.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/DeploymentFailedException.kt new file mode 100644 index 0000000000000000000000000000000000000000..0e276d7de4e205a75eb309a71a793e70f7565ea4 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/DeploymentFailedException.kt @@ -0,0 +1,5 @@ +package theodolite.util + + +class DeploymentFailedException(message:String): Exception(message) { +} \ No newline at end of file