From 08ca611ba084b6f564343f1efc14e6d9eb294602 Mon Sep 17 00:00:00 2001 From: Julien Pinsonneau Date: Thu, 14 Mar 2024 17:30:43 +0100 Subject: [PATCH] lint + skip vendors --- Makefile | 2 +- scripts/functions.sh | 15 ++++++++------- scripts/inject.sh | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 9129dabe..7fce735d 100644 --- a/Makefile +++ b/Makefile @@ -96,7 +96,7 @@ ifeq (, $(shell which shellcheck)) @echo "### shellcheck could not be found, skipping shell lint" else @echo "### Run shellcheck against bash scripts" - find . -name '*.sh' | xargs shellcheck + find . -name '*.sh' -not -path "./vendor/*" | xargs shellcheck endif .PHONY: clean diff --git a/scripts/functions.sh b/scripts/functions.sh index b6011c0c..8b199e83 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -6,35 +6,35 @@ function loadYAMLs() { namespaceYAMLContent ' if [ -f ./res/namespace.yml ]; then - namespaceYAML="`cat ./res/namespace.yml`" + namespaceYAML="$(cat ./res/namespace.yml)" fi saYAML=' saYAMLContent ' if [ -f ./res/service-account.yml ]; then - saYAML="`cat ./res/service-account.yml`" + saYAML="$(cat ./res/service-account.yml)" fi flowAgentYAML=' flowAgentYAMLContent ' if [ -f ./res/flow-capture.yml ]; then - flowAgentYAML="`cat ./res/flow-capture.yml`" + flowAgentYAML="$(cat ./res/flow-capture.yml)" fi packetAgentYAML=' packetAgentYAMLContent ' if [ -f ./res/packet-capture.yml ]; then - packetAgentYAML="`cat ./res/packet-capture.yml`" + packetAgentYAML="$(cat ./res/packet-capture.yml)" fi collectorServiceYAML=' collectorServiceYAMLContent ' if [ -f ./res/collector-service.yml ]; then - collectorServiceYAML="`cat ./res/collector-service.yml`" + collectorServiceYAML="$(cat ./res/collector-service.yml)" fi } @@ -66,11 +66,11 @@ function setup { echo "creating collector service" echo "$collectorServiceYAML" | oc apply -f - - if [ $1 = "flows" ]; then + if [ "$1" = "flows" ]; then echo "creating flow-capture agents" echo "${flowAgentYAML/"{{FLOW_FILTER_VALUE}}"/$2}" | oc apply -f - oc rollout status daemonset netobserv-cli -n netobserv-cli --timeout 60s - elif [ $1 = "packets" ]; then + elif [ "$1" = "packets" ]; then echo "creating packet-capture agents" echo "${packetAgentYAML/"{{PCA_FILTER_VALUE}}"/$2}" | oc apply -f - oc rollout status daemonset netobserv-cli -n netobserv-cli --timeout 60s @@ -78,6 +78,7 @@ function setup { } function cleanup { + # shellcheck disable=SC2034 if output=$(oc whoami 2>&1); then echo "Copying collector output files..." mkdir -p ./output diff --git a/scripts/inject.sh b/scripts/inject.sh index ae06f4f0..55ea003b 100755 --- a/scripts/inject.sh +++ b/scripts/inject.sh @@ -20,7 +20,7 @@ if [ -z "$1" ]; then echo "output generated in tmp folder" else echo "output generated in $1 folder" - cp -a ./tmp/. ./$1 + cp -a ./tmp/. ./"$1" rm -rf ./tmp fi