|
1 |
| -#!/bin/bash |
| 1 | +#!/usr/bin/env bash |
2 | 2 |
|
3 | 3 | # Run golangci-lint with different sets of build tags.
|
4 | 4 | set -e
|
|
8 | 8 | # a very old version, where modern features (like `declare -A`) are
|
9 | 9 | # absent.
|
10 | 10 |
|
| 11 | +declare -a EXTRA_TAGS |
| 12 | + |
11 | 13 | echo "Linting for GOOS=$GOOS"
|
12 |
| -# Special case: for Darwin and Windows only "remote" linting is possible and required. |
13 |
| -if [[ "$GOOS" == "windows" || "$GOOS" == "darwin" ]]; then |
14 |
| - ( |
15 |
| - set -x |
16 |
| - ./bin/golangci-lint run --build-tags="remote,containers_image_openpgp" "$@" |
17 |
| - ) |
18 |
| - exit 0 |
19 |
| -fi |
| 14 | +case "$GOOS" in |
| 15 | + windows|darwin) |
| 16 | + # For Darwin and Windows, only "remote" linting is possible and required. |
| 17 | + TAGS="remote,containers_image_openpgp" |
| 18 | + ;; |
| 19 | + freebsd) |
| 20 | + TAGS="containers_image_openpgp" |
| 21 | + EXTRA_TAGS=(",remote") |
| 22 | + ;; |
| 23 | + *) |
| 24 | + # Assume Linux: run linter for various sets of build tags. |
| 25 | + TAGS="apparmor,seccomp,selinux" |
| 26 | + EXTRA_TAGS=(",systemd" ",remote") |
| 27 | +esac |
20 | 28 |
|
21 |
| -# Normal case (Linux): run linter for various sets of build tags. |
22 |
| -TAGS="apparmor,seccomp,selinux" |
23 |
| -for EXTRA_TAGS in "" ",systemd" ",remote"; do |
| 29 | +for EXTRA in "" "${EXTRA_TAGS[@]}"; do |
| 30 | + # Use set -x in a subshell to make it easy for a developer to copy-paste |
| 31 | + # the command-line to focus or debug a single, specific linting category. |
24 | 32 | (
|
25 |
| - # Make it really easy for a developer to copy-paste the command-line |
26 |
| - # to focus or debug a single, specific linting category. |
27 | 33 | set -x
|
28 |
| - ./bin/golangci-lint run --build-tags="${TAGS}${EXTRA_TAGS}" "$@" |
| 34 | + ./bin/golangci-lint run --build-tags="${TAGS}${EXTRA}" "$@" |
29 | 35 | )
|
30 | 36 | done
|
0 commit comments