[dev-v3] Bump Go v1.25, `golangci-lint` v2

Signed-off-by: George Jenkins <gvjenkins@gmail.com>
pull/31670/head
George Jenkins 5 days ago
parent b49daa138d
commit 0ae8e4f2cb

4
.github/env vendored

@ -1,2 +1,2 @@
GOLANG_VERSION=1.24
GOLANGCI_LINT_VERSION=v1.64
GOLANG_VERSION=1.25
GOLANGCI_LINT_VERSION=v2.5.0

@ -1,45 +1,66 @@
run:
timeout: 10m
version: "2"
linters:
disable-all: true
default: none
enable:
- dupl
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- unused
- staticcheck
linters-settings:
gofmt:
simplify: true
goimports:
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"
- unused
settings:
dupl:
threshold: 400
staticcheck:
checks:
- "all"
- "-QF1008" # QF1008: could remove embedded field "Foo" from selector
- "-QF1001" # QF1001: could apply De Morgan's law
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
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'
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
goimports:
local-prefixes:
- helm.sh/helm/v3
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

@ -86,7 +86,7 @@ func (o *docsOptions) run(_ io.Writer) error {
hdrFunc := func(filename string) string {
base := filepath.Base(filename)
name := strings.TrimSuffix(base, path.Ext(base))
title := cases.Title(language.Und, cases.NoLower).String(strings.Replace(name, "_", " ", -1))
title := cases.Title(language.Und, cases.NoLower).String(strings.ReplaceAll(name, "_", " "))
return fmt.Sprintf("---\ntitle: \"%s\"\n---\n\n", title)
}

@ -136,8 +136,7 @@ func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdate
wg.Wait()
if len(repoFailList) > 0 && failOnRepoUpdateFail {
return fmt.Errorf("Failed to update the following repositories: %s",
repoFailList)
return fmt.Errorf("Failed to update the following repositories: %s", repoFailList) //nolint:staticcheck
}
fmt.Fprintln(out, "Update Complete. ⎈Happy Helming!⎈")

@ -234,7 +234,7 @@ func writeToFile(outputDir string, name string, data string, append bool) error
defer f.Close()
_, err = f.WriteString(fmt.Sprintf("---\n# Source: %s\n%s\n", name, data))
_, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, data)
if err != nil {
return err

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

@ -92,5 +92,5 @@ func update(filename string, in []byte) error {
}
func normalize(in []byte) []byte {
return bytes.Replace(in, []byte("\r\n"), []byte("\n"), -1)
return bytes.ReplaceAll(in, []byte("\r\n"), []byte("\n"))
}

@ -172,28 +172,28 @@ func copyFile(src, dst string) (err error) {
in, err := os.Open(src)
if err != nil {
return
return //nolint:nakedret
}
defer in.Close()
out, err := os.Create(dst)
if err != nil {
return
return //nolint:nakedret
}
if _, err = io.Copy(out, in); err != nil {
out.Close()
return
return //nolint:nakedret
}
// Check for write errors on Close
if err = out.Close(); err != nil {
return
return //nolint:nakedret
}
si, err := os.Stat(src)
if err != nil {
return
return //nolint:nakedret
}
// Temporary fix for Go < 1.9
@ -205,7 +205,7 @@ func copyFile(src, dst string) (err error) {
}
err = os.Chmod(dst, si.Mode())
return
return //nolint:nakedret
}
// cloneSymlink will create a new symlink that points to the resolved path of sl.

@ -33,17 +33,11 @@ package fs
import (
"os"
"os/exec"
"path/filepath"
"runtime"
"sync"
"testing"
)
var (
mu sync.Mutex
)
func TestRenameWithFallback(t *testing.T) {
dir := t.TempDir()
@ -360,19 +354,6 @@ func TestCopyFile(t *testing.T) {
}
}
func cleanUpDir(dir string) {
// NOTE(mattn): It seems that sometimes git.exe is not dead
// when cleanUpDir() is called. But we do not know any way to wait for it.
if runtime.GOOS == "windows" {
mu.Lock()
exec.Command(`taskkill`, `/F`, `/IM`, `git.exe`).Run()
mu.Unlock()
}
if dir != "" {
os.RemoveAll(dir)
}
}
func TestCopyFileSymlink(t *testing.T) {
tempdir := t.TempDir()

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package util
package util //nolint:revive
import (
"context"

@ -619,7 +619,7 @@ func writeToFile(outputDir string, name string, data string, append bool) error
defer f.Close()
_, err = f.WriteString(fmt.Sprintf("---\n# Source: %s\n%s\n", name, data))
_, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, data)
if err != nil {
return err

@ -38,7 +38,7 @@ type lookupFunc = func(apiversion string, resource string, namespace string, nam
//
// This function is considered deprecated, and will be renamed in Helm 4. It will no
// longer be a public function.
func NewLookupFunction(config *rest.Config) lookupFunc {
func NewLookupFunction(config *rest.Config) lookupFunc { //nolint:revive
return newLookupFunction(clientProviderFromConfig{config: config})
}

@ -186,8 +186,7 @@ func initCompromisedRegistryTestServer() string {
w.WriteHeader(200)
// layers[0] is the blob []byte("a")
w.Write([]byte(
fmt.Sprintf(`{ "schemaVersion": 2, "config": {
fmt.Fprintf(w, `{ "schemaVersion": 2, "config": {
"mediaType": "%s",
"digest": "sha256:a705ee2789ab50a5ba20930f246dbd5cc01ff9712825bb98f57ee8414377f133",
"size": 181
@ -199,7 +198,7 @@ func initCompromisedRegistryTestServer() string {
"size": 1
}
]
}`, ConfigMediaType, ChartLayerMediaType)))
}`, ConfigMediaType, ChartLayerMediaType)
} else if r.URL.Path == "/v2/testrepo/supposedlysafechart/blobs/sha256:a705ee2789ab50a5ba20930f246dbd5cc01ff9712825bb98f57ee8414377f133" {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)

@ -19,7 +19,7 @@ limitations under the License.
// where the serializer doesn't omit an empty value for time:
// https://github.com/golang/go/issues/11939. As such, this can be removed if a
// proposal is ever accepted for Go
package time
package time //nolint:revive
import (
"bytes"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package time
package time //nolint:revive
import (
"encoding/json"

Loading…
Cancel
Save