summaryrefslogtreecommitdiffstats
path: root/kubernetes
diff options
context:
space:
mode:
authorGuillaume Lambert <guillaume.lambert@orange.com>2021-04-26 21:46:56 +0200
committerGuillaume Lambert <guillaume.lambert@orange.com>2021-05-17 14:35:43 +0200
commitba6e50fd66d06231ff96f9a9c9a4b25b91fa5623 (patch)
tree7363eb42829666842f6cd791b7f90a3fcbba0793 /kubernetes
parent8f41d3f2fe323433c84ee2ad4b49c49c59ba7996 (diff)
[COMMON] Fix condition bracket bashisms - step 1
pointed out by checkbashisms $ mycmd=$(tox -e checkbashisms | grep '(\[\[ foo \]\] should be \[ foo \])' | sed -e "s@^[^.]*\(.[^ ]*\) line \([0-9]*\) .*@sed -i '\2s/\\\[\\\[\\\( [^]]*\\\)\\\]\\\]/[\\\1]/g' \1;@") $ eval $mycmd plus fix manually quoting hells induced and bash specific regex and multi-conditions Issue-ID: OOM-2643 Signed-off-by: Guillaume Lambert <guillaume.lambert@orange.com> Change-Id: Ie7ca5b71938fae22c200b7fead418618160fbe19
Diffstat (limited to 'kubernetes')
-rw-r--r--kubernetes/common/cassandra/resources/restore.sh2
-rwxr-xr-xkubernetes/config/prepull_docker.sh2
-rwxr-xr-xkubernetes/helm/plugins/deploy/deploy.sh54
-rwxr-xr-xkubernetes/helm/plugins/undeploy/undeploy.sh2
-rwxr-xr-xkubernetes/robot/demo-k8s.sh2
-rwxr-xr-xkubernetes/robot/ete-k8s.sh2
-rwxr-xr-xkubernetes/robot/eteHelm-k8s.sh2
-rwxr-xr-xkubernetes/robot/scripts/etescript/vnfsdk-etescript.sh2
8 files changed, 34 insertions, 34 deletions
diff --git a/kubernetes/common/cassandra/resources/restore.sh b/kubernetes/common/cassandra/resources/restore.sh
index a8105345f7..7f271d262f 100644
--- a/kubernetes/common/cassandra/resources/restore.sh
+++ b/kubernetes/common/cassandra/resources/restore.sh
@@ -41,7 +41,7 @@ then
print_usage
fi
-while [[ $# -gt 0 ]]
+while [ $# -gt 0 ]
do
key="$1"
shift
diff --git a/kubernetes/config/prepull_docker.sh b/kubernetes/config/prepull_docker.sh
index 040adec23d..590d651f87 100755
--- a/kubernetes/config/prepull_docker.sh
+++ b/kubernetes/config/prepull_docker.sh
@@ -102,7 +102,7 @@ do
for line in `parse_yaml $filename`
do
#skiping commented line
- if [[ ${line:0:1} != '#' ]]; then
+ if [ "${line:0:1}" != '#' ]; then
#find all image subtag inside converted values.yaml file's lines
if echo $line | grep -q $IMAGE_TEXT ; then
#find imageName inside line
diff --git a/kubernetes/helm/plugins/deploy/deploy.sh b/kubernetes/helm/plugins/deploy/deploy.sh
index 0d434ad877..ce8e80225f 100755
--- a/kubernetes/helm/plugins/deploy/deploy.sh
+++ b/kubernetes/helm/plugins/deploy/deploy.sh
@@ -49,14 +49,14 @@ generate_overrides() {
for index in "${!SUBCHART_NAMES[@]}"; do
START=${SUBCHART_NAMES[index]}
END=${SUBCHART_NAMES[index+1]}
- if [[ $START = "global:" ]]; then
+ if [ "$START" = "global:" ]; then
echo "global:" > $GLOBAL_OVERRIDES
cat $COMPUTED_OVERRIDES | sed '/common:/,/consul:/d' \
| sed -n '/^'"$START"'/,/'log:'/p' | sed '1d;$d' >> $GLOBAL_OVERRIDES
else
SUBCHART_DIR="$CACHE_SUBCHART_DIR/$(echo "$START" |cut -d':' -f1)"
- if [[ -d "$SUBCHART_DIR" ]]; then
- if [[ -z "$END" ]]; then
+ if [ -d "$SUBCHART_DIR" ]; then
+ if [ -z "$END" ]; then
cat $COMPUTED_OVERRIDES | sed -n '/^'"$START"'/,/'"$END"'/p' \
| sed '1d;$d' | cut -c3- > $SUBCHART_DIR/subchart-overrides.yaml
else
@@ -72,11 +72,11 @@ resolve_deploy_flags() {
n=${#flags[*]}
i=0 ; while [ "$i" -lt "$n" ]; do
PARAM=${flags[i]}
- if [[ $PARAM = "-f" || \
- $PARAM = "--values" || \
- $PARAM = "--set" || \
- $PARAM = "--set-string" || \
- $PARAM = "--version" ]]; then
+ if [ "$PARAM" = "-f" ] || \
+ [ "$PARAM" = "--values" ] || \
+ [ "$PARAM" = "--set" ] || \
+ [ "$PARAM" = "--set-string" ] || \
+ [ "$PARAM" = "--version" ]; then
# skip param and its value
i=$((i + 1))
else
@@ -89,7 +89,7 @@ resolve_deploy_flags() {
deploy() {
# validate params
- if [[ -z "$1" || -z "$2" ]]; then
+ if [ -z "$1" ] || [ -z "$2" ]; then
usage
exit 0
fi
@@ -99,7 +99,7 @@ deploy() {
FLAGS=${@:3}
CHART_REPO="$(echo "$CHART_URL" |cut -d'/' -f1)"
CHART_NAME="$(echo "$CHART_URL" |cut -d'/' -f2)"
- if [[ $HELM_VER = "v3."* ]]; then
+ if expr "$HELM_VER" : "v3\..*" ; then
CACHE_DIR=~/.local/share/helm/plugins/deploy/cache
else
CACHE_DIR=~/.helm/plugins/deploy/cache
@@ -111,23 +111,23 @@ deploy() {
# determine if verbose output is enabled
VERBOSE="false"
- if [[ $FLAGS = *"--verbose"* ]]; then
+ if expr "$FLAGS" : ".*--verbose.*" ; then
FLAGS="$(echo $FLAGS| sed -n 's/--verbose//p')"
VERBOSE="true"
fi
# determine if delay for deployment is enabled
DELAY="false"
- if [[ $FLAGS = *"--delay"* ]]; then
+ if expr "$FLAGS" : ".*--delay.*" ; then
FLAGS="$(echo $FLAGS| sed -n 's/--delay//p')"
DELAY="true"
fi
# determine if set-last-applied flag is enabled
SET_LAST_APPLIED="false"
- if [[ $FLAGS = *"--set-last-applied"* ]]; then
+ if expr"$FLAGS" : ".*--set-last-applied.*" ; then
FLAGS="$(echo $FLAGS| sed -n 's/--set-last-applied//p')"
SET_LAST_APPLIED="true"
fi
- if [[ $FLAGS = *"--dry-run"* ]]; then
+ if expr "$FLAGS" : ".*--dry-run.*" ; then
VERBOSE="true"
FLAGS="$FLAGS --debug"
fi
@@ -150,7 +150,7 @@ deploy() {
SUBCHART_RELEASE="$(echo "$RELEASE" |cut -d'-' -f2)"
# update specified subchart without parent
RELEASE="$(echo "$RELEASE" |cut -d'-' -f1)"
- if [[ $SUBCHART_RELEASE = $RELEASE ]]; then
+ if [ "$SUBCHART_RELEASE" = "$RELEASE" ]; then
SUBCHART_RELEASE=
fi
@@ -158,7 +158,7 @@ deploy() {
rm -rf $CACHE_DIR
# fetch umbrella chart (parent chart containing subcharts)
- if [[ -d "$CHART_URL" ]]; then
+ if [ -d "$CHART_URL" ]; then
mkdir -p $CHART_DIR
cp -R $CHART_URL/* $CHART_DIR/
@@ -195,20 +195,20 @@ deploy() {
generate_overrides $COMPUTED_OVERRIDES $GLOBAL_OVERRIDES
# upgrade/install parent chart first
- if [[ -z "$SUBCHART_RELEASE" ]]; then
+ if [ -z "$SUBCHART_RELEASE" ]; then
LOG_FILE=$LOG_DIR/${RELEASE}.log
:> $LOG_FILE
helm upgrade -i $RELEASE $CHART_DIR $DEPLOY_FLAGS -f $COMPUTED_OVERRIDES \
> $LOG_FILE.log 2>&1
- if [[ $VERBOSE = "true" ]]; then
+ if [ "$VERBOSE" = "true" ]; then
cat $LOG_FILE
else
echo "release \"$RELEASE\" deployed"
fi
# Add annotation last-applied-configuration if set-last-applied flag is set
- if [[ $SET_LAST_APPLIED = "true" ]]; then
+ if [ "$SET_LAST_APPLIED" = "true" ]; then
helm get manifest ${RELEASE} \
| kubectl apply set-last-applied --create-annotation -n onap -f - \
> $LOG_FILE.log 2>&1
@@ -224,12 +224,12 @@ deploy() {
SUBCHART_OVERRIDES=$CACHE_SUBCHART_DIR/$subchart/subchart-overrides.yaml
SUBCHART_ENABLED=0
- if [[ -f $SUBCHART_OVERRIDES ]]; then
+ if [ -f $SUBCHART_OVERRIDES ]; then
SUBCHART_ENABLED=$(cat $SUBCHART_OVERRIDES | grep -c "^enabled: true")
fi
- if [[ $SUBCHART_ENABLED -eq 1 ]]; then
- if [[ -z "$SUBCHART_RELEASE" || $SUBCHART_RELEASE = "$subchart" ]]; then
+ if [ $SUBCHART_ENABLED -eq 1 ]; then
+ if [ -z "$SUBCHART_RELEASE" ] || [ "$SUBCHART_RELEASE" = "$subchart" ]; then
LOG_FILE=$LOG_DIR/"${RELEASE}-${subchart}".log
:> $LOG_FILE
@@ -237,19 +237,19 @@ deploy() {
$DEPLOY_FLAGS -f $GLOBAL_OVERRIDES -f $SUBCHART_OVERRIDES \
> $LOG_FILE 2>&1
- if [[ $VERBOSE = "true" ]]; then
+ if [ "$VERBOSE" = "true" ]; then
cat $LOG_FILE
else
echo "release \"${RELEASE}-${subchart}\" deployed"
fi
# Add annotation last-applied-configuration if set-last-applied flag is set
- if [[ $SET_LAST_APPLIED = "true" ]]; then
+ if [ "$SET_LAST_APPLIED" = "true" ]; then
helm get manifest "${RELEASE}-${subchart}" \
| kubectl apply set-last-applied --create-annotation -n onap -f - \
> $LOG_FILE.log 2>&1
fi
fi
- if [[ $DELAY = "true" ]]; then
+ if [ "$DELAY" = "true" ]; then
echo sleep 3m
sleep 3m
fi
@@ -257,7 +257,7 @@ deploy() {
array=($(echo "$ALL_HELM_RELEASES" | grep "${RELEASE}-${subchart}"))
n=${#array[*]}
for i in $(seq $(($n-1)) -1 0); do
- if [[ $HELM_VER = "v3."* ]]; then
+ if expr "$HELM_VER" : "v3\..*" ; then
helm del "${array[i]}"
else
helm del "${array[i]}" --purge
@@ -267,7 +267,7 @@ deploy() {
done
# report on success/failures of installs/upgrades
- if [[ $HELM_VER = "v3."* ]]; then
+ if expr "$HELM_VER" : "v3\..*" ; then
helm ls --all-namespaces | grep -i FAILED | grep $RELEASE
else
helm ls | grep FAILED | grep $RELEASE
diff --git a/kubernetes/helm/plugins/undeploy/undeploy.sh b/kubernetes/helm/plugins/undeploy/undeploy.sh
index 1689bf1b48..790f84fda9 100755
--- a/kubernetes/helm/plugins/undeploy/undeploy.sh
+++ b/kubernetes/helm/plugins/undeploy/undeploy.sh
@@ -29,7 +29,7 @@ undeploy() {
done
}
-if [[ $# < 1 ]]; then
+if [ $# < 1 ]; then
echo "Error: command 'undeploy' requires a release name"
exit 0
fi
diff --git a/kubernetes/robot/demo-k8s.sh b/kubernetes/robot/demo-k8s.sh
index d48070cf24..099f80ccff 100755
--- a/kubernetes/robot/demo-k8s.sh
+++ b/kubernetes/robot/demo-k8s.sh
@@ -63,7 +63,7 @@ usage ()
# Check if execscript flag is used and drop it from input arguments
-if [[ "${!#}" = "execscript" ]]; then
+if [ "${!#}" = "execscript" ]; then
set -- "${@:1:$#-1}"
execscript=true
fi
diff --git a/kubernetes/robot/ete-k8s.sh b/kubernetes/robot/ete-k8s.sh
index 97f4e4d032..15d07fb3ee 100755
--- a/kubernetes/robot/ete-k8s.sh
+++ b/kubernetes/robot/ete-k8s.sh
@@ -76,7 +76,7 @@ SCRIPTDIR=scripts/etescript
ETEHOME=/var/opt/ONAP
-if [[ "${!#}" = "execscript" ]]; then
+if [ "${!#}" = "execscript" ]; then
for script in $(ls -1 "$DIR/$SCRIPTDIR"); do
[ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && source "$DIR/$SCRIPTDIR/$script"
done
diff --git a/kubernetes/robot/eteHelm-k8s.sh b/kubernetes/robot/eteHelm-k8s.sh
index 2512e5f7ce..d5e2fa41c3 100755
--- a/kubernetes/robot/eteHelm-k8s.sh
+++ b/kubernetes/robot/eteHelm-k8s.sh
@@ -44,7 +44,7 @@ SCRIPTDIR=scripts/helmscript
ETEHOME=/var/opt/ONAP
-if [[ "${!#}" = "execscript" ]]; then
+if [ "${!#}" = "execscript" ]; then
for script in $(ls -1 "$DIR/$SCRIPTDIR"); do
[ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && source "$DIR/$SCRIPTDIR/$script"
done
diff --git a/kubernetes/robot/scripts/etescript/vnfsdk-etescript.sh b/kubernetes/robot/scripts/etescript/vnfsdk-etescript.sh
index 19864d438c..a93f109085 100755
--- a/kubernetes/robot/scripts/etescript/vnfsdk-etescript.sh
+++ b/kubernetes/robot/scripts/etescript/vnfsdk-etescript.sh
@@ -35,7 +35,7 @@ copy_package_certs_to_robot () {
mkdir "$DIR/$SCRIPTDIR/tmp"
cd "$DIR/$SCRIPTDIR/tmp"
-if [[ -f rootCA-robot-$SDCVALID.cert && -f package-robot-$SDCVALID.cert && -f package-robot-$SDCINVALID.cert && -f package-private-robot-$SDCVALID.key && -f package-private-robot-$SDCINVALID.key ]]; then
+if [ -f rootCA-robot-$SDCVALID.cert ] && [ -f package-robot-$SDCVALID.cert ] && [ -f package-robot-$SDCINVALID.cert ] && [ -f package-private-robot-$SDCVALID.key ] && [ -f package-private-robot-$SDCINVALID.key ]; then
echo "All files are present";
else
generate_ca_key_cert_and_package_cert_issued_by_CA $SDCVALID