From f9b368103a29b9868fca60894deca27007d1242d Mon Sep 17 00:00:00 2001 From: Oleg Zhurakivskyy Date: Thu, 12 Nov 2020 14:01:34 +0000 Subject: [PATCH] scripts: Add set-image-pull-policy.sh script --- scripts/set-image-pull-policy.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/set-image-pull-policy.sh diff --git a/scripts/set-image-pull-policy.sh b/scripts/set-image-pull-policy.sh new file mode 100755 index 00000000..d801823d --- /dev/null +++ b/scripts/set-image-pull-policy.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# Copyright 2019-2020 Intel Corporation. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Invoke this script with a imagePullPolicy as parameter +# and it will update all hard-coded imagePullPolicy +# in the deployments, demos and controller code +# +# Adapted from https://github.com/intel/pmem-csi/ + +if [[ $# != 1 ]] || [[ "$1" == "?" ]] || [[ "$1" == "--help" ]] || + [[ ! $1 =~ IfNotPresent|Always ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +IMAGE_PULL_POLICY=$1 + +echo IMAGE_PULL_POLICY=$IMAGE_PULL_POLICY + +sed -i -e "s;\(imagePullPolicy\:\ \).*;\1$IMAGE_PULL_POLICY;" $(git grep -l 'imagePullPolicy' deployments/*.yaml demo/*.yaml) + +sed -i -e "s;\(ImagePullPolicy\:\ \).*;\1\"$IMAGE_PULL_POLICY\",;" $(git grep -l 'ImagePullPolicy' pkg/controllers/*/*.go)