From 1d4a2734878610cb3b1f9389d9ab47a7f9d923b4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 2 Apr 2021 16:02:34 +0200 Subject: [PATCH] validate/toml: switch to github.com/pelletier/go-toml The github.com/BurntSushi/toml project is no longer maintained, and containerd is switching to this project instead, so start moving our code as well. This patch only changes the binary used during validation (tbh, we could probably remove this validation step, but leaving that for now). I manually verified that the hack/verify/toml still works by adding a commit that makes the MAINTAINERS file invalid; diff --git a/MAINTAINERS b/MAINTAINERS index b739e7e20c..81ababd8de 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -23,7 +23,7 @@ # a subsystem, they are responsible for doing so and holding the # subsystem maintainers accountable. If ownership is unclear, they are the de facto owners. - people = [ + people = "akihirosuda", "anusha", "coolljt0725", Running `hack/verify/toml` was able to detect the broken format; hack/validate/toml (27, 4): keys cannot contain , characterThese files are not valid TOML: - MAINTAINERS Please reformat the above files as valid TOML Signed-off-by: Sebastiaan van Stijn --- Dockerfile | 10 +++++----- hack/dockerfile/install/tomll.installer | 9 +++++++++ hack/dockerfile/install/tomlv.installer | 12 ------------ hack/validate/toml | 2 +- vendor.conf | 1 - 5 files changed, 15 insertions(+), 19 deletions(-) create mode 100755 hack/dockerfile/install/tomll.installer delete mode 100755 hack/dockerfile/install/tomlv.installer diff --git a/Dockerfile b/Dockerfile index f5ec77836b..83a5bb04c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -151,12 +151,12 @@ RUN --mount=type=cache,sharing=locked,id=moby-cross-true-aptlib,target=/var/lib/ FROM runtime-dev-cross-${CROSS} AS runtime-dev -FROM base AS tomlv -ARG TOMLV_COMMIT +FROM base AS tomll +ARG GOTOML_VERSION RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ - --mount=type=bind,src=hack/dockerfile/install,target=/tmp/install \ - PREFIX=/build /tmp/install/install.sh tomlv + --mount=type=bind,src=hack/dockerfile/install/tomll.installer,target=/tmp/install/tomll.installer \ + . /tmp/install/tomll.installer && PREFIX=/build install_tomll FROM base AS vndr ARG VNDR_COMMIT @@ -305,7 +305,7 @@ RUN pip3 install yamllint==1.16.0 COPY --from=dockercli /build/ /usr/local/cli COPY --from=frozen-images /build/ /docker-frozen-images COPY --from=swagger /build/ /usr/local/bin/ -COPY --from=tomlv /build/ /usr/local/bin/ +COPY --from=tomll /build/ /usr/local/bin/ COPY --from=tini /build/ /usr/local/bin/ COPY --from=registry /build/ /usr/local/bin/ COPY --from=criu /build/ /usr/local/ diff --git a/hack/dockerfile/install/tomll.installer b/hack/dockerfile/install/tomll.installer new file mode 100755 index 0000000000..066b9ccdd0 --- /dev/null +++ b/hack/dockerfile/install/tomll.installer @@ -0,0 +1,9 @@ +#!/bin/sh + +: "${GOTOML_VERSION:=v1.8.1}" + +install_tomll() { + echo "Install go-toml version ${GOTOML_VERSION}" + # TODO remove GO111MODULE=on and change to 'go install -mod=mod ...' once we're at go 1.16+ + GO111MODULE=on GOBIN="${PREFIX}" go get -v "github.com/pelletier/go-toml/cmd/tomll@${GOTOML_VERSION}" +} diff --git a/hack/dockerfile/install/tomlv.installer b/hack/dockerfile/install/tomlv.installer deleted file mode 100755 index 6ef795700c..0000000000 --- a/hack/dockerfile/install/tomlv.installer +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# When updating TOMLV_COMMIT, consider updating github.com/BurntSushi/toml -# in vendor.conf accordingly -: ${TOMLV_COMMIT:=3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005} # v0.3.1 - -install_tomlv() { - echo "Install tomlv version $TOMLV_COMMIT" - git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml" - cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT" - go build -v ${GO_BUILDMODE} -o "${PREFIX}/tomlv" "github.com/BurntSushi/toml/cmd/tomlv" -} diff --git a/hack/validate/toml b/hack/validate/toml index 3d22619b1a..7f1739ab84 100755 --- a/hack/validate/toml +++ b/hack/validate/toml @@ -10,7 +10,7 @@ unset IFS badFiles=() for f in "${files[@]}"; do # we use "git show" here to validate that what's committed has valid TOML syntax - if ! git show "$VALIDATE_HEAD:$f" | tomlv /proc/self/fd/0; then + if ! git show "$VALIDATE_HEAD:$f" | tomll /proc/self/fd/0; then badFiles+=("$f") fi done diff --git a/vendor.conf b/vendor.conf index abedda4ee8..965b46f8bc 100644 --- a/vendor.conf +++ b/vendor.conf @@ -63,7 +63,6 @@ github.com/vishvananda/netns db3c7e526aae966c4ccfa6c8189b github.com/vishvananda/netlink f049be6f391489d3f374498fe0c8df8449258372 # v1.1.0 github.com/moby/ipvs 4566ccea0e08d68e9614c3e7a64a23b850c4bb35 # v1.0.1 -# When updating, consider updating TOMLV_COMMIT in hack/dockerfile/install/tomlv.installer accordingly github.com/BurntSushi/toml 3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005 # v0.3.1 github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d