mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-17 21:15:53 +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:
+9
-13
@@ -2,6 +2,7 @@ package maputil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -263,16 +264,14 @@ func typedVal(val string, st bool) any {
|
||||
}
|
||||
|
||||
// MergeMaps merges two maps with special handling for nested maps and arrays.
|
||||
func MergeMaps(a, b map[string]interface{}, opts ...MergeOptions) map[string]interface{} {
|
||||
func MergeMaps(a, b map[string]any, opts ...MergeOptions) map[string]any {
|
||||
arrayStrategy := ArrayMergeStrategySparse
|
||||
if len(opts) > 0 {
|
||||
arrayStrategy = opts[0].ArrayStrategy
|
||||
}
|
||||
|
||||
out := make(map[string]interface{}, len(a))
|
||||
for k, v := range a {
|
||||
out[k] = v
|
||||
}
|
||||
out := make(map[string]any, len(a))
|
||||
maps.Copy(out, a)
|
||||
for k, v := range b {
|
||||
if v == nil {
|
||||
// If key doesn't exist in base, add nil (issue #1154).
|
||||
@@ -282,9 +281,9 @@ func MergeMaps(a, b map[string]interface{}, opts ...MergeOptions) map[string]int
|
||||
}
|
||||
continue
|
||||
}
|
||||
if v, ok := v.(map[string]interface{}); ok {
|
||||
if v, ok := v.(map[string]any); ok {
|
||||
if bv, ok := out[k]; ok {
|
||||
if bv, ok := bv.(map[string]interface{}); ok {
|
||||
if bv, ok := bv.(map[string]any); ok {
|
||||
out[k] = MergeMaps(bv, v, opts...)
|
||||
continue
|
||||
}
|
||||
@@ -365,15 +364,12 @@ func mergeSlices(base, override []any, strategy ArrayMergeStrategy) []any {
|
||||
}
|
||||
|
||||
// Merge element-by-element (for ArrayMergeStrategyMerge or sparse arrays)
|
||||
maxLen := len(base)
|
||||
if len(override) > maxLen {
|
||||
maxLen = len(override)
|
||||
}
|
||||
maxLen := max(len(override), len(base))
|
||||
|
||||
result := make([]interface{}, maxLen)
|
||||
result := make([]any, maxLen)
|
||||
copy(result, base)
|
||||
|
||||
for i := 0; i < len(override); i++ {
|
||||
for i := range override {
|
||||
overrideVal := override[i]
|
||||
if overrideVal == nil {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user