mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-20 21:05:29 +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:
@@ -224,7 +224,7 @@ func TestReportJSON_FieldOrderIsHumanReadable(t *testing.T) {
|
||||
// Cheap way: scan line-by-line, the first 7 non-space chars of each line
|
||||
// are `"key":`.
|
||||
keys := []string{}
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
for line := range strings.SplitSeq(out, "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
if !strings.HasPrefix(line, `"`) {
|
||||
continue
|
||||
|
||||
@@ -50,7 +50,10 @@ func (o *openaiClient) Analyze(ctx goContext.Context, diff string, extras Analyz
|
||||
req := openai.ChatCompletionRequest{
|
||||
Model: o.cfg.Model,
|
||||
Temperature: o.cfg.Temperature,
|
||||
MaxTokens: o.cfg.MaxTokens,
|
||||
// SA1019: keep the deprecated MaxTokens field deliberately: `max_tokens` is the
|
||||
// only form universally accepted by OpenAI-compatible backends (One-API,
|
||||
// LiteLLM, Ollama shim); MaxCompletionTokens is not supported by all of them.
|
||||
MaxTokens: o.cfg.MaxTokens, //nolint:staticcheck // SA1019
|
||||
ResponseFormat: &openai.ChatCompletionResponseFormat{
|
||||
Type: openai.ChatCompletionResponseFormatTypeJSONObject,
|
||||
},
|
||||
@@ -166,8 +169,8 @@ func stripJSONCodeFence(s string) string {
|
||||
// Case 2: fenced JSON.
|
||||
if strings.HasPrefix(s, "```") {
|
||||
rest := s[3:]
|
||||
if nl := strings.IndexByte(rest, '\n'); nl >= 0 {
|
||||
s = rest[nl+1:]
|
||||
if _, after, ok := strings.Cut(rest, "\n"); ok {
|
||||
s = after
|
||||
} else {
|
||||
s = rest
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func TestMockClient_Analyze_PropagatesErr(t *testing.T) {
|
||||
func TestMockClient_ConcurrentSafe(t *testing.T) {
|
||||
c := NewMockClient(Analysis{Summary: "ok"})
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 20; i++ {
|
||||
for range 20 {
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
Reference in New Issue
Block a user