lint: enable linters from buildkit

Skipping errname and testifylint

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2024-11-19 17:51:24 -08:00
parent 0c629335ac
commit c0fd64f4f8
No known key found for this signature in database
GPG Key ID: AFA9DE5F8AB7AF39
15 changed files with 23 additions and 27 deletions

View File

@ -5,23 +5,35 @@ run:
linters: linters:
enable: enable:
- bodyclose
- depguard - depguard
- forbidigo - forbidigo
- gocritic
- gofmt - gofmt
- goimports - goimports
- gosec - gosec
- gosimple - gosimple
- govet - govet
- ineffassign - ineffassign
- makezero
- misspell - misspell
- noctx
- nolintlint - nolintlint
- revive - revive
- staticcheck - staticcheck
- typecheck - typecheck
- unused - unused
- whitespace
disable-all: true disable-all: true
linters-settings: linters-settings:
gocritic:
disabled-checks:
- "ifElseChain"
- "assignOp"
- "appendAssign"
- "singleCaseSwitch"
- "exitAfterDefer" # FIXME
govet: govet:
enable: enable:
- nilness - nilness

View File

@ -179,7 +179,6 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
c.Targets = append(c.Targets, t) c.Targets = append(c.Targets, t)
} }
c.Groups = append(c.Groups, g) c.Groups = append(c.Groups, g)
} }
return &c, nil return &c, nil

View File

@ -170,7 +170,6 @@ func indexOfFunc() function.Function {
} }
} }
return cty.NilVal, errors.New("item not found") return cty.NilVal, errors.New("item not found")
}, },
}) })
} }

View File

@ -288,7 +288,15 @@ func GetBuilders(dockerCli command.Cli, txn *store.Txn) ([]*Builder, error) {
return nil, err return nil, err
} }
builders := make([]*Builder, len(storeng)) contexts, err := dockerCli.ContextStore().List()
if err != nil {
return nil, err
}
sort.Slice(contexts, func(i, j int) bool {
return contexts[i].Name < contexts[j].Name
})
builders := make([]*Builder, len(storeng), len(storeng)+len(contexts))
seen := make(map[string]struct{}) seen := make(map[string]struct{})
for i, ng := range storeng { for i, ng := range storeng {
b, err := New(dockerCli, b, err := New(dockerCli,
@ -303,14 +311,6 @@ func GetBuilders(dockerCli command.Cli, txn *store.Txn) ([]*Builder, error) {
seen[b.NodeGroup.Name] = struct{}{} seen[b.NodeGroup.Name] = struct{}{}
} }
contexts, err := dockerCli.ContextStore().List()
if err != nil {
return nil, err
}
sort.Slice(contexts, func(i, j int) bool {
return contexts[i].Name < contexts[j].Name
})
for _, c := range contexts { for _, c := range contexts {
// if a context has the same name as an instance from the store, do not // if a context has the same name as an instance from the store, do not
// add it to the builders list. An instance from the store takes // add it to the builders list. An instance from the store takes

View File

@ -885,7 +885,6 @@ func printWarnings(w io.Writer, warnings []client.VertexWarning, mode progressui
src.Print(w) src.Print(w)
} }
fmt.Fprintf(w, "\n") fmt.Fprintf(w, "\n")
} }
} }

View File

@ -42,7 +42,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, in createOptions, arg
return errors.Errorf("can't push with no tags specified, please set --tag or --dry-run") return errors.Errorf("can't push with no tags specified, please set --tag or --dry-run")
} }
fileArgs := make([]string, len(in.files)) fileArgs := make([]string, len(in.files), len(in.files)+len(args))
for i, f := range in.files { for i, f := range in.files {
dt, err := os.ReadFile(f) dt, err := os.ReadFile(f)
if err != nil { if err != nil {

View File

@ -46,7 +46,6 @@ func runUse(dockerCli command.Cli, in useOptions) error {
return errors.Errorf("run `docker context use %s` to switch to context %s", in.builder, in.builder) return errors.Errorf("run `docker context use %s` to switch to context %s", in.builder, in.builder)
} }
} }
} }
return errors.Wrapf(err, "failed to find instance %q", in.builder) return errors.Wrapf(err, "failed to find instance %q", in.builder)
} }

