Skip to content

Commit c1209ac

Browse files
committed
hack: modernize-fix bake target
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 03f9877 commit c1209ac

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

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
@@ -92,4 +92,25 @@ RUN --mount=target=. \
9292
done
9393
EOF
9494

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

0 commit comments

Comments
 (0)