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
*
* @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
}
}
}
}
......
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment