File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,15 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
200200 --mount=type=cache,target=/go/pkg/mod \
201201 PREFIX=/build ./install.sh $INSTALL_BINARY_NAME
202202
203+ FROM base AS shfmt
204+ ENV INSTALL_BINARY_NAME=shfmt
205+ ARG SHFMT_COMMIT
206+ COPY hack/dockerfile/install/install.sh ./install.sh
207+ COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
208+ RUN --mount=type=cache,target=/root/.cache/go-build \
209+ --mount=type=cache,target=/go/pkg/mod \
210+ PREFIX=/build ./install.sh $INSTALL_BINARY_NAME
211+
203212FROM dev-base AS dockercli
204213ENV INSTALL_BINARY_NAME=dockercli
205214ARG DOCKERCLI_CHANNEL
@@ -304,6 +313,7 @@ COPY --from=criu /build/ /usr/local/
304313COPY --from=vndr /build/ /usr/local/bin/
305314COPY --from=gotestsum /build/ /usr/local/bin/
306315COPY --from=golangci_lint /build/ /usr/local/bin/
316+ COPY --from=shfmt /build/ /usr/local/bin/
307317COPY --from=runc /build/ /usr/local/bin/
308318COPY --from=containerd /build/ /usr/local/bin/
309319COPY --from=rootlesskit /build/ /usr/local/bin/
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ : " ${SHFMT_COMMIT:= 01725bdd30658db1fe1b9e02173c3060061fe86f} " # v3.0.2
4+
5+ install_shfmt () {
6+ echo " Install shfmt version $SHFMT_COMMIT "
7+ git clone https://github.com/mvdan/sh.git " $GOPATH /src/github.com/mvdan/sh"
8+ cd " $GOPATH /src/github.com/mvdan/sh" || exit 1
9+ git checkout -q " $SHFMT_COMMIT "
10+ GO111MODULE=on go build -buildmode=pie -v -o " ${PREFIX} /shfmt" ./cmd/shfmt
11+ }
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1414. " ${SCRIPTDIR} " /changelog-date-descending
1515. " ${SCRIPTDIR} " /deprecate-integration-cli
1616. " ${SCRIPTDIR} " /golangci-lint
17+ . " ${SCRIPTDIR} " /shfmt
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e -o pipefail
3+
4+ shfmtflags=" -bn -ci -sr"
5+ # NOTE: `git grep '^#!'` may also pick up non-shell script files.
6+ # Add exceptional files to `egrep -v` if any false-positive is detected.
7+ if git grep --name-only ' ^#!' | egrep -v ' (vendor|\.go|Jenkinsfile)' \
8+ | xargs shfmt -d $shfmtflags ; then
9+ echo ' Congratulations! The shell scripts are properly formatted.'
10+ else
11+ echo " Please reformat the shell scripts with \` shfmt -w ${shfmtflags} \` ."
12+ exit 1
13+ fi
You can’t perform that action at this time.
0 commit comments