mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 10:31:24 +02:00
build: update Go to 1.27.1 and modernize the codebase (#2798)
Toolchain and CI:
- Bump go directive from 1.26.8 to 1.27.1 (go.mod)
- Use golang:1.27-alpine builder images in all Dockerfiles
- Bump golangci-lint to v2.13.2 (first release with go1.27 support)
- Add CI gate: `go fix -diff` fails when outdated Go patterns are
detected (locally: `make check-modernize`)
Note: darwin binaries now require macOS 13 or later.
Lint fixes required by golangci-lint v2.13.2:
- goconst: ignore tests (all 436 findings were test-only; goconst
got stricter since v2.12 and this option was added for it)
- openai.go: keep deprecated MaxTokens deliberately with a nolint
rationale (max_tokens is the only form universally supported by
OpenAI-compatible backends like One-API, LiteLLM, Ollama shim)
- state.go: drop always-nil flags param from appendChartVersionFlags
(renamed to chartVersionFlags, unparam)
Modernization (go fix ./..., 62 files):
- interface{} -> any, maps.Copy, strings.SplitSeq, range-over-int,
builtin min/max, slices.Contains/ContainsFunc/Sort, WaitGroup.Go,
reflect.Type.Fields(), new(expr)
- exit_error.go: strings.Builder + fmt.Fprintf instead of string
concatenation and WriteString(fmt.Sprintf(...)) (QF1012)
- chart_dependency.go: strings.CutLast for OCI dependency helpers
Signed-off-by: yxxhero <aiopsclub@163.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package tmpl
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"maps"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
@@ -36,14 +37,10 @@ func (c *Context) CreateFuncMap() template.FuncMap {
|
||||
}
|
||||
|
||||
// add functions from the Context's createFuncMap() method to the funcMap
|
||||
for name, f := range c.createFuncMap() {
|
||||
funcMap[name] = f
|
||||
}
|
||||
maps.Copy(funcMap, c.createFuncMap())
|
||||
|
||||
// add aliased functions to the funcMap
|
||||
for name, f := range aliased {
|
||||
funcMap[name] = f
|
||||
}
|
||||
maps.Copy(funcMap, aliased)
|
||||
|
||||
return funcMap
|
||||
}
|
||||
@@ -90,7 +87,7 @@ func (c *Context) newTemplate() (*template.Template, error) {
|
||||
includedNames := make(map[string]int)
|
||||
|
||||
// Add the 'include' function here so we can close over t.
|
||||
funcMap["include"] = func(name string, data interface{}) (string, error) {
|
||||
funcMap["include"] = func(name string, data any) (string, error) {
|
||||
var buf strings.Builder
|
||||
if v, ok := includedNames[name]; ok {
|
||||
if v > recursionMaxNums {
|
||||
|
||||
@@ -404,7 +404,7 @@ func TestContext_RenderTemplateToBuffer(t *testing.T) {
|
||||
},
|
||||
}
|
||||
s := "Hello, {{ include \"name\" . }}!"
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"Name": "Alice",
|
||||
}
|
||||
expected := "Hello, Alice!"
|
||||
|
||||
Reference in New Issue
Block a user