Merge pull request #3182 from crazy-max/go-1.24

update to go 1.24
This commit is contained in:
Tõnis Tiigi
2025-05-13 12:14:37 -07:00
committed by GitHub
35 changed files with 26 additions and 62 deletions
+2 -2
View File
@@ -36,8 +36,8 @@ env:
TEST_CACHE_SCOPE: "test"
TESTFLAGS: "-v --parallel=6 --timeout=30m"
GOTESTSUM_FORMAT: "standard-verbose"
GO_VERSION: "1.23"
GOTESTSUM_VERSION: "v1.9.0" # same as one in Dockerfile
GO_VERSION: "1.24"
GOTESTSUM_VERSION: "v1.12.0" # same as one in Dockerfile
jobs:
test-integration:
+1 -1
View File
@@ -17,7 +17,7 @@ on:
pull_request:
env:
GO_VERSION: "1.23"
GO_VERSION: "1.24"
jobs:
codeql:
+1 -1
View File
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.23
ARG GO_VERSION=1.24
ARG ALPINE_VERSION=3.21
ARG XX_VERSION=1.6.1
+9 -10
View File
@@ -483,8 +483,7 @@ func (c Config) expandTargets(pattern string) ([]string, error) {
func (c Config) loadLinks(name string, t *Target, m map[string]*Target, o map[string]map[string]Override, visited []string, ent *EntitlementConf) error {
visited = append(visited, name)
for _, v := range t.Contexts {
if strings.HasPrefix(v, "target:") {
target := strings.TrimPrefix(v, "target:")
if target, ok := strings.CutPrefix(v, "target:"); ok {
if target == name {
return errors.Errorf("target %s cannot link to itself", target)
}
@@ -1275,8 +1274,8 @@ func collectLocalPaths(t build.Inputs) []string {
if v, ok := isLocalPath(t.DockerfilePath); ok {
out = append(out, v)
}
} else if strings.HasPrefix(t.ContextPath, "cwd://") {
out = append(out, strings.TrimPrefix(t.ContextPath, "cwd://"))
} else if v, ok := strings.CutPrefix(t.ContextPath, "cwd://"); ok {
out = append(out, v)
}
for _, v := range t.NamedContexts {
if v.State != nil {
@@ -1328,11 +1327,11 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
bi.DockerfileInline = *t.DockerfileInline
}
updateContext(&bi, inp)
if strings.HasPrefix(bi.DockerfilePath, "cwd://") {
if v, ok := strings.CutPrefix(bi.DockerfilePath, "cwd://"); ok {
// If Dockerfile is local for a remote invocation, we first check if
// it's not outside the working directory and then resolve it to an
// absolute path.
bi.DockerfilePath = path.Clean(strings.TrimPrefix(bi.DockerfilePath, "cwd://"))
bi.DockerfilePath = path.Clean(v)
var err error
bi.DockerfilePath, err = filepath.Abs(bi.DockerfilePath)
if err != nil {
@@ -1357,15 +1356,15 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
return nil, errors.Errorf("reading a dockerfile for a remote build invocation is currently not supported")
}
}
if strings.HasPrefix(bi.ContextPath, "cwd://") {
bi.ContextPath = path.Clean(strings.TrimPrefix(bi.ContextPath, "cwd://"))
if v, ok := strings.CutPrefix(bi.ContextPath, "cwd://"); ok {
bi.ContextPath = path.Clean(v)
}
if !build.IsRemoteURL(bi.ContextPath) && bi.ContextState == nil && !filepath.IsAbs(bi.DockerfilePath) {
bi.DockerfilePath = filepath.Join(bi.ContextPath, bi.DockerfilePath)
}
for k, v := range bi.NamedContexts {
if strings.HasPrefix(v.Path, "cwd://") {
bi.NamedContexts[k] = build.NamedContext{Path: path.Clean(strings.TrimPrefix(v.Path, "cwd://"))}
if v, ok := strings.CutPrefix(v.Path, "cwd://"); ok {
bi.NamedContexts[k] = build.NamedContext{Path: path.Clean(v)}
}
}
-4
View File
@@ -1381,7 +1381,6 @@ target "d" {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
m, g, err := ReadTargets(ctx, []File{f}, []string{"d"}, tt.overrides, nil, &EntitlementConf{})
require.NoError(t, err)
@@ -1454,7 +1453,6 @@ group "default" {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
m, g, err := ReadTargets(ctx, []File{f}, []string{"default"}, tt.overrides, nil, &EntitlementConf{})
require.NoError(t, err)
@@ -1509,7 +1507,6 @@ func TestTargetName(t *testing.T) {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.target, func(t *testing.T) {
_, _, err := ReadTargets(ctx, []File{{
Name: "docker-bake.hcl",
@@ -1600,7 +1597,6 @@ target "f" {
},
}
for _, tt := range cases {
tt := tt
t.Run(strings.Join(tt.names, "+"), func(t *testing.T) {
m, g, err := ReadTargets(ctx, []File{f}, tt.names, nil, nil, &EntitlementConf{})
require.NoError(t, err)
-2
View File
@@ -62,7 +62,6 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
g := &Group{Name: "default"}
for _, s := range cfg.Services {
s := s
if s.Build == nil {
continue
}
@@ -144,7 +143,6 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
// compose does not support nil values for labels
labels := map[string]*string{}
for k, v := range s.Build.Labels {
v := v
labels[k] = &v
}
-3
View File
@@ -518,7 +518,6 @@ func TestServiceName(t *testing.T) {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.svc, func(t *testing.T) {
_, err := ParseCompose([]composetypes.ConfigFile{{Content: []byte(`
services:
@@ -589,7 +588,6 @@ services:
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
_, err := ParseCompose([]composetypes.ConfigFile{{Content: tt.dt}}, nil)
if tt.wantErr {
@@ -665,7 +663,6 @@ target "default" {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
isCompose, err := validateComposeFile(tt.dt, tt.fn)
assert.Equal(t, tt.isCompose, isCompose)
-3
View File
@@ -781,7 +781,6 @@ func Parse(b hcl.Body, opt Opt, val any) (*ParseMeta, hcl.Diagnostics) {
}
for _, a := range content.Attributes {
a := a
return nil, hcl.Diagnostics{
&hcl.Diagnostic{
Severity: hcl.DiagError,
@@ -834,7 +833,6 @@ func Parse(b hcl.Body, opt Opt, val any) (*ParseMeta, hcl.Diagnostics) {
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].Ptr()
context = block.DefRange.Ptr()
@@ -903,7 +901,6 @@ func Parse(b hcl.Body, opt Opt, val any) (*ParseMeta, hcl.Diagnostics) {
diags = hcl.Diagnostics{}
for _, b := range content.Blocks {
b := b
v := reflect.ValueOf(val)
err := p.resolveBlock(b, nil)
-1
View File
@@ -383,7 +383,6 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opts map[
wg.Add(1)
sharedSessionsWG[node.Name] = wg
for _, s := range sessions {
s := s
eg.Go(func() error {
return s.Run(baseCtx, c.Dialer())
})
-1
View File
@@ -109,7 +109,6 @@ func TestGetGitAttributes(t *testing.T) {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
setupTest(t)
if tt.envGitLabels != "" {
+1 -2
View File
@@ -503,8 +503,7 @@ func loadInputs(ctx context.Context, d *driver.DriverHandle, inp *Inputs, pw pro
}
// handle OCI layout
if strings.HasPrefix(v.Path, "oci-layout://") {
localPath := strings.TrimPrefix(v.Path, "oci-layout://")
if localPath, ok := strings.CutPrefix(v.Path, "oci-layout://"); ok {
localPath, dig, hasDigest := strings.Cut(localPath, "@")
localPath, tag, hasTag := strings.Cut(localPath, ":")
if !hasTag {
-1
View File
@@ -92,7 +92,6 @@ func fetchProvenance(ctx context.Context, c *client.Client, ref string, mode con
})
} else if ev.Record.Results != nil {
for platform, res := range ev.Record.Results {
platform := platform
desc := lookupProvenance(res)
if desc == nil {
continue
-1
View File
@@ -130,7 +130,6 @@ func TestToBuildkitExtraHosts(t *testing.T) {
}
for _, tc := range tests {
tc := tc
if tc.expectedOut == "" {
tc.expectedOut = strings.Join(tc.input, ",")
}
-1
View File
@@ -190,7 +190,6 @@ foo = "bar"
},
}
for _, tt := range testCases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
flags, err := parseBuildkitdFlags(tt.flags, tt.driver, tt.driverOpts, tt.buildkitdConfigFile)
if tt.wantErr {
+1 -2
View File
@@ -559,8 +559,7 @@ func readBakeFiles(ctx context.Context, nodes []builder.Node, url string, names
var rnames []string // remote
var anames []string // both
for _, v := range names {
if strings.HasPrefix(v, "cwd://") {
tname := strings.TrimPrefix(v, "cwd://")
if tname, ok := strings.CutPrefix(v, "cwd://"); ok {
lnames = append(lnames, tname)
anames = append(anames, tname)
} else {
+2 -2
View File
@@ -869,9 +869,9 @@ func printTable(w io.Writer, kvs []keyValueOutput, title string) {
func readKeyValues(attrs map[string]string, prefix string) []keyValueOutput {
var out []keyValueOutput
for k, v := range attrs {
if strings.HasPrefix(k, prefix) {
if name, ok := strings.CutPrefix(k, prefix); ok {
out = append(out, keyValueOutput{
Name: strings.TrimPrefix(k, prefix),
Name: name,
Value: v,
})
}
-1
View File
@@ -43,7 +43,6 @@ func runRm(ctx context.Context, dockerCli command.Cli, opts rmOptions) error {
eg, ctx := errgroup.WithContext(ctx)
for i, node := range nodes {
node := node
eg.Go(func() error {
if node.Driver == nil {
return nil
-1
View File
@@ -139,7 +139,6 @@ func queryRecords(ctx context.Context, ref string, nodes []builder.Node, opts *q
eg, ctx := errgroup.WithContext(ctx)
for _, node := range nodes {
node := node
eg.Go(func() error {
if node.Driver == nil {
return nil
-1
View File
@@ -184,7 +184,6 @@ func runCreate(ctx context.Context, dockerCli command.Cli, in createOptions, arg
pw := progress.WithPrefix(printer, "internal", true)
for _, t := range tags {
t := t
eg.Go(func() error {
return progress.Wrap(fmt.Sprintf("pushing %s", t.String()), pw.Write, func(sub progress.SubLogger) error {
eg2, _ := errgroup.WithContext(ctx)
-1
View File
@@ -164,7 +164,6 @@ func TestTruncPlatforms(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
tpfs := truncPlatforms(tt.platforms, tt.max)
assert.Equal(t, tt.expectedList, tpfs.List())
+1 -2
View File
@@ -70,9 +70,8 @@ func ResolveOptionPaths(options *Options) (_ *Options, err error) {
for k, v := range options.NamedContexts {
if isRemoteURL(v) || strings.HasPrefix(v, "docker-image://") {
// url prefix, this is a remote path
} else if strings.HasPrefix(v, "oci-layout://") {
} else if p, ok := strings.CutPrefix(v, "oci-layout://"); ok {
// oci layout prefix, this is a local path
p := strings.TrimPrefix(v, "oci-layout://")
p, err = filepath.Abs(p)
if err != nil {
return nil, err
-1
View File
@@ -240,7 +240,6 @@ 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)
-2
View File
@@ -9,7 +9,6 @@ import (
func TestConstraint(t *testing.T) {
for _, tt := range mobyBuildkitVersions {
tt := tt
t.Run(tt.MobyVersionConstraint, func(t *testing.T) {
_, err := semver.NewConstraint(tt.MobyVersionConstraint)
require.NoError(t, err)
@@ -121,7 +120,6 @@ func TestResolveBuildKitVersion(t *testing.T) {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.mobyVersion, func(t *testing.T) {
bkVersion, err := resolveBuildKitVersion(tt.mobyVersion)
if tt.err {
+1 -1
View File
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.23
ARG GO_VERSION=1.24
ARG ALPINE_VERSION=3.21
ARG FORMATS=md,yaml
+1 -1
View File
@@ -5,7 +5,7 @@
# Copyright The Buildx Authors.
# Licensed under the Apache License, Version 2.0
ARG GO_VERSION=1.23
ARG GO_VERSION=1.24
ARG PROTOC_VERSION=3.11.4
ARG PROTOC_GOOGLEAPIS_VERSION=2af421884dd468d565137215c946ebe4e245ae26
+1 -1
View File
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.23
ARG GO_VERSION=1.24
ARG ALPINE_VERSION=3.21
ARG GOVULNCHECK_VERSION=v1.1.3
+4 -5
View File
@@ -1,15 +1,14 @@
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.23
ARG GO_VERSION=1.24
ARG ALPINE_VERSION=3.21
ARG XX_VERSION=1.6.1
ARG GOLANGCI_LINT_VERSION=v2.1.5
ARG GOLANGCI_FROM_SOURCE=false
# v0.31 requires go1.24
ARG GOPLS_VERSION=v0.30.0
# disabled: deprecated unusedvariable simplifyrange
ARG GOPLS_ANALYZERS="embeddirective fillreturns hostport infertypeargs modernize nonewvars noresultvalues simplifycompositelit simplifyslice unusedparams yield"
ARG GOPLS_VERSION=v0.33.0
# GOPLS_ANALYZERS defines gopls analyzers to be run. disabled by default: deprecated simplifyrange unusedfunc unusedvariable
ARG GOPLS_ANALYZERS="embeddirective fillreturns infertypeargs maprange modernize nonewvars noresultvalues simplifycompositelit simplifyslice unusedparams yield"
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
+1 -1
View File
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.23
ARG GO_VERSION=1.24
ARG ALPINE_VERSION=3.21
ARG MODOUTDATED_VERSION=v0.9.0
-1
View File
@@ -36,7 +36,6 @@ func testLs(t *testing.T, sb integration.Sandbox) {
sbDriver, _, _ := driverName(sb.Name())
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
out, err := lsCmd(sb, withArgs(tt.args...))
require.NoError(t, err, out)
-1
View File
@@ -49,7 +49,6 @@ func TestIsSubPath(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
ok, err := isSubPath(tt.basePath, tt.subPath)
require.NoError(t, err)
-1
View File
@@ -17,7 +17,6 @@ func fromReader(l progress.SubLogger, rc io.ReadCloser) error {
defer func() {
for _, st := range started {
st := st
if st.Completed == nil {
now := time.Now()
st.Completed = &now
-1
View File
@@ -35,7 +35,6 @@ func TestStripCredentials(t *testing.T) {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if g, w := stripCredentials(tt.url), tt.want; g != w {
t.Fatalf("got: %q\nwant: %q", g, w)
-1
View File
@@ -200,7 +200,6 @@ func TestGitRemoteURL(t *testing.T) {
},
}
for _, tt := range cases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
gittestutil.Mktmp(t)
c, err := gitutil.New()
-1
View File
@@ -225,7 +225,6 @@ func (l *loader) fetch(ctx context.Context, fetcher remotes.Fetcher, desc ocispe
eg, ctx := errgroup.WithContext(ctx)
for _, d := range idx.Manifests {
d := d
eg.Go(func() error {
return l.fetch(ctx, fetcher, d, r)
})
-1
View File
@@ -145,7 +145,6 @@ func TestAsAttributeKeyValue(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
kv := keyValue{
Key: "key",