mirror of https://github.com/docker/buildx.git
update lint to go1.16/golangci
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
905be6431b
commit
dba79ba223
|
@ -0,0 +1,30 @@
|
||||||
|
run:
|
||||||
|
timeout: 10m
|
||||||
|
skip-files:
|
||||||
|
- ".*\\.pb\\.go$"
|
||||||
|
|
||||||
|
modules-download-mode: vendor
|
||||||
|
|
||||||
|
build-tags:
|
||||||
|
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- govet
|
||||||
|
- deadcode
|
||||||
|
- goimports
|
||||||
|
- ineffassign
|
||||||
|
- misspell
|
||||||
|
- unused
|
||||||
|
- varcheck
|
||||||
|
- golint
|
||||||
|
- staticcheck
|
||||||
|
- typecheck
|
||||||
|
- structcheck
|
||||||
|
disable-all: true
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
- linters:
|
||||||
|
- golint
|
||||||
|
text: "stutters"
|
|
@ -56,7 +56,7 @@ func ParseCompose(dt []byte) (*Config, error) {
|
||||||
if reflect.DeepEqual(s.Build, zeroBuildConfig) {
|
if reflect.DeepEqual(s.Build, zeroBuildConfig) {
|
||||||
// if not make sure they're setting an image or it's invalid d-c.yml
|
// if not make sure they're setting an image or it's invalid d-c.yml
|
||||||
if s.Image == "" {
|
if s.Image == "" {
|
||||||
return nil, fmt.Errorf("compose file invalid: service %s has neither an image nor a build context specified. At least one must be provided.", s.Name)
|
return nil, fmt.Errorf("compose file invalid: service %s has neither an image nor a build context specified. At least one must be provided", s.Name)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,9 +161,8 @@ func parseHCL(dt []byte, fn string) (_ *Config, err error) {
|
||||||
fnl := strings.ToLower(fn)
|
fnl := strings.ToLower(fn)
|
||||||
if strings.HasSuffix(fnl, ".json") {
|
if strings.HasSuffix(fnl, ".json") {
|
||||||
return nil, jsondiags
|
return nil, jsondiags
|
||||||
} else {
|
|
||||||
return nil, hcldiags
|
|
||||||
}
|
}
|
||||||
|
return nil, hcldiags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ type Input struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadRemoteFiles(ctx context.Context, dis []build.DriverInfo, url string, names []string, pw progress.Writer) ([]File, *Input, error) {
|
func ReadRemoteFiles(ctx context.Context, dis []build.DriverInfo, url string, names []string, pw progress.Writer) ([]File, *Input, error) {
|
||||||
st, filename, ok := detectHttpContext(url)
|
st, filename, ok := detectHTTPContext(url)
|
||||||
if !ok {
|
if !ok {
|
||||||
st, ok = detectGitContext(url)
|
st, ok = detectGitContext(url)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -83,7 +83,7 @@ func ReadRemoteFiles(ctx context.Context, dis []build.DriverInfo, url string, na
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsRemoteURL(url string) bool {
|
func IsRemoteURL(url string) bool {
|
||||||
if _, _, ok := detectHttpContext(url); ok {
|
if _, _, ok := detectHTTPContext(url); ok {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if _, ok := detectGitContext(url); ok {
|
if _, ok := detectGitContext(url); ok {
|
||||||
|
@ -92,7 +92,7 @@ func IsRemoteURL(url string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectHttpContext(url string) (*llb.State, string, bool) {
|
func detectHTTPContext(url string) (*llb.State, string, bool) {
|
||||||
if httpPrefix.MatchString(url) {
|
if httpPrefix.MatchString(url) {
|
||||||
httpContext := llb.HTTP(url, llb.Filename("context"), llb.WithCustomName("[internal] load remote build context"))
|
httpContext := llb.HTTP(url, llb.Filename("context"), llb.WithCustomName("[internal] load remote build context"))
|
||||||
return &httpContext, "context", true
|
return &httpContext, "context", true
|
||||||
|
|
|
@ -63,11 +63,14 @@ type buildOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type commonOptions struct {
|
type commonOptions struct {
|
||||||
builder string
|
builder string
|
||||||
noCache *bool
|
noCache *bool
|
||||||
progress string
|
progress string
|
||||||
pull *bool
|
pull *bool
|
||||||
|
// golangci-lint#826
|
||||||
|
// nolint:structcheck
|
||||||
exportPush bool
|
exportPush bool
|
||||||
|
// nolint:structcheck
|
||||||
exportLoad bool
|
exportLoad bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,8 +185,6 @@ func printSummary(tw *tabwriter.Writer, dus [][]*client.UsageInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tw = tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0)
|
|
||||||
|
|
||||||
if shared > 0 {
|
if shared > 0 {
|
||||||
fmt.Fprintf(tw, "Shared:\t%.2f\n", units.Bytes(shared))
|
fmt.Fprintf(tw, "Shared:\t%.2f\n", units.Bytes(shared))
|
||||||
fmt.Fprintf(tw, "Private:\t%.2f\n", units.Bytes(total-shared))
|
fmt.Fprintf(tw, "Private:\t%.2f\n", units.Bytes(total-shared))
|
||||||
|
|
|
@ -168,7 +168,7 @@ func parseSources(in []string) ([]*src, error) {
|
||||||
for i, in := range in {
|
for i, in := range in {
|
||||||
s, err := parseSource(in)
|
s, err := parseSource(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to parse source %q, valid sources are digests, refereces and descriptors", in)
|
return nil, errors.Wrapf(err, "failed to parse source %q, valid sources are digests, references and descriptors", in)
|
||||||
}
|
}
|
||||||
out[i] = s
|
out[i] = s
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"Vendor": true,
|
|
||||||
"Deadline": "8m",
|
|
||||||
"Exclude": [".*.pb.go"],
|
|
||||||
"DisableAll": true,
|
|
||||||
"Enable": [
|
|
||||||
"gofmt",
|
|
||||||
"goimports",
|
|
||||||
"ineffassign",
|
|
||||||
"vet",
|
|
||||||
"deadcode"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,12 +1,10 @@
|
||||||
# syntax=docker/dockerfile:1.0-experimental
|
# syntax=docker/dockerfile:1.2
|
||||||
|
|
||||||
FROM golang:1.16-alpine
|
FROM golang:1.16-alpine
|
||||||
RUN apk add --no-cache git yamllint
|
RUN apk add --no-cache gcc musl-dev yamllint
|
||||||
RUN go get -u gopkg.in/alecthomas/gometalinter.v1 \
|
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.36.0
|
||||||
&& mv /go/bin/gometalinter.v1 /go/bin/gometalinter \
|
|
||||||
&& gometalinter --install
|
|
||||||
WORKDIR /go/src/github.com/docker/buildx
|
WORKDIR /go/src/github.com/docker/buildx
|
||||||
RUN --mount=target=/go/src/github.com/docker/buildx \
|
RUN --mount=target=/go/src/github.com/docker/buildx --mount=target=/root/.cache,type=cache \
|
||||||
gometalinter --config=gometalinter.json ./...
|
golangci-lint run
|
||||||
RUN --mount=target=/go/src/github.com/docker/buildx \
|
RUN --mount=target=/go/src/github.com/docker/buildx --mount=target=/root/.cache,type=cache \
|
||||||
yamllint -c .yamllint.yml --strict .
|
yamllint -c .yamllint.yml --strict .
|
|
@ -55,6 +55,6 @@ type pw struct {
|
||||||
status chan *client.SolveStatus
|
status chan *client.SolveStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pw) Status() chan *client.SolveStatus {
|
func (w *pw) Status() chan *client.SolveStatus {
|
||||||
return p.status
|
return w.status
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue