From c9a21e58840e661631b63770e6b2055c7a1ef4cc Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 12 Jan 2024 22:22:45 +0100 Subject: [PATCH] Fix some more linting issues (#5) --- .woodpecker/test-release.yaml | 2 +- plugin.sh | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.woodpecker/test-release.yaml b/.woodpecker/test-release.yaml index 3e24fd5..8beda90 100644 --- a/.woodpecker/test-release.yaml +++ b/.woodpecker/test-release.yaml @@ -29,7 +29,7 @@ steps: image: alpine:3.19 commands: - apk add -U shellcheck - - shellcheck -e SC3040 -e SC3010 -e SC3037 -e SC2086 -e SC2166 -e SC2002 -e SC2236 -e SC3020 -e SC2162 *.sh + - shellcheck -e SC3040 -e SC3010 -e SC3037 -e SC3020 -e SC2162 *.sh # TODO: add test of fresh build kaniko diff --git a/plugin.sh b/plugin.sh index 16b4fe7..083cb7a 100755 --- a/plugin.sh +++ b/plugin.sh @@ -65,11 +65,11 @@ if [[ "${PLUGIN_AUTO_TAG:-}" == "true" ]]; then TAG=$(echo "${DRONE_TAG:-}" |sed 's/^v//g') part=$(echo "${TAG}" |tr '.' '\n' |wc -l) # expect number - echo ${TAG} |grep -E "[a-z-]" &>/dev/null && isNum=1 || isNum=0 + echo "${TAG}" |grep -E "[a-z-]" &>/dev/null && isNum=1 || isNum=0 - if [ ! -n "${TAG:-}" ];then + if [ -z "${TAG:-}" ]; then echo "latest" > .tags - elif [ ${isNum} -eq 1 -o ${part} -gt 3 ];then + elif [ "${isNum}" -eq 1 ] || [ "${part}" -gt 3 ]; then echo "${TAG},latest" > .tags else major=$(echo "${TAG}" |awk -F'.' '{print $1}') @@ -85,13 +85,13 @@ if [[ "${PLUGIN_AUTO_TAG:-}" == "true" ]]; then fi if [ -n "${PLUGIN_MIRRORS:-}" ]; then - MIRROR="$(echo $PLUGIN_MIRRORS | tr ',' '\n' | while read mirror; do echo "--registry-mirror=${mirror}"; done)" + MIRROR="$(echo "${PLUGIN_MIRRORS}" | tr ',' '\n' | while read mirror; do echo "--registry-mirror=${mirror}"; done)" fi if [ -n "${PLUGIN_TAGS:-}" ]; then DESTINATIONS=$(echo "${PLUGIN_TAGS}" | tr ',' '\n' | while read tag; do echo "--destination=${REGISTRY}/${PLUGIN_REPO}:${tag} "; done) elif [ -f .tags ]; then - DESTINATIONS=$(cat .tags| tr ',' '\n' | while read tag; do echo "--destination=${REGISTRY}/${PLUGIN_REPO}:${tag} "; done) + DESTINATIONS=$(tr ',' '\n' < .tags | while read tag; do echo "--destination=${REGISTRY}/${PLUGIN_REPO}:${tag} "; done) elif [ -n "${PLUGIN_REPO:-}" ]; then DESTINATIONS="--destination=${REGISTRY}/${PLUGIN_REPO}:latest" else @@ -100,15 +100,15 @@ else CACHE="" fi -/kaniko/executor -v ${LOG} \ - --context=${CONTEXT} \ - --dockerfile=${DOCKERFILE} \ - ${EXTRA_OPTS} \ - ${DESTINATIONS} \ - ${CACHE:-} \ - ${CACHE_TTL:-} \ - ${CACHE_REPO:-} \ - ${TARGET:-} \ - ${BUILD_ARGS:-} \ - ${BUILD_ARGS_FROM_ENV:-} \ - ${MIRROR:-} +/kaniko/executor -v "${LOG}" \ + --context="${CONTEXT}" \ + --dockerfile="${DOCKERFILE}" \ + "${EXTRA_OPTS}" \ + "${DESTINATIONS}" \ + "${CACHE:-}" \ + "${CACHE_TTL:-}" \ + "${CACHE_REPO:-}" \ + "${TARGET:-}" \ + "${BUILD_ARGS:-}" \ + "${BUILD_ARGS_FROM_ENV:-}" \ + "${MIRROR:-}"