fix go.mod and lint issues

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2025-03-19 11:52:08 +01:00
parent bf95aa3dfa
commit 212d598ab1
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
12 changed files with 29 additions and 44 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding" "encoding"
"io" "io"
"maps"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -1104,9 +1105,7 @@ func (t *Target) GetEvalContexts(ectx *hcl.EvalContext, block *hcl.Block, loadDe
e2 := ectx.NewChild() e2 := ectx.NewChild()
e2.Variables = make(map[string]cty.Value) e2.Variables = make(map[string]cty.Value)
if e != ectx { if e != ectx {
for k, v := range e.Variables { maps.Copy(e2.Variables, e.Variables)
e2.Variables[k] = v
}
} }
e2.Variables[k] = v e2.Variables[k] = v
ectxs2 = append(ectxs2, e2) ectxs2 = append(ectxs2, e2)

View File

@ -3,6 +3,7 @@ package bake
import ( import (
"context" "context"
"fmt" "fmt"
"maps"
"os" "os"
"path/filepath" "path/filepath"
"slices" "slices"
@ -91,9 +92,7 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
var additionalContexts map[string]string var additionalContexts map[string]string
if s.Build.AdditionalContexts != nil { if s.Build.AdditionalContexts != nil {
additionalContexts = map[string]string{} additionalContexts = map[string]string{}
for k, v := range s.Build.AdditionalContexts { maps.Copy(additionalContexts, s.Build.AdditionalContexts)
additionalContexts[k] = v
}
} }
var shmSize *string var shmSize *string

View File

@ -8,6 +8,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"maps"
"os" "os"
"slices" "slices"
"strconv" "strconv"
@ -431,9 +432,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opts map[
FrontendInputs: frontendInputs, FrontendInputs: frontendInputs,
FrontendOpt: make(map[string]string), FrontendOpt: make(map[string]string),
} }
for k, v := range so.FrontendAttrs { maps.Copy(req.FrontendOpt, so.FrontendAttrs)
req.FrontendOpt[k] = v
}
so.Frontend = "" so.Frontend = ""
so.FrontendInputs = nil so.FrontendInputs = nil

View File

@ -2,6 +2,7 @@ package build
import ( import (
"context" "context"
"maps"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -127,9 +128,7 @@ func getGitAttributes(ctx context.Context, contextPath, dockerfilePath string) (
if so.FrontendAttrs == nil { if so.FrontendAttrs == nil {
so.FrontendAttrs = make(map[string]string) so.FrontendAttrs = make(map[string]string)
} }
for k, v := range res { maps.Copy(so.FrontendAttrs, res)
so.FrontendAttrs[k] = v
}
if !setGitInfo || root == "" { if !setGitInfo || root == "" {
return return

View File

@ -5,6 +5,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"io" "io"
"maps"
"strings" "strings"
"sync" "sync"
@ -40,9 +41,7 @@ func setRecordProvenance(ctx context.Context, c *client.Client, sr *client.Solve
if err != nil { if err != nil {
return err return err
} }
for k, v := range res { maps.Copy(sr.ExporterResponse, res)
sr.ExporterResponse[k] = v
}
return nil return nil
}) })
} }

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"maps"
"sort" "sort"
"strings" "strings"
"time" "time"
@ -409,9 +410,7 @@ func truncPlatforms(pfs []string, max int) truncatedPlatforms {
left[ppf] = append(left[ppf], pf) left[ppf] = append(left[ppf], pf)
} }
} }
for k, v := range left { maps.Copy(res, left)
res[k] = v
}
return truncatedPlatforms{ return truncatedPlatforms{
res: res, res: res,
input: pfs, input: pfs,

View File

@ -1,6 +1,10 @@
package pb package pb
import "github.com/moby/buildkit/client" import (
"maps"
"github.com/moby/buildkit/client"
)
func CreateCaches(entries []*CacheOptionsEntry) []client.CacheOptionsEntry { func CreateCaches(entries []*CacheOptionsEntry) []client.CacheOptionsEntry {
var outs []client.CacheOptionsEntry var outs []client.CacheOptionsEntry
@ -12,9 +16,7 @@ func CreateCaches(entries []*CacheOptionsEntry) []client.CacheOptionsEntry {
Type: entry.Type, Type: entry.Type,
Attrs: map[string]string{}, Attrs: map[string]string{},
} }
for k, v := range entry.Attrs { maps.Copy(out.Attrs, entry.Attrs)
out.Attrs[k] = v
}
outs = append(outs, out) outs = append(outs, out)
} }
return outs return outs

View File

@ -2,6 +2,7 @@ package pb
import ( import (
"io" "io"
"maps"
"os" "os"
"strconv" "strconv"
@ -26,9 +27,7 @@ func CreateExports(entries []*ExportEntry) ([]client.ExportEntry, []string, erro
Type: entry.Type, Type: entry.Type,
Attrs: map[string]string{}, Attrs: map[string]string{},
} }
for k, v := range entry.Attrs { maps.Copy(out.Attrs, entry.Attrs)
out.Attrs[k] = v
}
supportFile := false supportFile := false
supportDir := false supportDir := false

4
go.mod
View File

@ -1,8 +1,6 @@
module github.com/docker/buildx module github.com/docker/buildx
go 1.23 go 1.23.0
toolchain go1.23.7
require ( require (
github.com/Masterminds/semver/v3 v3.2.1 github.com/Masterminds/semver/v3 v3.2.1

View File

@ -2,6 +2,7 @@ package store
import ( import (
"fmt" "fmt"
"maps"
"slices" "slices"
"time" "time"
@ -93,9 +94,7 @@ func (ng *NodeGroup) Update(name, endpoint string, platforms []string, endpoints
needsRestart = true needsRestart = true
} }
if buildkitdConfigFile != "" { if buildkitdConfigFile != "" {
for k, v := range files { maps.Copy(n.Files, files)
n.Files[k] = v
}
needsRestart = true needsRestart = true
} }
if needsRestart { if needsRestart {
@ -147,9 +146,7 @@ func (n *Node) Copy() *Node {
buildkitdFlags := []string{} buildkitdFlags := []string{}
copy(buildkitdFlags, n.BuildkitdFlags) copy(buildkitdFlags, n.BuildkitdFlags)
driverOpts := map[string]string{} driverOpts := map[string]string{}
for k, v := range n.DriverOpts { maps.Copy(driverOpts, n.DriverOpts)
driverOpts[k] = v
}
files := map[string][]byte{} files := map[string][]byte{}
for k, v := range n.Files { for k, v := range n.Files {
vv := []byte{} vv := []byte{}

View File

@ -107,9 +107,7 @@ func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann map[exptypes
if old.Annotations == nil { if old.Annotations == nil {
old.Annotations = map[string]string{} old.Annotations = map[string]string{}
} }
for k, v := range d.Annotations { maps.Copy(old.Annotations, d.Annotations)
old.Annotations[k] = v
}
newDescs[idx] = old newDescs[idx] = old
} else { } else {
m[d.Digest] = len(newDescs) m[d.Digest] = len(newDescs)

View File

@ -6,6 +6,7 @@ import (
"context" "context"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"maps"
"regexp" "regexp"
"sort" "sort"
"strings" "strings"
@ -126,13 +127,9 @@ func (l *loader) Load(ctx context.Context, ref string) (*result, error) {
} }
var a asset var a asset
annotations := make(map[string]string, len(mfst.manifest.Annotations)+len(mfst.desc.Annotations)) annotations := map[string]string{}
for k, v := range mfst.desc.Annotations { maps.Copy(annotations, mfst.desc.Annotations)
annotations[k] = v maps.Copy(annotations, mfst.manifest.Annotations)
}
for k, v := range mfst.manifest.Annotations {
annotations[k] = v
}
if err := l.scanConfig(ctx, fetcher, mfst.manifest.Config, &a); err != nil { if err := l.scanConfig(ctx, fetcher, mfst.manifest.Config, &a); err != nil {
return nil, err return nil, err