Skip to content

Commit 3e037bb

Browse files
committed
fix go.mod and lint issues
Signed-off-by: CrazyMax <[email protected]>
1 parent bf95aa3 commit 3e037bb

File tree

12 files changed

+28
-45
lines changed

12 files changed

+28
-45
lines changed

bake/bake.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding"
66
"io"
7+
"maps"
78
"os"
89
"path"
910
"path/filepath"
@@ -1104,9 +1105,7 @@ func (t *Target) GetEvalContexts(ectx *hcl.EvalContext, block *hcl.Block, loadDe
11041105
e2 := ectx.NewChild()
11051106
e2.Variables = make(map[string]cty.Value)
11061107
if e != ectx {
1107-
for k, v := range e.Variables {
1108-
e2.Variables[k] = v
1109-
}
1108+
maps.Copy(e2.Variables, e.Variables)
11101109
}
11111110
e2.Variables[k] = v
11121111
ectxs2 = append(ectxs2, e2)

bake/compose.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bake
33
import (
44
"context"
55
"fmt"
6+
"maps"
67
"os"
78
"path/filepath"
89
"slices"
@@ -90,10 +91,7 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
9091

9192
var additionalContexts map[string]string
9293
if s.Build.AdditionalContexts != nil {
93-
additionalContexts = map[string]string{}
94-
for k, v := range s.Build.AdditionalContexts {
95-
additionalContexts[k] = v
96-
}
94+
additionalContexts = maps.Clone(s.Build.AdditionalContexts)
9795
}
9896

9997
var shmSize *string

build/build.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/json"
99
"fmt"
1010
"io"
11+
"maps"
1112
"os"
1213
"slices"
1314
"strconv"
@@ -431,9 +432,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opts map[
431432
FrontendInputs: frontendInputs,
432433
FrontendOpt: make(map[string]string),
433434
}
434-
for k, v := range so.FrontendAttrs {
435-
req.FrontendOpt[k] = v
436-
}
435+
maps.Copy(req.FrontendOpt, so.FrontendAttrs)
437436
so.Frontend = ""
438437
so.FrontendInputs = nil
439438

build/git.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package build
22

33
import (
44
"context"
5+
"maps"
56
"os"
67
"path"
78
"path/filepath"
@@ -127,9 +128,7 @@ func getGitAttributes(ctx context.Context, contextPath, dockerfilePath string) (
127128
if so.FrontendAttrs == nil {
128129
so.FrontendAttrs = make(map[string]string)
129130
}
130-
for k, v := range res {
131-
so.FrontendAttrs[k] = v
132-
}
131+
maps.Copy(so.FrontendAttrs, res)
133132

134133
if !setGitInfo || root == "" {
135134
return

build/provenance.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/base64"
66
"encoding/json"
77
"io"
8+
"maps"
89
"strings"
910
"sync"
1011

@@ -40,9 +41,7 @@ func setRecordProvenance(ctx context.Context, c *client.Client, sr *client.Solve
4041
if err != nil {
4142
return err
4243
}
43-
for k, v := range res {
44-
sr.ExporterResponse[k] = v
45-
}
44+
maps.Copy(sr.ExporterResponse, res)
4645
return nil
4746
})
4847
}

commands/ls.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"maps"
78
"sort"
89
"strings"
910
"time"
@@ -409,9 +410,7 @@ func truncPlatforms(pfs []string, max int) truncatedPlatforms {
409410
left[ppf] = append(left[ppf], pf)
410411
}
411412
}
412-
for k, v := range left {
413-
res[k] = v
414-
}
413+
maps.Copy(res, left)
415414
return truncatedPlatforms{
416415
res: res,
417416
input: pfs,

controller/pb/cache.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package pb
22

3-
import "github.com/moby/buildkit/client"
3+
import (
4+
"maps"
5+
6+
"github.com/moby/buildkit/client"
7+
)
48

59
func CreateCaches(entries []*CacheOptionsEntry) []client.CacheOptionsEntry {
610
var outs []client.CacheOptionsEntry
@@ -12,9 +16,7 @@ func CreateCaches(entries []*CacheOptionsEntry) []client.CacheOptionsEntry {
1216
Type: entry.Type,
1317
Attrs: map[string]string{},
1418
}
15-
for k, v := range entry.Attrs {
16-
out.Attrs[k] = v
17-
}
19+
maps.Copy(out.Attrs, entry.Attrs)
1820
outs = append(outs, out)
1921
}
2022
return outs

controller/pb/export.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package pb
22

33
import (
44
"io"
5+
"maps"
56
"os"
67
"strconv"
78

@@ -26,9 +27,7 @@ func CreateExports(entries []*ExportEntry) ([]client.ExportEntry, []string, erro
2627
Type: entry.Type,
2728
Attrs: map[string]string{},
2829
}
29-
for k, v := range entry.Attrs {
30-
out.Attrs[k] = v
31-
}
30+
maps.Copy(out.Attrs, entry.Attrs)
3231

3332
supportFile := false
3433
supportDir := false

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/docker/buildx
22

3-
go 1.23
4-
5-
toolchain go1.23.7
3+
go 1.23.0
64

75
require (
86
github.com/Masterminds/semver/v3 v3.2.1

store/nodegroup.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package store
22

33
import (
44
"fmt"
5+
"maps"
56
"slices"
67
"time"
78

@@ -93,9 +94,7 @@ func (ng *NodeGroup) Update(name, endpoint string, platforms []string, endpoints
9394
needsRestart = true
9495
}
9596
if buildkitdConfigFile != "" {
96-
for k, v := range files {
97-
n.Files[k] = v
98-
}
97+
maps.Copy(n.Files, files)
9998
needsRestart = true
10099
}
101100
if needsRestart {
@@ -146,10 +145,7 @@ func (n *Node) Copy() *Node {
146145
copy(platforms, n.Platforms)
147146
buildkitdFlags := []string{}
148147
copy(buildkitdFlags, n.BuildkitdFlags)
149-
driverOpts := map[string]string{}
150-
for k, v := range n.DriverOpts {
151-
driverOpts[k] = v
152-
}
148+
driverOpts := maps.Clone(n.DriverOpts)
153149
files := map[string][]byte{}
154150
for k, v := range n.Files {
155151
vv := []byte{}

util/imagetools/create.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann map[exptypes
107107
if old.Annotations == nil {
108108
old.Annotations = map[string]string{}
109109
}
110-
for k, v := range d.Annotations {
111-
old.Annotations[k] = v
112-
}
110+
maps.Copy(old.Annotations, d.Annotations)
113111
newDescs[idx] = old
114112
} else {
115113
m[d.Digest] = len(newDescs)

util/imagetools/loader.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"encoding/base64"
88
"encoding/json"
9+
"maps"
910
"regexp"
1011
"sort"
1112
"strings"
@@ -127,12 +128,8 @@ func (l *loader) Load(ctx context.Context, ref string) (*result, error) {
127128

128129
var a asset
129130
annotations := make(map[string]string, len(mfst.manifest.Annotations)+len(mfst.desc.Annotations))
130-
for k, v := range mfst.desc.Annotations {
131-
annotations[k] = v
132-
}
133-
for k, v := range mfst.manifest.Annotations {
134-
annotations[k] = v
135-
}
131+
annotations = maps.Clone(mfst.desc.Annotations)
132+
maps.Copy(annotations, mfst.manifest.Annotations)
136133

137134
if err := l.scanConfig(ctx, fetcher, mfst.manifest.Config, &a); err != nil {
138135
return nil, err

0 commit comments

Comments
 (0)