fix lint issues after update

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-10-19 12:31:24 +02:00
parent 6e5aefbb98
commit 503d483731
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
11 changed files with 28 additions and 51 deletions

View File

@ -51,6 +51,7 @@ func ParseCompose(cfgs []compose.ConfigFile, envs map[string]string) (*Config, e
g := &Group{Name: "default"}
for _, s := range cfg.Services {
s := s
if s.Build == nil {
continue
}

View File

@ -631,13 +631,14 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
}
for _, a := range content.Attributes {
a := a
return nil, hcl.Diagnostics{
&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Invalid attribute",
Detail: "global attributes currently not supported",
Subject: &a.Range,
Context: &a.Range,
Subject: a.Range.Ptr(),
Context: a.Range.Ptr(),
},
}
}
@ -660,13 +661,14 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
var subject *hcl.Range
var context *hcl.Range
if p.funcs[k].Params != nil {
subject = &p.funcs[k].Params.Range
subject = p.funcs[k].Params.Range.Ptr()
context = subject
} else {
for _, block := range blocks.Blocks {
block := block
if block.Type == "function" && len(block.Labels) == 1 && block.Labels[0] == k {
subject = &block.LabelRanges[0]
context = &block.DefRange
subject = block.LabelRanges[0].Ptr()
context = block.DefRange.Ptr()
break
}
}
@ -732,6 +734,7 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
diags = hcl.Diagnostics{}
for _, b := range content.Blocks {
b := b
v := reflect.ValueOf(val)
err := p.resolveBlock(b, nil)
@ -742,7 +745,7 @@ func Parse(b hcl.Body, opt Opt, val interface{}) (map[string]map[string][]string
continue
}
} else {
return nil, wrapErrorDiagnostic("Invalid block", err, &b.LabelRanges[0], &b.DefRange)
return nil, wrapErrorDiagnostic("Invalid block", err, b.LabelRanges[0].Ptr(), b.DefRange.Ptr())
}
}

View File

@ -65,6 +65,7 @@ var (
)
const (
//nolint:gosec // G101: false-positive
printFallbackImage = "docker/dockerfile:1.5.2-labs@sha256:f2e91734a84c0922ff47aa4098ab775f1dfa932430d2888dd5cad5251fafdac4"
)

View File

@ -35,10 +35,7 @@ func runUse(dockerCli command.Cli, in useOptions) error {
if err != nil {
return err
}
if err := txn.SetCurrent(ep, "", false, false); err != nil {
return err
}
return nil
return txn.SetCurrent(ep, "", false, false)
}
list, err := dockerCli.ContextStore().List()
if err != nil {
@ -58,11 +55,7 @@ func runUse(dockerCli command.Cli, in useOptions) error {
if err != nil {
return err
}
if err := txn.SetCurrent(ep, in.builder, in.isGlobal, in.isDefault); err != nil {
return err
}
return nil
return txn.SetCurrent(ep, in.builder, in.isGlobal, in.isDefault)
}
func useCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {

View File

@ -236,6 +236,7 @@ func TestResolvePaths(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := ResolveOptionPaths(&tt.options)
require.NoError(t, err)

View File

@ -73,10 +73,7 @@ func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
if err := d.start(ctx, sub); err != nil {
return err
}
if err := d.wait(ctx, sub); err != nil {
return err
}
return nil
return d.wait(ctx, sub)
})
})
}
@ -119,7 +116,7 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
}
useInit := true // let it cleanup exited processes created by BuildKit's container API
if err := l.Wrap("creating container "+d.Name, func() error {
return l.Wrap("creating container "+d.Name, func() error {
hc := &container.HostConfig{
Privileged: true,
Mounts: []mount.Mount{
@ -189,14 +186,8 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
return err
}
}
if err := d.wait(ctx, l); err != nil {
return err
}
return nil
}); err != nil {
return err
}
return nil
return d.wait(ctx, l)
})
}
func (d *Driver) wait(ctx context.Context, l progress.SubLogger) error {

View File

@ -87,10 +87,7 @@ func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
return sub.Wrap(
fmt.Sprintf("waiting for %d pods to be ready", d.minReplicas),
func() error {
if err := d.wait(ctx); err != nil {
return err
}
return nil
return d.wait(ctx)
})
})
}
@ -228,7 +225,7 @@ func (d *Driver) Factory() driver.Factory {
return d.factory
}
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
func (d *Driver) Features(_ context.Context) map[driver.Feature]bool {
return map[driver.Feature]bool{
driver.OCIExporter: true,
driver.DockerExporter: d.DockerAPI != nil,
@ -237,6 +234,6 @@ func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
}
}
func (d *Driver) HostGatewayIP(ctx context.Context) (net.IP, error) {
func (d *Driver) HostGatewayIP(_ context.Context) (net.IP, error) {
return nil, errors.New("host-gateway is not supported by the kubernetes driver")
}

View File

@ -102,10 +102,7 @@ func (ng *NodeGroup) Update(name, endpoint string, platforms []string, endpoints
}
ng.Nodes[i] = n
if err := ng.validateDuplicates(endpoint, i); err != nil {
return err
}
return nil
return ng.validateDuplicates(endpoint, i)
}
if name == "" {
@ -127,11 +124,7 @@ func (ng *NodeGroup) Update(name, endpoint string, platforms []string, endpoints
}
ng.Nodes = append(ng.Nodes, n)
if err := ng.validateDuplicates(endpoint, len(ng.Nodes)-1); err != nil {
return err
}
return nil
return ng.validateDuplicates(endpoint, len(ng.Nodes)-1)
}
func (ng *NodeGroup) Copy() *NodeGroup {

View File

@ -185,10 +185,7 @@ func (t *Txn) reset(key string) error {
if err != nil {
return err
}
if err := ioutils.AtomicWriteFile(filepath.Join(t.s.root, "current"), dt, 0600); err != nil {
return err
}
return nil
return ioutils.AtomicWriteFile(filepath.Join(t.s.root, "current"), dt, 0600)
}
func (t *Txn) Current(key string) (*NodeGroup, error) {

View File

@ -18,9 +18,9 @@ func TestEmptyStartup(t *testing.T) {
s, err := New(tmpdir)
require.NoError(t, err)
txn, close, err := s.Txn()
txn, release, err := s.Txn()
require.NoError(t, err)
defer close()
defer release()
ng, err := txn.Current("foo")
require.NoError(t, err)

View File

@ -80,8 +80,8 @@ func (w *containerWorker) New(ctx context.Context, cfg *integration.BackendConfi
}
func (w *containerWorker) Close() error {
if close := w.dockerClose; close != nil {
return close()
if c := w.dockerClose; c != nil {
return c()
}
// reset the worker to be ready to go again