View File

@ -153,7 +153,6 @@ func ResolveOptionPaths(options *BuildOptions) (_ *BuildOptions, err error) {
} }
} }
ps = append(ps, p) ps = append(ps, p)
} }
s.Paths = ps s.Paths = ps
ssh = append(ssh, s) ssh = append(ssh, s)

View File

@ -302,7 +302,6 @@ func attachIO(ctx context.Context, stream msgStream, initMessage *pb.InitMessage
out = cfg.stderr out = cfg.stderr
default: default:
return errors.Errorf("unsupported fd %d", file.Fd) return errors.Errorf("unsupported fd %d", file.Fd)
} }
if out == nil { if out == nil {
logrus.Warnf("attachIO: no writer for fd %d", file.Fd) logrus.Warnf("attachIO: no writer for fd %d", file.Fd)

View File

@ -177,7 +177,6 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
break break
} }
} }
} }
_, err := d.DockerAPI.ContainerCreate(ctx, cfg, hc, &network.NetworkingConfig{}, nil, d.Name) _, err := d.DockerAPI.ContainerCreate(ctx, cfg, hc, &network.NetworkingConfig{}, nil, d.Name)
if err != nil && !errdefs.IsConflict(err) { if err != nil && !errdefs.IsConflict(err) {

View File

@ -176,11 +176,6 @@ func resolveBuildKitVersion(ver string) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
//if _, errs := c.Validate(mobyVersion); len(errs) > 0 {
// for _, err := range errs {
// fmt.Printf("%s: %v\n", m.MobyVersionConstraint, err)
// }
//}
if !c.Check(mobyVersion) { if !c.Check(mobyVersion) {
continue continue
} }

View File

@ -978,7 +978,6 @@ func testBakeMultiPlatform(t *testing.T, sb integration.Sandbox) {
require.NotNil(t, img) require.NotNil(t, img)
img = imgs.Find("linux/arm64") img = imgs.Find("linux/arm64")
require.NotNil(t, img) require.NotNil(t, img)
} else { } else {
require.Error(t, err, string(out)) require.Error(t, err, string(out))
require.Contains(t, string(out), "Multi-platform build is not supported") require.Contains(t, string(out), "Multi-platform build is not supported")
@ -1468,7 +1467,7 @@ target "third" {
fstest.CreateFile("docker-bake.hcl", bakefile, 0600), fstest.CreateFile("docker-bake.hcl", bakefile, 0600),
) )
dockerfilePathFirst := filepath.Join("Dockerfile") dockerfilePathFirst := "Dockerfile"
dockerfilePathSecond := filepath.Join("subdir", "Dockerfile") dockerfilePathSecond := filepath.Join("subdir", "Dockerfile")
dockerfilePathThird := filepath.Join("subdir", "subsubdir", "Dockerfile") dockerfilePathThird := filepath.Join("subdir", "subsubdir", "Dockerfile")

View File

@ -649,7 +649,6 @@ func testBuildMultiPlatform(t *testing.T, sb integration.Sandbox) {
require.NotNil(t, img) require.NotNil(t, img)
img = imgs.Find("linux/arm64") img = imgs.Find("linux/arm64")
require.NotNil(t, img) require.NotNil(t, img)
} else { } else {
require.Error(t, err, string(out)) require.Error(t, err, string(out))
require.Contains(t, string(out), "Multi-platform build is not supported") require.Contains(t, string(out), "Multi-platform build is not supported")

View File

@ -138,7 +138,6 @@ func ParseAnnotations(inp []string) (map[exptypes.AnnotationKey]string, error) {
} }
annotations[ak] = v annotations[ak] = v
} }
} }
return annotations, nil return annotations, nil
} }

View File

@ -47,7 +47,6 @@ func (f mockFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.Rea
reader := io.NopCloser(strings.NewReader(desc.Annotations["test_content"])) reader := io.NopCloser(strings.NewReader(desc.Annotations["test_content"]))
return reader, nil return reader, nil
} }
} }
func (r mockResolver) Resolve(ctx context.Context, ref string) (name string, desc ocispec.Descriptor, err error) { func (r mockResolver) Resolve(ctx context.Context, ref string) (name string, desc ocispec.Descriptor, err error) {