Skip to content

Commit 9dc9b84

Browse files
authored
Ensure scripts/ are well lint-ed (#277)
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent e8bad66 commit 9dc9b84

File tree

6 files changed

+26
-19
lines changed

6 files changed

+26
-19
lines changed

.github/workflows/lint-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ jobs:
7575
- component: helm-charts
7676
make_command: 'make helm-lint'
7777
step_name: 'Validate Helm charts'
78+
- component: scripts
79+
make_command: 'make -C scripts lint'
80+
step_name: 'Run shellcheck on scripts'
7881
steps:
7982
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
8083

scripts/build-image-list.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ CONTAINER_ORG=${CONTAINER_ORG:-$(git config --get remote.origin.url | sed -n 's#
3333
if [[ -z "${SAFE_REF_NAME:-}" ]]; then
3434
CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}
3535
# Sanitize branch name by replacing slashes with dashes
36-
SAFE_REF_NAME=$(echo "$CI_COMMIT_REF_NAME" | sed 's#/#-#g')
36+
SAFE_REF_NAME=${CI_COMMIT_REF_NAME//\//-}
3737
fi
3838

3939
# Initialize output file
4040
out="versions.txt"
41-
> "$out"
41+
: > "$out"
4242

4343
# ------- 1) Build dynamic list -------
4444
# Define array of dynamic images with their respective tags (sorted!)

scripts/buildko.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export KO_LOG=info
2121
export KO_DOCKER_REPO="${KO_DOCKER_REPO,,}"
2222
export VERSION="${VERSION:-v0.1.0}"
2323
export GIT_COMMIT="${GIT_COMMIT:-dev}"
24-
export BUILD_DATE=$(date -u +%FT%TZ)
24+
BUILD_DATE=$(date -u +%FT%TZ)
25+
export BUILD_DATE
2526

2627
# Display build variables for debugging
2728
echo "Build variables:"

scripts/setup-dev-env.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ if ! command_exists yq; then
180180
exit 1
181181
fi
182182
elif [[ "${OS}" == "linux" ]]; then
183-
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${ARCH}
183+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_"${ARCH}"
184184
sudo chmod +x /usr/local/bin/yq
185185
fi
186186

@@ -300,10 +300,10 @@ if [[ "${SKIP_PYTHON}" == "false" ]]; then
300300

301301
if prompt_continue; then
302302
if [[ "${OS}" == "darwin" ]]; then
303-
pip3 install poetry==${POETRY_VERSION}
303+
pip3 install poetry=="${POETRY_VERSION}"
304304
elif [[ "${OS}" == "linux" ]]; then
305-
python3 -m pip install --break-system-packages poetry==${POETRY_VERSION} || \
306-
python3 -m pip install --user poetry==${POETRY_VERSION}
305+
python3 -m pip install --break-system-packages poetry=="${POETRY_VERSION}" || \
306+
python3 -m pip install --user poetry=="${POETRY_VERSION}"
307307
fi
308308
log_success "Poetry installed"
309309
fi
@@ -316,18 +316,18 @@ if [[ "${SKIP_PYTHON}" == "false" ]]; then
316316

317317
if [[ "${BLACK_INSTALLED}" != "${BLACK_VERSION}"* ]]; then
318318
log_warning "Black version mismatch (current: ${BLACK_INSTALLED}, target: ${BLACK_VERSION})"
319-
log_info "Consider updating: pip install --upgrade black==${PBLACK_VERSION}"
319+
log_info "Consider updating: pip install --upgrade black==${BLACK_VERSION}"
320320
fi
321321
else
322322
log_warning "Black not found"
323323
log_info "Installing Black ${BLACK_VERSION}..."
324324

325325
if prompt_continue; then
326326
if [[ "${OS}" == "darwin" ]]; then
327-
pip3 install black==${BLACK_VERSION}
327+
pip3 install black=="${BLACK_VERSION}"
328328
elif [[ "${OS}" == "linux" ]]; then
329-
python3 -m pip install --break-system-packages black==${BLACK_VERSION} || \
330-
python3 -m pip install --user black==${BLACK_VERSION}
329+
python3 -m pip install --break-system-packages black=="${BLACK_VERSION}" || \
330+
python3 -m pip install --user black=="${BLACK_VERSION}"
331331
fi
332332
log_success "Black installed"
333333
fi
@@ -399,7 +399,7 @@ if [[ "${SKIP_TOOLS}" == "false" ]]; then
399399
fi
400400
fi
401401

402-
# shellcheck
402+
# Install shellcheck
403403
if command_exists shellcheck; then
404404
log_success "shellcheck already installed: $(shellcheck --version | head -2 | tail -1)"
405405
else
@@ -464,7 +464,7 @@ if [[ "${SKIP_TOOLS}" == "false" ]]; then
464464
if [[ "${OS}" == "darwin" ]]; then
465465
brew install tilt-dev/tap/ctlptl
466466
elif [[ "${OS}" == "linux" ]]; then
467-
go install github.com/tilt-dev/ctlptl/cmd/ctlptl@v${CTLPTL_VERSION}
467+
go install github.com/tilt-dev/ctlptl/cmd/ctlptl@v"${CTLPTL_VERSION}"
468468
sudo cp "$(go env GOPATH)/bin/ctlptl" /usr/local/bin/
469469
fi
470470
log_success "ctlptl installed"
@@ -497,8 +497,8 @@ if [[ "${SKIP_TOOLS}" == "false" ]] && command_exists go; then
497497
log_info " protoc-gen-go-grpc: ${PROTOC_GEN_GO_GRPC_VERSION}"
498498

499499
if prompt_continue; then
500-
go install google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION}
501-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION}
500+
go install google.golang.org/protobuf/cmd/protoc-gen-go@"${PROTOC_GEN_GO_VERSION}"
501+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@"${PROTOC_GEN_GO_GRPC_VERSION}"
502502
log_success "Go protobuf/gRPC tools installed"
503503
fi
504504

scripts/update-dockerfile-versions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ SKIPPED_COUNT=0
7979

8080
# Process each Dockerfile
8181
while IFS= read -r dockerfile; do
82-
RELATIVE_PATH="${dockerfile#${REPO_ROOT}/}"
82+
RELATIVE_PATH="${dockerfile#"${REPO_ROOT}"/}"
8383
CHANGED=false
8484

8585
# Check for Go base images

scripts/verify-image-provenance.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ readonly BLUE='\033[0;34m'
5252
readonly NC='\033[0m' # No Color
5353

5454
# Paths
55-
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
56-
readonly REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
55+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
56+
readonly SCRIPT_DIR
57+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
58+
readonly REPO_ROOT
5759
readonly VERSIONS_FILE="${VERSIONS_FILE:-$REPO_ROOT/.versions.yaml}"
5860

5961
# Configuration - load versions from .versions.yaml if available
@@ -416,6 +418,7 @@ EOF
416418

417419
if [ -n "$events" ]; then
418420
log_info "Policy warnings detected:"
421+
# shellcheck disable=SC2001 # sed is appropriate for adding indentation to multiple lines
419422
echo "$events" | sed 's/^/ /'
420423
else
421424
log_info "No policy warnings found in pod events (check Policy Controller logs for details)"
@@ -546,7 +549,7 @@ EOF
546549
# Look for successful validations (would not have "failed" or "no matching" in logs)
547550
# In warn mode, successful validations are silent, so we check for policy check counts
548551
local all_checked_modules
549-
all_checked_modules=$(echo "$validated_modules")
552+
all_checked_modules="$validated_modules"
550553

551554
# Compare: modules checked vs modules failed = modules that might have passed
552555
local potentially_passed=""

0 commit comments

Comments
 (0)