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 <matt.farina@suse.com>
pull/13538/head
Matt Farina 9 months ago committed by Payal Godhani
parent ccdabad4b9
commit dc26e5b3e2

@ -21,7 +21,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0
with:
go-version: '1.22'
go-version: '1.23'
check-latest: true
- name: Test source headers are present
run: make test-source-headers

@ -18,7 +18,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0
with:
go-version: '1.22'
go-version: '1.23'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 #pin@6.1.1

@ -16,7 +16,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0
with:
go-version: '1.22'
go-version: '1.23'
check-latest: true
- name: govulncheck
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # pin@1.0.4

@ -27,7 +27,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0
with:
go-version: '1.22.7'
go-version: '1.23'
- name: Run unit tests
run: make test-coverage
@ -83,7 +83,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0
with:
go-version: '1.22'
go-version: '1.23'
check-latest: true
- name: Run unit tests

@ -23,3 +23,23 @@ linters-settings:
local-prefixes: helm.sh/helm/v3
dupl:
threshold: 400
issues:
exclude-rules:
# Helm, and the Go source code itself, sometimes uses these names outside their built-in
# functions. As the Go source code has re-used these names it's ok for Helm to do the same.
# Linting will look for redefinition of built-in id's but we opt-in to the ones we choose to use.
- linters:
- revive
text: "redefines-builtin-id: redefinition of the built-in function append"
- linters:
- revive
text: "redefines-builtin-id: redefinition of the built-in function clear"
- linters:
- revive
text: "redefines-builtin-id: redefinition of the built-in function max"
- linters:
- revive
text: "redefines-builtin-id: redefinition of the built-in function min"
- linters:
- revive
text: "redefines-builtin-id: redefinition of the built-in function new"

@ -78,7 +78,7 @@ func (o *pluginUninstallOptions) run(out io.Writer) error {
}
}
if len(errorPlugins) > 0 {
return errors.Errorf(strings.Join(errorPlugins, "\n"))
return errors.New(strings.Join(errorPlugins, "\n"))
}
return nil
}

@ -81,7 +81,7 @@ func (o *pluginUpdateOptions) run(out io.Writer) error {
}
}
if len(errorPlugins) > 0 {
return errors.Errorf(strings.Join(errorPlugins, "\n"))
return errors.New(strings.Join(errorPlugins, "\n"))
}
return nil
}

@ -140,7 +140,7 @@ func (s statusPrinter) WriteTable(out io.Writer) error {
}
_, _ = fmt.Fprintf(out, "DESCRIPTION: %s\n", s.release.Info.Description)
if s.release.Info.Resources != nil && len(s.release.Info.Resources) > 0 {
if len(s.release.Info.Resources) > 0 {
buf := new(bytes.Buffer)
printFlags := get.NewHumanPrintFlags()
typePrinter, _ := printFlags.ToPrinter("")

@ -1,6 +1,6 @@
module helm.sh/helm/v3
go 1.22.0
go 1.23.0
require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24

@ -44,7 +44,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent,
for _, h := range executingHooks {
// Set default delete policy to before-hook-creation
if h.DeletePolicies == nil || len(h.DeletePolicies) == 0 {
if len(h.DeletePolicies) == 0 {
// TODO(jlegrone): Only apply before-hook-creation delete policy to run to completion
// resources. For all other resource types update in place if a
// resource with the same name already exists and is owned by the

@ -206,7 +206,7 @@ func (e Engine) initFunMap(t *template.Template) {
log.Printf("[INFO] Missing required value: %s", warn)
return "", nil
}
return val, errors.Errorf(warnWrap(warn))
return val, errors.New(warnWrap(warn))
} else if _, ok := val.(string); ok {
if val == "" {
if e.LintMode {
@ -214,7 +214,7 @@ func (e Engine) initFunMap(t *template.Template) {
log.Printf("[INFO] Missing required value: %s", warn)
return "", nil
}
return val, errors.Errorf(warnWrap(warn))
return val, errors.New(warnWrap(warn))
}
}
return val, nil

@ -435,7 +435,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err
case err != nil:
return res, err
case len(updateErrors) != 0:
return res, errors.Errorf(strings.Join(updateErrors, " && "))
return res, errors.New(strings.Join(updateErrors, " && "))
}
for _, info := range original.Difference(target) {

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

@ -208,7 +208,7 @@ func generateChartOCIAnnotations(meta *chart.Metadata, creationTime string) map[
chartOCIAnnotations = addToMap(chartOCIAnnotations, ocispec.AnnotationSource, meta.Sources[0])
}
if meta.Maintainers != nil && len(meta.Maintainers) > 0 {
if len(meta.Maintainers) > 0 {
var maintainerSb strings.Builder
for maintainerIdx, maintainer := range meta.Maintainers {

@ -19,7 +19,7 @@ IFS=$'\n\t'
find_files() {
find . -not \( \
\( \
-wholename './vendor' \
-wholename './.git' \
-o -wholename '*testdata*' \
-o -wholename '*third_party*' \
\) -prune \

Loading…
Cancel
Save