Skip to content

Commit b88423b

Browse files
authored
Merge pull request #3053 from tonistiigi/modernize-fixes
lint: apply x/tools/modernize fixes and validation
2 parents 23afb70 + d5d3d3d commit b88423b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+238
-266
lines changed

bake/bake.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,8 @@ func (c Config) loadLinks(name string, t *Target, m map[string]*Target, o map[st
486486
if target == name {
487487
return errors.Errorf("target %s cannot link to itself", target)
488488
}
489-
for _, v := range visited {
490-
if v == target {
491-
return errors.Errorf("infinite loop from %s to %s", name, target)
492-
}
489+
if slices.Contains(visited, target) {
490+
return errors.Errorf("infinite loop from %s to %s", name, target)
493491
}
494492
t2, ok := m[target]
495493
if !ok {

bake/compose.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ type (
315315
stringArray []string
316316
)
317317

318-
func (sa *stringArray) UnmarshalYAML(unmarshal func(interface{}) error) error {
318+
func (sa *stringArray) UnmarshalYAML(unmarshal func(any) error) error {
319319
var multi []string
320320
err := unmarshal(&multi)
321321
if err != nil {
@@ -332,7 +332,7 @@ func (sa *stringArray) UnmarshalYAML(unmarshal func(interface{}) error) error {
332332

333333
// composeExtTarget converts Compose build extension x-bake to bake Target
334334
// https://github.com/compose-spec/compose-spec/blob/master/spec.md#extension
335-
func (t *Target) composeExtTarget(exts map[string]interface{}) error {
335+
func (t *Target) composeExtTarget(exts map[string]any) error {
336336
var xb xbake
337337

338338
ext, ok := exts["x-bake"]

bake/entitlements.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (c EntitlementConf) Prompt(ctx context.Context, isRemote bool, out io.Write
306306
fmt.Fprintf(out, "\nPass %q to grant requested privileges.\n", strings.Join(slices.Concat(flags, flagsFS), " "))
307307
}
308308

309-
args := append([]string(nil), os.Args...)
309+
args := slices.Clone(os.Args)
310310
if v, ok := os.LookupEnv("DOCKER_CLI_PLUGIN_ORIGINAL_CLI_COMMAND"); ok && v != "" {
311311
args[0] = v
312312
}

bake/hcl_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ func TestHCLIndexOfFunc(t *testing.T) {
16451645
require.Empty(t, c.Targets[1].Tags[1])
16461646
}
16471647

1648-
func ptrstr(s interface{}) *string {
1648+
func ptrstr(s any) *string {
16491649
var n *string
16501650
if reflect.ValueOf(s).Kind() == reflect.String {
16511651
ss := s.(string)

bake/hclparser/gohcl/decode.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import (
1515

1616
// DecodeOptions allows customizing sections of the decoding process.
1717
type DecodeOptions struct {
18-
ImpliedType func(gv interface{}) (cty.Type, error)
18+
ImpliedType func(gv any) (cty.Type, error)
1919
Convert func(in cty.Value, want cty.Type) (cty.Value, error)
2020
}
2121

22-
func (o DecodeOptions) DecodeBody(body hcl.Body, ctx *hcl.EvalContext, val interface{}) hcl.Diagnostics {
22+
func (o DecodeOptions) DecodeBody(body hcl.Body, ctx *hcl.EvalContext, val any) hcl.Diagnostics {
2323
o = o.withDefaults()
2424

2525
rv := reflect.ValueOf(val)
@@ -46,7 +46,7 @@ func (o DecodeOptions) DecodeBody(body hcl.Body, ctx *hcl.EvalContext, val inter
4646
// are returned then the given value may have been partially-populated but
4747
// may still be accessed by a careful caller for static analysis and editor
4848
// integration use-cases.
49-
func DecodeBody(body hcl.Body, ctx *hcl.EvalContext, val interface{}) hcl.Diagnostics {
49+
func DecodeBody(body hcl.Body, ctx *hcl.EvalContext, val any) hcl.Diagnostics {
5050
return DecodeOptions{}.DecodeBody(body, ctx, val)
5151
}
5252

@@ -282,7 +282,7 @@ func (o DecodeOptions) decodeBlockToValue(block *hcl.Block, ctx *hcl.EvalContext
282282
return diags
283283
}
284284

285-
func (o DecodeOptions) DecodeExpression(expr hcl.Expression, ctx *hcl.EvalContext, val interface{}) hcl.Diagnostics {
285+
func (o DecodeOptions) DecodeExpression(expr hcl.Expression, ctx *hcl.EvalContext, val any) hcl.Diagnostics {
286286
o = o.withDefaults()
287287

288288
srcVal, diags := expr.Value(ctx)
@@ -332,7 +332,7 @@ func (o DecodeOptions) DecodeExpression(expr hcl.Expression, ctx *hcl.EvalContex
332332
// are returned then the given value may have been partially-populated but
333333
// may still be accessed by a careful caller for static analysis and editor
334334
// integration use-cases.
335-
func DecodeExpression(expr hcl.Expression, ctx *hcl.EvalContext, val interface{}) hcl.Diagnostics {
335+
func DecodeExpression(expr hcl.Expression, ctx *hcl.EvalContext, val any) hcl.Diagnostics {
336336
return DecodeOptions{}.DecodeExpression(expr, ctx, val)
337337
}
338338

0 commit comments

Comments
 (0)