Skip to content

Commit eb43f4c

Browse files
authored
Merge pull request #3183 from crazy-max/modernize-fix
hack: modernize-fix bake target
2 parents 43e2f27 + c1209ac commit eb43f4c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docker-bake.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ target "lint-gopls" {
7373
target = "gopls-analyze"
7474
}
7575

76+
target "modernize-fix" {
77+
inherits = ["_common"]
78+
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
79+
target = "modernize-fix"
80+
output = ["."]
81+
}
82+
7683
target "validate-vendor" {
7784
inherits = ["_common"]
7885
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"

hack/dockerfiles/lint.Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,25 @@ RUN --mount=target=. \
9191
done
9292
EOF
9393

94+
FROM base AS modernize-fix-run
95+
COPY --link --from=xx / /
96+
ARG TARGETNAME
97+
ARG TARGETPLATFORM
98+
WORKDIR /go/src/github.com/docker/buildx
99+
RUN --mount=target=.,rw \
100+
--mount=target=/root/.cache,type=cache,id=lint-cache-${TARGETNAME}-${TARGETPLATFORM} \
101+
--mount=target=/gopls-analyzers,from=gopls,source=/out <<EOF
102+
set -ex
103+
xx-go --wrap
104+
mkdir /out
105+
/gopls-analyzers/modernize -fix ./...
106+
for file in $(git status --porcelain | awk '/^ M/ {print $2}'); do
107+
mkdir -p /out/$(dirname $file)
108+
cp $file /out/$file
109+
done
110+
EOF
111+
112+
FROM scratch AS modernize-fix
113+
COPY --link --from=modernize-fix-run /out /
114+
94115
FROM lint

0 commit comments

Comments
 (0)