Skip to content

Commit

Permalink
hack: add linter
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Jun 27, 2020
1 parent 2828ad0 commit 4c99bcd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
12 changes: 6 additions & 6 deletions cmd/binfmt/config.go
Expand Up @@ -14,32 +14,32 @@ type config struct {
}

var configs = map[string]config{
"amd64": config{
"amd64": {
binary: "qemu-x86_64",
magic: `\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00`,
mask: `\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff`,
},
"arm64": config{
"arm64": {
binary: "qemu-aarch64",
magic: `\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00`,
mask: `\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff`,
},
"arm": config{
"arm": {
binary: "qemu-arm",
magic: `\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00`,
mask: `\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff`,
},
"s390x": config{
"s390x": {
binary: "qemu-s390x",
magic: `\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16`,
mask: `\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff`,
},
"ppc64le": config{
"ppc64le": {
binary: "qemu-ppc64le",
magic: `\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00`,
mask: `\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00`,
},
"riscv64": config{
"riscv64": {
binary: "qemu-riscv64",
magic: `\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00`,
mask: `\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff`,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
@@ -1,4 +1,4 @@
module github.com/tonistiigi/binfmt/binfmt
module github.com/tonistiigi/binfmt

go 1.14

Expand Down
13 changes: 13 additions & 0 deletions gometalinter.json
@@ -0,0 +1,13 @@
{
"Vendor": true,
"Deadline": "8m",
"Exclude": [".*.pb.go"],
"DisableAll": true,
"Enable": [
"gofmt",
"goimports",
"ineffassign",
"vet",
"deadcode"
]
}
10 changes: 10 additions & 0 deletions hack/dockerfiles/lint.Dockerfile
@@ -0,0 +1,10 @@
# syntax=docker/dockerfile:1.1-experimental

FROM golang:1.14-alpine
RUN apk add --no-cache git
RUN go get -u gopkg.in/alecthomas/gometalinter.v1 \
&& mv /go/bin/gometalinter.v1 /go/bin/gometalinter \
&& gometalinter --install
WORKDIR /src
RUN --mount=target=. \
gometalinter --config=gometalinter.json ./...
10 changes: 10 additions & 0 deletions hack/lint
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -eu -o pipefail -x

: ${CONTINUOUS_INTEGRATION=}

progressFlag=""
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi

docker buildx build $progressFlag -f ./hack/dockerfiles/lint.Dockerfile .

0 comments on commit 4c99bcd

Please sign in to comment.