Skip to content

Commit dba0ef4

Browse files
committed
scripts: add missing quotes, and minor linting issues
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 0cb6568 commit dba0ef4

14 files changed

Lines changed: 58 additions & 53 deletions

script/setup/config-selinux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ case "${SELINUX}" in
4545
;;
4646
esac
4747

48-
echo SELinux is $(getenforce)
48+
echo SELinux is "$(getenforce)"

script/setup/install-cni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CNI_CONFIG_DIR=${DESTDIR}/etc/cni/net.d
2828
TMPROOT=$(mktemp -d)
2929
git clone https://github.com/containernetworking/plugins.git "${TMPROOT}"/plugins
3030
pushd "${TMPROOT}"/plugins
31-
git checkout $CNI_COMMIT
31+
git checkout "$CNI_COMMIT"
3232
./build_linux.sh
3333
mkdir -p $CNI_DIR
3434
cp -r ./bin $CNI_DIR

script/setup/install-cni-windows

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ split_ip() {
3737
local -r varname="$1"
3838
local -r ip="$2"
3939
for i in {0..3}; do
40-
eval "$varname"[$i]=$( echo "$ip" | cut -d '.' -f $((i + 1)) )
40+
eval "$varname"[$i]="$( echo "$ip" | cut -d '.' -f $((i + 1)) )"
4141
done
4242
}
4343

script/setup/install-critools

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ cd "$GOPATH"
2626
go get -u github.com/onsi/ginkgo/ginkgo
2727

2828
: "${CRITEST_COMMIT:=$(cat "${script_dir}/critools-version")}"
29+
: "${DESTDIR:=""}"
2930

3031
TMPROOT=$(mktemp -d)
31-
git clone https://github.com/kubernetes-sigs/cri-tools.git "${TMPROOT}"/cri-tools
32+
git clone https://github.com/kubernetes-sigs/cri-tools.git "${TMPROOT}/cri-tools"
3233
pushd "${TMPROOT}"/cri-tools
3334
git checkout "$CRITEST_COMMIT"
3435
make
35-
make install -e DESTDIR=${DESTDIR:=''} BINDIR=/usr/local/bin
36+
make install -e DESTDIR="${DESTDIR}" BINDIR=/usr/local/bin
3637

37-
mkdir -p ${DESTDIR:=''}/etc/
38-
cat << EOF | tee ${DESTDIR:=''}/etc/crictl.yaml
38+
mkdir -p "${DESTDIR}/etc/"
39+
cat << EOF | tee "${DESTDIR}/etc/crictl.yaml"
3940
runtime-endpoint: unix:///run/containerd/containerd.sock
4041
EOF
4142

script/setup/install-protobuf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ PROTOBUF_DIR=$(mktemp -d)
2828
case $GOARCH in
2929

3030
arm64)
31-
wget -O $PROTOBUF_DIR/protobuf "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-aarch64.zip"
32-
unzip $PROTOBUF_DIR/protobuf -d /usr/local
31+
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-aarch64.zip"
32+
unzip "$PROTOBUF_DIR/protobuf" -d /usr/local
3333
;;
3434

3535
amd64|386)
3636
if [ "$GOOS" = windows ]; then
37-
wget -O $PROTOBUF_DIR/protobuf "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-win32.zip"
37+
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-win32.zip"
3838
elif [ "$GOOS" = linux ]; then
39-
wget -O $PROTOBUF_DIR/protobuf "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip"
39+
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip"
4040
fi
41-
unzip $PROTOBUF_DIR/protobuf -d /usr/local
41+
unzip "$PROTOBUF_DIR/protobuf" -d /usr/local
4242
;;
4343

4444
ppc64le)
45-
wget -O $PROTOBUF_DIR/protobuf "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-ppcle_64.zip"
46-
unzip $PROTOBUF_DIR/protobuf -d /usr/local
45+
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-ppcle_64.zip"
46+
unzip "$PROTOBUF_DIR/protobuf" -d /usr/local
4747
;;
4848
*)
49-
wget -O $PROTOBUF_DIR/protobuf "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-cpp-$PROTOBUF_VERSION.zip"
50-
unzip $PROTOBUF_DIR/protobuf -d /usr/src/protobuf
51-
cd /usr/src/protobuf/protobuf-$PROTOBUF_VERSION
49+
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-cpp-$PROTOBUF_VERSION.zip"
50+
unzip "$PROTOBUF_DIR/protobuf" -d /usr/src/protobuf
51+
cd "/usr/src/protobuf/protobuf-$PROTOBUF_VERSION"
5252
./autogen.sh
5353
./configure --disable-shared
5454
make
@@ -57,4 +57,4 @@ ppc64le)
5757
ldconfig
5858
;;
5959
esac
60-
rm -rf $PROTOBUF_DIR
60+
rm -rf "$PROTOBUF_DIR"

script/setup/install-seccomp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ set -eu -o pipefail
2323
set -x
2424

