File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -93,9 +93,17 @@ clean:
9393
9494lint :
9595ifeq ($(CONTAINER_RUNNABLE ) , 0)
96- @GOPATH=${GOPATH} ./hack/lint.sh $(CONTAINER_RUNTIME)
96+ @GOPATH=${GOPATH} ./hack/lint.sh $(CONTAINER_RUNTIME) || { echo "lint failed! Try running 'make lint-fix'"; exit 1; }
9797else
98- echo "linter can only be run within a container since it needs a specific golangci-lint version"
98+ echo "linter can only be run within a container since it needs a specific golangci-lint version"; exit 1
99+ endif
100+
101+ lint-fix :
102+ ifeq ($(CONTAINER_RUNNABLE ) , 0)
103+ @GOPATH=${GOPATH} ./hack/lint.sh $(CONTAINER_RUNTIME) fix || { echo "ERROR: lint fix failed! There is a bug that changes file ownership to root \
104+ when this happens. To fix it, simply run 'chown -R <user>:<group> *' from the repo root."; exit 1; }
105+ else
106+ echo "linter can only be run within a container since it needs a specific golangci-lint version"; exit 1
99107endif
100108
101109gofmt :
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2-
32VERSION=v1.60.3
3+ extra_flags=" "
44if [ " $# " -ne 1 ]; then
5+ if [ " $# " -eq 2 ] && [ " $2 " == " fix" ]; then
6+ extra_flags=" --fix"
7+ else
58 echo " Expected command line argument - container runtime (docker/podman) got $# arguments: $@ "
69 exit 1
10+ fi
711fi
812
913$1 run --security-opt label=disable --rm \
1014 -v ${HOME} /.cache/golangci-lint:/cache -e GOLANGCI_LINT_CACHE=/cache \
1115 -v $( pwd) :/app -w /app -e GO111MODULE=on docker.io/golangci/golangci-lint:${VERSION} \
1216 golangci-lint run --verbose --print-resources-usage \
13- --modules-download-mode=vendor --timeout=15m0s && \
14- echo " lint OK!"
17+ --modules-download-mode=vendor --timeout=15m0s ${extra_flags} && \
18+ echo " lint OK!"
You can’t perform that action at this time.
0 commit comments