Skip to content

Commit

Permalink
fix lint issues after update
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Oct 19, 2023
1 parent 6e5aefb commit 503d483
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 51 deletions.
1 change: 1 addition & 0 deletions bake/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 9 additions & 6 deletions bake/hclparser/hclparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
}
}
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -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())
}
}

Expand Down
1 change: 1 addition & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var (
)

const (
//nolint:gosec // G101: false-positive
printFallbackImage = "docker/dockerfile:1.5.2-labs@sha256:f2e91734a84c0922ff47aa4098ab775f1dfa932430d2888dd5cad5251fafdac4"
)

Expand Down
11 changes: 2 additions & 9 deletions commands/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions controller/pb/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 4 additions & 13 deletions driver/docker-container/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions driver/kubernetes/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}
Expand Down Expand Up @@ -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,
Expand All @@ -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")
}
11 changes: 2 additions & 9 deletions store/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand All @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/workers/docker-container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 503d483

Please sign in to comment.