Skip to content

chore: bump to go 1.24 #5920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

run:
deadline: 5m
go: '1.22'
go: '1.24'

linters:
enable-all: true
Expand Down
9 changes: 6 additions & 3 deletions api/filters/replacement/replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,17 @@ func copyValueToTarget(target *yaml.RNode, value *yaml.RNode, selector *types.Ta
Path: kyaml_utils.SmarterPathSplitter(fp, "."),
Create: createKind})
if err != nil {
return errors.WrapPrefixf(err, fieldRetrievalError(fp, createKind != 0)) //nolint:govet
msg := fieldRetrievalError(fp, createKind != 0)
return errors.WrapPrefixf(err, "%s", msg)
}
targetFields, err := targetFieldList.Elements()
if err != nil {
return errors.WrapPrefixf(err, fieldRetrievalError(fp, createKind != 0)) //nolint:govet
msg := fieldRetrievalError(fp, createKind != 0)
return errors.WrapPrefixf(err, "%s", msg)
}
if len(targetFields) == 0 {
return errors.Errorf(fieldRetrievalError(fp, createKind != 0)) //nolint:govet
msg := fieldRetrievalError(fp, createKind != 0)
return errors.Errorf("%s", msg)
}

for _, t := range targetFields {
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kustomize/api

go 1.22.7
go 1.24.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to go 1.24.0 tag in go.mod file.
details: #5763 (comment)

However, for the Go runtime versions actually used like Dockerfiles or GitHub Actions, newer patch versions are safe to use, so always use the latest available version whenever possible.


require (
github.com/blang/semver/v4 v4.0.0
Expand Down
5 changes: 2 additions & 3 deletions api/internal/builtins/HelmChartInflationGenerator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/internal/git/repospec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
rs.Dir = ""
rs.Submodules = false
rs.Timeout = 0
assert.Equal(t, &tc.repoSpec, rs) //nolint:gosec
assert.Equal(t, &tc.repoSpec, rs)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/internal/loader/fileloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (fl *FileLoader) New(path string) (ifc.Loader, error) {
}
root, err := filesys.ConfirmDir(fl.fSys, fl.root.Join(path))
if err != nil {
return nil, errors.WrapPrefixf(err, ErrRtNotDir.Error()) //nolint:govet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the go runtime version in this PR while keeping only the minimum necessary changes to pass existing tests and lint checks? If needed, we could extract the lint-related changes in this PR into a separate PR and merge that one first.

By keeping the go version bump PR simple, we'll make it easy to revert in case of any issues during upgrade.

return nil, errors.WrapPrefixf(err, "%s", ErrRtNotDir.Error())
}
if err = fl.errIfGitContainmentViolation(root); err != nil {
return nil, err
Expand Down
1 change: 0 additions & 1 deletion api/internal/loader/fileloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func TestIsRemoteFile(t *testing.T) {
},
}
for name, test := range cases {
test := test
t.Run(name, func(t *testing.T) {
require.Equal(t, test.valid, IsRemoteFile(test.url))
})
Expand Down
2 changes: 1 addition & 1 deletion api/internal/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewLoader(
}
root, err := filesys.ConfirmDir(fSys, target)
if err != nil {
return nil, errors.WrapPrefixf(err, ErrRtNotDir.Error()) //nolint:govet
return nil, errors.WrapPrefixf(err, "%s", ErrRtNotDir.Error())
}
return newLoaderAtConfirmedDir(
lr, root, fSys, nil, git.ClonerUsingGitExec), nil
Expand Down
5 changes: 0 additions & 5 deletions api/internal/localizer/locloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func TestNewLocLoaderDefaultForRootTarget(t *testing.T) {
},
}
for name, params := range cases {
params := params
t.Run(name, func(t *testing.T) {
req := require.New(t)
fSys := makeMemoryFs(t)
Expand Down Expand Up @@ -172,7 +171,6 @@ func TestNewLocLoaderCwdNotRoot(t *testing.T) {
}

for name, test := range cases {
test := test
t.Run(name, func(t *testing.T) {
req := require.New(t)
fSys := makeWdFs(t)[test.wd]
Expand Down Expand Up @@ -223,7 +221,6 @@ func TestNewLocLoaderFails(t *testing.T) {
},
}
for name, params := range cases {
params := params
t.Run(name, func(t *testing.T) {
var buf bytes.Buffer
log.SetOutput(&buf)
Expand Down Expand Up @@ -254,7 +251,6 @@ func TestNewFails(t *testing.T) {
"file": "delta/deployment.yaml",
}
for name, root := range cases {
root := root
t.Run(name, func(t *testing.T) {
fSys := makeMemoryFs(t)

Expand Down Expand Up @@ -283,7 +279,6 @@ func TestLoadFails(t *testing.T) {
"winding inside dst": "/a/test/../newDir/pod.yaml",
}
for name, file := range cases {
file := file
t.Run(name, func(t *testing.T) {
req := require.New(t)
fSys := makeMemoryFs(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestMakeDefaultConfig_mutation(t *testing.T) {
}

func BenchmarkMakeDefaultConfig(b *testing.B) {
for i := 0; i < b.N; i++ {
for i := 0; i < b.N; i++ { //nolint:intrange
_ = MakeDefaultConfig()
}
}
9 changes: 5 additions & 4 deletions api/internal/plugins/execplugin/execplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ func (p *ExecPlugin) invokePlugin(input []byte) ([]byte, error) {
}
_, err = f.Write(p.cfg)
if err != nil {
msg := fmt.Sprintf("writing plugin config to %s", f.Name())
return nil, errors.WrapPrefixf(
err, "writing plugin config to "+f.Name())
err, "%s", msg)
}
err = f.Close()
if err != nil {
msg := fmt.Sprintf("closing plugin config file %s", f.Name())
return nil, errors.WrapPrefixf(
err, "closing plugin config file "+f.Name())
err, "%s", msg)
}
//nolint:gosec
cmd := exec.Command(
Expand All @@ -182,10 +184,9 @@ func (p *ExecPlugin) invokePlugin(input []byte) ([]byte, error) {
}
result, err := cmd.Output()
if err != nil {
//nolint:govet
return nil, errors.WrapPrefixf(
fmt.Errorf("failure in plugin configured via %s; %w",
f.Name(), err), stdErr.String())
f.Name(), err), "%s", stdErr.String())
}
return result, os.Remove(f.Name())
}
Expand Down
5 changes: 2 additions & 3 deletions api/krusty/remoteloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func TestRemoteLoad_LocalProtocol(t *testing.T) {
}
root := t.TempDir()

hashPath, err := os.MkdirTemp(root, "hash-")
require.NoError(t, err)
hashPath := t.TempDir()
hashDir := filepath.Base(hashPath)

bash(fmt.Sprintf(`
Expand Down Expand Up @@ -437,7 +436,7 @@ func configureGitSSHCommand(t *testing.T) {
require.NoError(t, err)

// Write the key to a temp file and use it in SSH
f, err := os.CreateTemp("", "kustomize_ssh")
f, err := os.CreateTemp(t.TempDir(), "kustomize_ssh")
require.NoError(t, err)
_, err = io.Copy(f, bytes.NewReader(key))
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion api/resource/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ metadata:
`))
require.NoError(t, err)

for i := 0; i < patchApplyCount; i++ {
for i := 0; i < patchApplyCount; i++ { //nolint: intrange
require.NoError(t, resource.ApplySmPatch(noOpPatch))

bytes, err := resource.AsYAML()
Expand Down
6 changes: 2 additions & 4 deletions api/testutils/kusttest/harnessenhanced.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced {

func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced {
t.Helper()
var err error
r := makeBaseEnhancedHarness(t)
fSys := filesys.MakeFsOnDisk()
r.Harness = MakeHarnessWithFs(t, fSys)
tmpDir, err := os.MkdirTemp("", "kust-testing-")
if err != nil {
panic("test harness cannot make tmp dir: " + err.Error())
}
tmpDir := t.TempDir()
r.ldr, err = fLdr.NewLoader(fLdr.RestrictionRootOnly, tmpDir, fSys)
if err != nil {
panic("test harness cannot make ldr at tmp dir: " + err.Error())
Expand Down
4 changes: 2 additions & 2 deletions api/testutils/localizertest/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func SetWorkingDir(t *testing.T, workingDir string) {
wd, err := os.Getwd()
require.NoError(t, err)
t.Cleanup(func() {
require.NoError(t, os.Chdir(wd))
require.NoError(t, os.Chdir(wd)) //nolint:usetesting
})

err = os.Chdir(workingDir)
err = os.Chdir(workingDir) //nolint:usetesting
require.NoError(t, err)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/config/docs/api-conventions/functions-impl.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ End-of-message
image.

```
FROM public.ecr.aws/docker/library/golang:1.22.7-bullseye
FROM public.ecr.aws/docker/library/golang:1.24.3-bullseye
RUN go get sigs.k8s.io/kustomize/cmd/config
RUN mv /go/bin/config /usr/bin/config
COPY nginx-template.sh /usr/bin/nginx-template.sh
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kustomize/cmd/config

go 1.22.7
go 1.24.3

require (
github.com/go-errors/errors v1.4.2
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/internal/commands/cat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ spec:
return
}

f, err := os.CreateTemp("", "kustomize-cat-test-dest")
f, err := os.CreateTemp(t.TempDir(), "kustomize-cat-test-dest")
if !assert.NoError(t, err) {
return
}
Expand Down
7 changes: 2 additions & 5 deletions cmd/config/internal/commands/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,7 @@ metadata:
t.Skip()
}

dir, err := os.MkdirTemp("", "kustomize-test-data-")
if !assert.NoError(t, err) {
t.FailNow()
}
dir := t.TempDir()
defer os.RemoveAll(dir)
os.Chdir(dir)

Expand All @@ -528,7 +525,7 @@ metadata:
cmd.Stderr = &stdErr
cmd.Env = os.Environ()

err = cmd.Run()
err := cmd.Run()
if tt.expectedErr != "" {
if !assert.Contains(t, stdErr.String(), tt.expectedErr, stdErr.String()) {
t.FailNow()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0

FROM public.ecr.aws/docker/library/golang:1.22.7-bullseye
FROM public.ecr.aws/docker/library/golang:1.24.3-bullseye
ENV CGO_ENABLED=0
WORKDIR /go/src/

Expand Down
2 changes: 1 addition & 1 deletion cmd/config/internal/commands/e2e/e2econtainerconfig/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kustomize/cmd/config/internal/commands/e2e/e2econtainerconfig

go 1.22.7
go 1.24.3

require sigs.k8s.io/kustomize/kyaml v0.14.2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0

FROM public.ecr.aws/docker/library/golang:1.22.7-bullseye
FROM public.ecr.aws/docker/library/golang:1.24.3-bullseye
ENV CGO_ENABLED=0
WORKDIR /go/src/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kustomize/cmd/config/internal/commands/e2e/e2econtainerenvgenerator

go 1.22.7
go 1.24.3

require sigs.k8s.io/kustomize/kyaml v0.14.2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0

FROM public.ecr.aws/docker/library/golang:1.22.7-bullseye
FROM public.ecr.aws/docker/library/golang:1.24.3-bullseye
ENV CGO_ENABLED=0
WORKDIR /go/src/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kustomize/cmd/config/internal/commands/e2e/e2econtainer-render-helm-chart

go 1.22.7
go 1.24.3

require sigs.k8s.io/kustomize/kyaml v0.14.2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0

FROM public.ecr.aws/docker/library/golang:1.22.7-bullseye
FROM public.ecr.aws/docker/library/golang:1.24.3-bullseye
ENV CGO_ENABLED=0
WORKDIR /go/src/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/kustomize/cmd/config/internal/commands/e2e/e2econtainersimplegenerator

go 1.22.7
go 1.24.3

require sigs.k8s.io/kustomize/kyaml v0.14.2

Expand Down
7 changes: 2 additions & 5 deletions cmd/config/internal/commands/e2e/test_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ func runTests(t *testing.T, tests []test) {
for i := range tests {
tt := tests[i]
t.Run(tt.name, func(t *testing.T) {
dataDir, err := os.MkdirTemp("", "kustomize-test-data-")
if !assert.NoError(t, err) {
t.FailNow()
}
dataDir := t.TempDir()
defer os.RemoveAll(dataDir)
os.Chdir(dataDir)

Expand All @@ -62,7 +59,7 @@ func runTests(t *testing.T, tests []test) {
cmd.Stderr = &stdErr
cmd.Env = os.Environ()

err = cmd.Run()
err := cmd.Run()
if tt.expectedErr != "" {
if !assert.Contains(t, stdErr.String(), tt.expectedErr, stdErr.String()) {
t.FailNow()
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/internal/commands/grep.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r *GrepRunner) preRunE(c *cobra.Command, args []string) error {
r.Value = last[1]
}

r.Path = append(parts[:len(parts)-1], last[0]) //nolint:gocritic
r.GrepFilter.Path = append(parts[:len(parts)-1], last[0]) //nolint:gocritic
return nil
}

Expand Down
Loading
Loading