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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-04-02 16:02:34 +02:00
parent 1ff685085a
commit 1d4a273487
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
5 changed files with 15 additions and 19 deletions

View file

@ -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 runtime-dev-cross-${CROSS} AS runtime-dev
FROM base AS tomlv FROM base AS tomll
ARG TOMLV_COMMIT ARG GOTOML_VERSION
RUN --mount=type=cache,target=/root/.cache/go-build \ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,src=hack/dockerfile/install,target=/tmp/install \ --mount=type=bind,src=hack/dockerfile/install/tomll.installer,target=/tmp/install/tomll.installer \
PREFIX=/build /tmp/install/install.sh tomlv . /tmp/install/tomll.installer && PREFIX=/build install_tomll
FROM base AS vndr FROM base AS vndr
ARG VNDR_COMMIT ARG VNDR_COMMIT
@ -305,7 +305,7 @@ RUN pip3 install yamllint==1.16.0
COPY --from=dockercli /build/ /usr/local/cli COPY --from=dockercli /build/ /usr/local/cli
COPY --from=frozen-images /build/ /docker-frozen-images COPY --from=frozen-images /build/ /docker-frozen-images
COPY --from=swagger /build/ /usr/local/bin/ 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=tini /build/ /usr/local/bin/
COPY --from=registry /build/ /usr/local/bin/ COPY --from=registry /build/ /usr/local/bin/
COPY --from=criu /build/ /usr/local/ COPY --from=criu /build/ /usr/local/

View file

@ -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}"
}

View file

@ -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"
}

View file

@ -10,7 +10,7 @@ unset IFS
badFiles=() badFiles=()
for f in "${files[@]}"; do for f in "${files[@]}"; do
# we use "git show" here to validate that what's committed has valid TOML syntax # 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") badFiles+=("$f")
fi fi
done done

View file

@ -63,7 +63,6 @@ github.com/vishvananda/netns db3c7e526aae966c4ccfa6c8189b
github.com/vishvananda/netlink f049be6f391489d3f374498fe0c8df8449258372 # v1.1.0 github.com/vishvananda/netlink f049be6f391489d3f374498fe0c8df8449258372 # v1.1.0
github.com/moby/ipvs 4566ccea0e08d68e9614c3e7a64a23b850c4bb35 # v1.0.1 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/BurntSushi/toml 3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005 # v0.3.1
github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d