From e264a1ba8afa5872836dd017925ff3278f4a0a1c Mon Sep 17 00:00:00 2001
From: Simon Ehrenstein <simon.ehrenstein@gmail.com>
Date: Mon, 15 Mar 2021 08:30:12 +0100
Subject: [PATCH] Add SchedulerNamePatcher for Deployments

---
 .../main/kotlin/theodolite/patcher/PatcherManager.kt |  1 +
 .../theodolite/patcher/SchedulerNamePatcher.kt       | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt

diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt
index 5557eb4b9..a0e21b998 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherManager.kt
@@ -25,6 +25,7 @@ class PatcherManager {
                 patcherDefinition.container,
                 patcherDefinition.variableName
             )
+            "SchedulerNamePatcher" -> SchedulerNamePatcher(resource)
             else -> throw IllegalArgumentException("Patcher type ${patcherDefinition.type} not found")
         }
     }
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt
new file mode 100644
index 000000000..88d9a978f
--- /dev/null
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt
@@ -0,0 +1,12 @@
+package theodolite.patcher
+
+import io.fabric8.kubernetes.api.model.KubernetesResource
+import io.fabric8.kubernetes.api.model.apps.Deployment
+
+class SchedulerNamePatcher(private val k8sResource: KubernetesResource): Patcher {
+    override fun <String> patch(value: String) {
+        if (k8sResource is Deployment) {
+            k8sResource.spec.template.spec.schedulerName = value as kotlin.String;
+        }
+    }
+}
\ No newline at end of file
-- 
GitLab