Skip to content

Commit 9f620b8

Browse files
committed
Update to Go 1.23
Multiple changes were made to pass linting. Some Go built-in names are being used for variables (e.g., min). This happens in the Go source itself including the Go standard library and is not always a bad practice. To handle allowing some built-in names to be used the linter config is updated to allow (via opt-in) some names to pass. This allows us to still check for re-use of Go built-in names and opt-in to any new uses. There were also several cases where a value was checked for nil before checking its length when this is already handled by len() or the types default value. These were cleaned up. The license validation was updated because it was checking everything in the .git directory including all remote content that was local. The previous vendor directory was from a time prior to Go modules when Helm handled dependencies differently. It was no longer needed. Signed-off-by: Matt Farina <[email protected]> (cherry picked from commit 5727f56)
1 parent 0a588c2 commit 9f620b8

15 files changed

+36
-16
lines changed

.github/workflows/build-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup Go
2323
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
2424
with:
25-
go-version: '1.22'
25+
go-version: '1.23'
2626
check-latest: true
2727
- name: Test source headers are present
2828
run: make test-source-headers

.github/workflows/golangci-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Go
1919
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
2020
with:
21-
go-version: '1.22'
21+
go-version: '1.23'
2222
check-latest: true
2323
- name: golangci-lint
2424
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 #[email protected]

.github/workflows/govulncheck.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup Go
1717
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
1818
with:
19-
go-version: '1.22'
19+
go-version: '1.23'
2020
check-latest: true
2121
- name: govulncheck
2222
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # [email protected]

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Setup Go
2828
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
2929
with:
30-
go-version: '1.22.7'
30+
go-version: '1.23'
3131

3232
- name: Run unit tests
3333
run: make test-coverage
@@ -83,7 +83,7 @@ jobs:
8383
- name: Setup Go
8484
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
8585
with:
86-
go-version: '1.22'
86+
go-version: '1.23'
8787
check-latest: true
8888

8989
- name: Run unit tests

.golangci.yml

+20
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,23 @@ linters-settings:
2323
local-prefixes: helm.sh/helm/v3
2424
dupl:
2525
threshold: 400
26+
issues:
27+
exclude-rules:
28+
# Helm, and the Go source code itself, sometimes uses these names outside their built-in
29+
# functions. As the Go source code has re-used these names it's ok for Helm to do the same.
30+
# Linting will look for redefinition of built-in id's but we opt-in to the ones we choose to use.
31+
- linters:
32+
- revive
33+
text: "redefines-builtin-id: redefinition of the built-in function append"
34+
- linters:
35+
- revive
36+
text: "redefines-builtin-id: redefinition of the built-in function clear"
37+
- linters:
38+
- revive
39+
text: "redefines-builtin-id: redefinition of the built-in function max"
40+
- linters:
41+
- revive
42+
text: "redefines-builtin-id: redefinition of the built-in function min"
43+
- linters:
44+
- revive
45+
text: "redefines-builtin-id: redefinition of the built-in function new"

cmd/helm/plugin_uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (o *pluginUninstallOptions) run(out io.Writer) error {
7878
}
7979
}
8080
if len(errorPlugins) > 0 {
81-
return errors.Errorf(strings.Join(errorPlugins, "\n"))
81+
return errors.New(strings.Join(errorPlugins, "\n"))
8282
}
8383
return nil
8484
}

cmd/helm/plugin_update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (o *pluginUpdateOptions) run(out io.Writer) error {
8181
}
8282
}
8383
if len(errorPlugins) > 0 {
84-
return errors.Errorf(strings.Join(errorPlugins, "\n"))
84+
return errors.New(strings.Join(errorPlugins, "\n"))
8585
}
8686
return nil
8787
}

cmd/helm/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (s statusPrinter) WriteTable(out io.Writer) error {
144144
_, _ = fmt.Fprintf(out, "DESCRIPTION: %s\n", s.release.Info.Description)
145145
}
146146

147-
if s.showResources && s.release.Info.Resources != nil && len(s.release.Info.Resources) > 0 {
147+
if s.showResources && len(s.release.Info.Resources) > 0 {
148148
buf := new(bytes.Buffer)
149149
printFlags := get.NewHumanPrintFlags()
150150
typePrinter, _ := printFlags.ToPrinter("")

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module helm.sh/helm/v3
22

3-
go 1.22.0
3+
go 1.23.0
44

55
require (
66
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24

pkg/action/hooks.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent,
4444

4545
for _, h := range executingHooks {
4646
// Set default delete policy to before-hook-creation
47-
if h.DeletePolicies == nil || len(h.DeletePolicies) == 0 {
47+
if len(h.DeletePolicies) == 0 {
4848
// TODO(jlegrone): Only apply before-hook-creation delete policy to run to completion
4949
// resources. For all other resource types update in place if a
5050
// resource with the same name already exists and is owned by the

pkg/engine/engine.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ func (e Engine) initFunMap(t *template.Template) {
206206
log.Printf("[INFO] Missing required value: %s", warn)
207207
return "", nil
208208
}
209-
return val, errors.Errorf(warnWrap(warn))
209+
return val, errors.New(warnWrap(warn))
210210
} else if _, ok := val.(string); ok {
211211
if val == "" {
212212
if e.LintMode {
213213
// Don't fail on missing required values when linting
214214
log.Printf("[INFO] Missing required value: %s", warn)
215215
return "", nil
216216
}
217-
return val, errors.Errorf(warnWrap(warn))
217+
return val, errors.New(warnWrap(warn))
218218
}
219219
}
220220
return val, nil

pkg/kube/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err
435435
case err != nil:
436436
return res, err
437437
case len(updateErrors) != 0:
438-
return res, errors.Errorf(strings.Join(updateErrors, " && "))
438+
return res, errors.New(strings.Join(updateErrors, " && "))
439439
}
440440

441441
for _, info := range original.Difference(target) {

pkg/kube/wait.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func SelectorsForObject(object runtime.Object) (selector labels.Selector, err er
153153
case *batchv1.Job:
154154
selector, err = metav1.LabelSelectorAsSelector(t.Spec.Selector)
155155
case *corev1.Service:
156-
if t.Spec.Selector == nil || len(t.Spec.Selector) == 0 {
156+
if len(t.Spec.Selector) == 0 {
157157
return nil, fmt.Errorf("invalid service '%s': Service is defined without a selector", t.Name)
158158
}
159159
selector = labels.SelectorFromSet(t.Spec.Selector)

pkg/registry/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func generateChartOCIAnnotations(meta *chart.Metadata, creationTime string) map[
208208
chartOCIAnnotations = addToMap(chartOCIAnnotations, ocispec.AnnotationSource, meta.Sources[0])
209209
}
210210

211-
if meta.Maintainers != nil && len(meta.Maintainers) > 0 {
211+
if len(meta.Maintainers) > 0 {
212212
var maintainerSb strings.Builder
213213

214214
for maintainerIdx, maintainer := range meta.Maintainers {

scripts/validate-license.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ IFS=$'\n\t'
1919
find_files() {
2020
find . -not \( \
2121
\( \
22-
-wholename './vendor' \
22+
-wholename './.git' \
2323
-o -wholename '*testdata*' \
2424
-o -wholename '*third_party*' \
2525
\) -prune \

0 commit comments

Comments
 (0)