Skip to content

Commit

Permalink
lint: apply x/tools/modernize fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Mar 8, 2025
1 parent e19c729 commit d5d3d3d
Show file tree
Hide file tree
Showing 50 changed files with 238 additions and 266 deletions.
6 changes: 2 additions & 4 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,8 @@ func (c Config) loadLinks(name string, t *Target, m map[string]*Target, o map[st
if target == name {
return errors.Errorf("target %s cannot link to itself", target)
}
for _, v := range visited {
if v == target {
return errors.Errorf("infinite loop from %s to %s", name, target)
}
if slices.Contains(visited, target) {
return errors.Errorf("infinite loop from %s to %s", name, target)
}
t2, ok := m[target]
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions bake/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ type (
stringArray []string
)

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

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

ext, ok := exts["x-bake"]
Expand Down
2 changes: 1 addition & 1 deletion bake/entitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (c EntitlementConf) Prompt(ctx context.Context, isRemote bool, out io.Write
fmt.Fprintf(out, "\nPass %q to grant requested privileges.\n", strings.Join(slices.Concat(flags, flagsFS), " "))
}

args := append([]string(nil), os.Args...)
args := slices.Clone(os.Args)
if v, ok := os.LookupEnv("DOCKER_CLI_PLUGIN_ORIGINAL_CLI_COMMAND"); ok && v != "" {
args[0] = v
}
Expand Down
2 changes: 1 addition & 1 deletion bake/hcl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ func TestHCLIndexOfFunc(t *testing.T) {
require.Empty(t, c.Targets[1].Tags[1])
}

func ptrstr(s interface{}) *string {
func ptrstr(s any) *string {
var n *string
if reflect.ValueOf(s).Kind() == reflect.String {
ss := s.(string)
Expand Down
10 changes: 5 additions & 5 deletions bake/hclparser/gohcl/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (

// DecodeOptions allows customizing sections of the decoding process.
type DecodeOptions struct {
ImpliedType func(gv interface{}) (cty.Type, error)
ImpliedType func(gv any) (cty.Type, error)
Convert func(in cty.Value, want cty.Type) (cty.Value, error)
}

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

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

Expand Down Expand Up @@ -282,7 +282,7 @@ func (o DecodeOptions) decodeBlockToValue(block *hcl.Block, ctx *hcl.EvalContext
return diags
}

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

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

Expand Down
Loading

0 comments on commit d5d3d3d

Please sign in to comment.