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

Add pullPolicy configuration for image patcher

parent 5a943316
No related branches found
No related tags found
No related merge requests found
Pipeline #15855 passed
...@@ -10,23 +10,32 @@ import io.fabric8.kubernetes.api.model.apps.StatefulSet ...@@ -10,23 +10,32 @@ import io.fabric8.kubernetes.api.model.apps.StatefulSet
* *
* @param container Container to be patched. * @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 { override fun patchSingleResource(resource: HasMetadata, value: String): HasMetadata {
when (resource) { when (resource) {
is Deployment -> { is Deployment -> {
resource.spec.template.spec.containers.filter { it.name == container }.forEach { resource.spec.template.spec.containers.filter { it.name == container }.forEach {
it.image = value it.image = value
if (pullPolicy != null) {
it.imagePullPolicy = pullPolicy
}
} }
} }
is StatefulSet -> { is StatefulSet -> {
resource.spec.template.spec.containers.filter { it.name == container }.forEach { resource.spec.template.spec.containers.filter { it.name == container }.forEach {
it.image = value it.image = value
if (pullPolicy != null) {
it.imagePullPolicy = pullPolicy
}
} }
} }
is Pod -> { is Pod -> {
resource.spec.containers.filter { it.name == container }.forEach { resource.spec.containers.filter { it.name == container }.forEach {
it.image = value it.image = value
if (pullPolicy != null) {
it.imagePullPolicy = pullPolicy
}
} }
} }
} }
......
...@@ -75,7 +75,8 @@ class PatcherFactory { ...@@ -75,7 +75,8 @@ class PatcherFactory {
?: throwInvalid(patcher) ?: throwInvalid(patcher)
) )
"ImagePatcher" -> ImagePatcher( "ImagePatcher" -> ImagePatcher(
container = patcher.properties["container"] ?: throwInvalid(patcher) container = patcher.properties["container"] ?: throwInvalid(patcher),
pullPolicy = patcher.properties["pullPolicy"]
) )
"ConfigMapYamlPatcher" -> DecoratingPatcher( "ConfigMapYamlPatcher" -> DecoratingPatcher(
ConfigMapYamlPatcher( ConfigMapYamlPatcher(
......
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