diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcher.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcher.kt index ce23aaa04..ea1b61609 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcher.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/ImagePatcher.kt @@ -10,23 +10,32 @@ import io.fabric8.kubernetes.api.model.apps.StatefulSet * * @param container Container to be patched. */ -class ImagePatcher(private val container: String) : AbstractStringPatcher() { +class ImagePatcher(private val container: String, private val pullPolicy: String? = null) : AbstractStringPatcher() { override fun patchSingleResource(resource: HasMetadata, value: String): HasMetadata { when (resource) { is Deployment -> { resource.spec.template.spec.containers.filter { it.name == container }.forEach { it.image = value + if (pullPolicy != null) { + it.imagePullPolicy = pullPolicy + } } } is StatefulSet -> { resource.spec.template.spec.containers.filter { it.name == container }.forEach { it.image = value + if (pullPolicy != null) { + it.imagePullPolicy = pullPolicy + } } } is Pod -> { resource.spec.containers.filter { it.name == container }.forEach { it.image = value + if (pullPolicy != null) { + it.imagePullPolicy = pullPolicy + } } } } diff --git a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherFactory.kt b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherFactory.kt index d996b5450..7d47dc8b6 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherFactory.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/kubernetes/patcher/PatcherFactory.kt @@ -75,7 +75,8 @@ class PatcherFactory { ?: throwInvalid(patcher) ) "ImagePatcher" -> ImagePatcher( - container = patcher.properties["container"] ?: throwInvalid(patcher) + container = patcher.properties["container"] ?: throwInvalid(patcher), + pullPolicy = patcher.properties["pullPolicy"] ) "ConfigMapYamlPatcher" -> DecoratingPatcher( ConfigMapYamlPatcher(