2525
export SECCOMP_VERSION=2.5.1
26-
export SECCOMP_PATH=$(mktemp -d)
26+
SECCOMP_PATH=$(mktemp -d)
27+
export SECCOMP_PATH
2728
curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" | tar -xzC "$SECCOMP_PATH" --strip-components=1
2829
(
2930
cd "$SECCOMP_PATH"

script/test/cri-integration.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
set -o nounset
1818
set -o pipefail
1919

20-
source $(dirname "${BASH_SOURCE[0]}")/utils.sh
21-
cd ${ROOT}
20+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
21+
cd "${ROOT}"
2222

2323
# FOCUS focuses the test to run.
2424
FOCUS=${FOCUS:-""}
@@ -29,15 +29,15 @@ RUNTIME=${RUNTIME:-""}
2929

3030
CRI_ROOT="${CONTAINERD_ROOT}/io.containerd.grpc.v1.cri"
3131

32-
mkdir -p ${REPORT_DIR}
33-
test_setup ${REPORT_DIR}
32+
mkdir -p "${REPORT_DIR}"
33+
test_setup "${REPORT_DIR}"
3434

3535
# Run integration test.
3636
${sudo} bin/cri-integration.test --test.run="${FOCUS}" --test.v \
37-
--cri-endpoint=${CONTAINERD_SOCK} \
38-
--cri-root=${CRI_ROOT} \
39-
--runtime-handler=${RUNTIME} \
40-
--containerd-bin=${CONTAINERD_BIN} \
37+
--cri-endpoint="${CONTAINERD_SOCK}" \
38+
--cri-root="${CRI_ROOT}" \
39+
--runtime-handler="${RUNTIME}" \
40+
--containerd-bin="${CONTAINERD_BIN}" \
4141
--image-list="${TEST_IMAGE_LIST:-}"
4242

4343
test_exit_code=$?

script/test/utils.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pid=
8383

8484
# NOTE: We don't have the sudo command on Windows.
8585
sudo=""
86-
if [ $(id -u) -ne 0 ] && command -v sudo &> /dev/null; then
86+
if [ "$(id -u)" -ne 0 ] && command -v sudo &> /dev/null; then
8787
sudo="sudo PATH=${PATH}"
8888
fi
8989

@@ -99,7 +99,7 @@ test_setup() {
9999
# Create containerd in a different process group
100100
# so that we can easily clean them up.
101101
keepalive "${sudo} bin/containerd ${CONTAINERD_FLAGS}" \
102-
${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
102+
"${RESTART_WAIT_PERIOD}" &> "${report_dir}/containerd.log" &
103103
pid=$!
104104
set +m
105105

@@ -122,7 +122,7 @@ test_teardown() {
122122
# so we can kill both of them by matching the PGID.
123123
${sudo} ps | awk "{if (\$3 == ${pid}) print \$1}" | xargs kill
124124
else
125-
${sudo} pkill -g $(ps -o pgid= -p ${pid})
125+
${sudo} pkill -g $(ps -o pgid= -p "${pid}")
126126
fi
127127
fi
128128
}
@@ -131,11 +131,11 @@ test_teardown() {
131131
# keepalive process is eventually killed in test_teardown.
132132
keepalive() {
133133
local command=$1
134-
echo ${command}
134+
echo "${command}"
135135
local wait_period=$2
136136
while true; do
137137
${command}
138-
sleep ${wait_period}
138+
sleep "${wait_period}"
139139
done
140140
}
141141

test/build-test-images.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ set -o errexit
2222
set -o nounset
2323
set -o pipefail
2424

25-
source $(dirname "${BASH_SOURCE[0]}")/build-utils.sh
26-
source $(dirname "${BASH_SOURCE[0]}")/init-buildx.sh
25+
: "${PROJECT:=k8s-cri-containerd}"
26+
27+
basedir="$(dirname "${BASH_SOURCE[0]}")"
28+
source "${basedir}/build-utils.sh"
29+
source "${basedir}/init-buildx.sh"
2730
cd "${ROOT}"
2831

2932
# ignore errors if the image already exists
30-
make -C integration/images/volume-copy-up push PROJ="gcr.io/${PROJECT:-k8s-cri-containerd}" || true
31-
make -C integration/images/volume-ownership push PROJ="gcr.io/${PROJECT:-k8s-cri-containerd}" || true
33+
make -C integration/images/volume-copy-up push PROJ="gcr.io/${PROJECT}" || true
34+
make -C integration/images/volume-ownership push PROJ="gcr.io/${PROJECT}" || true

test/build-utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
2020
PROJECT=${PROJECT:-"k8s-cri-containerd"}
2121

2222
# GOOGLE_APPLICATION_CREDENTIALS is the path of service account file.
23-
if [ -z ${GOOGLE_APPLICATION_CREDENTIALS:-""} ]; then
23+
if [ -z "${GOOGLE_APPLICATION_CREDENTIALS:-""}" ]; then
2424
echo "GOOGLE_APPLICATION_CREDENTIALS is not set"
2525
exit 1
2626
fi
@@ -33,6 +33,6 @@ apt-get update
3333
apt-get install -y libseccomp2 libseccomp-dev
3434

3535
# PULL_REFS is from prow.
36-
if [ ! -z "${PULL_REFS:-""}" ]; then
36+
if [ -n "${PULL_REFS:-""}" ]; then
3737
DEPLOY_DIR=$(echo "${PULL_REFS}" | sha1sum | awk '{print $1}')
3838
fi

0 commit comments

Comments
 (0)