mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
update lint to go1.16/golangci
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
905be6431b
commit
dba79ba223
30
.golangci.yml
Normal file
30
.golangci.yml
Normal file
@ -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 not make sure they're setting an image or it's invalid d-c.yml
|
||||
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
|
||||
}
|
||||
|
@ -161,9 +161,8 @@ func parseHCL(dt []byte, fn string) (_ *Config, err error) {
|
||||
fnl := strings.ToLower(fn)
|
||||
if strings.HasSuffix(fnl, ".json") {
|
||||
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) {
|
||||
st, filename, ok := detectHttpContext(url)
|
||||
st, filename, ok := detectHTTPContext(url)
|
||||
if !ok {
|
||||
st, ok = detectGitContext(url)
|
||||
if !ok {
|
||||
@ -83,7 +83,7 @@ func ReadRemoteFiles(ctx context.Context, dis []build.DriverInfo, url string, na
|
||||
}
|
||||
|
||||
func IsRemoteURL(url string) bool {
|
||||
if _, _, ok := detectHttpContext(url); ok {
|
||||
if _, _, ok := detectHTTPContext(url); ok {
|
||||
return true
|
||||
}
|
||||
if _, ok := detectGitContext(url); ok {
|
||||
@ -92,7 +92,7 @@ func IsRemoteURL(url string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func detectHttpContext(url string) (*llb.State, string, bool) {
|
||||
func detectHTTPContext(url string) (*llb.State, string, bool) {
|
||||
if httpPrefix.MatchString(url) {
|
||||
httpContext := llb.HTTP(url, llb.Filename("context"), llb.WithCustomName("[internal] load remote build context"))
|
||||
return &httpContext, "context", true
|
||||
|
@ -63,11 +63,14 @@ type buildOptions struct {
|
||||
}
|
||||
|
||||
type commonOptions struct {
|
||||
builder string
|
||||
noCache *bool
|
||||
progress string
|
||||
pull *bool
|
||||
builder string
|
||||
noCache *bool
|
||||
progress string
|
||||
pull *bool
|
||||
// golangci-lint#826
|
||||
// nolint:structcheck
|
||||
exportPush bool
|
||||
// nolint:structcheck
|
||||
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 {
|
||||
fmt.Fprintf(tw, "Shared:\t%.2f\n", units.Bytes(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 {
|
||||
s, err := parseSource(in)
|
||||
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
|
||||
}
|
||||
|
@ -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
|
||||
RUN apk add --no-cache git yamllint
|
||||
RUN go get -u gopkg.in/alecthomas/gometalinter.v1 \
|
||||
&& mv /go/bin/gometalinter.v1 /go/bin/gometalinter \
|
||||
&& gometalinter --install
|
||||
RUN apk add --no-cache gcc musl-dev yamllint
|
||||
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.36.0
|
||||
WORKDIR /go/src/github.com/docker/buildx
|
||||
RUN --mount=target=/go/src/github.com/docker/buildx \
|
||||
gometalinter --config=gometalinter.json ./...
|
||||
RUN --mount=target=/go/src/github.com/docker/buildx \
|
||||
RUN --mount=target=/go/src/github.com/docker/buildx --mount=target=/root/.cache,type=cache \
|
||||
golangci-lint run
|
||||
RUN --mount=target=/go/src/github.com/docker/buildx --mount=target=/root/.cache,type=cache \
|
||||
yamllint -c .yamllint.yml --strict .
|
@ -55,6 +55,6 @@ type pw struct {
|
||||
status chan *client.SolveStatus
|
||||
}
|
||||
|
||||
func (p *pw) Status() chan *client.SolveStatus {
|
||||
return p.status
|
||||
func (w *pw) Status() chan *client.SolveStatus {
|
||||
return w.status
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user