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:
yxxhero
2026-09-16 13:29:02 +08:00
committed by GitHub
co-authored by Claude
parent 88be4012b1
commit ad81e4231e
65 changed files with 710 additions and 941 deletions
+65 -71
View File
@@ -80,27 +80,25 @@ func TestGetUnresolvedDependenciess(t *testing.T) {
name: "oci chart with path prefix and underscores (issue #954)",
helmState: &HelmState{
FilePath: "helmfile.yaml",
ReleaseSetSpec: ReleaseSetSpec{
Releases: []ReleaseSpec{
{
Name: "example",
Chart: "myrepo/path_with_underscores/example",
Version: "1.0.0",
Namespace: "myns",
},
{
Name: "another",
Chart: "myrepo/another_path/chart",
Version: "2.0.0",
Namespace: "myns",
},
Releases: []ReleaseSpec{
{
Name: "example",
Chart: "myrepo/path_with_underscores/example",
Version: "1.0.0",
Namespace: "myns",
},
Repositories: []RepositorySpec{
{
Name: "myrepo",
URL: "harbor.custom.com",
OCI: true,
},
{
Name: "another",
Chart: "myrepo/another_path/chart",
Version: "2.0.0",
Namespace: "myns",
},
},
Repositories: []RepositorySpec{
{
Name: "myrepo",
URL: "harbor.custom.com",
OCI: true,
},
},
},
@@ -130,34 +128,32 @@ func TestGetUnresolvedDependenciess(t *testing.T) {
name: "oci chart without path prefix (unchanged behavior)",
helmState: &HelmState{
FilePath: "helmfile.yaml",
ReleaseSetSpec: ReleaseSetSpec{
Releases: []ReleaseSpec{
{
Name: "foo",
Chart: "chartsa/abc",
Version: "0.1.0",
Namespace: "ns1",
},
{
Name: "empty",
Chart: "chartsb/empty",
Namespace: "ns2",
},
{
Name: "empty",
Chart: "chartsb/empty",
},
Releases: []ReleaseSpec{
{
Name: "foo",
Chart: "chartsa/abc",
Version: "0.1.0",
Namespace: "ns1",
},
Repositories: []RepositorySpec{
{
Name: "chartsa",
URL: "localhost:5000/aaa",
OCI: true,
},
{
Name: "chartsb",
URL: "localhost:5000/bbb",
},
{
Name: "empty",
Chart: "chartsb/empty",
Namespace: "ns2",
},
{
Name: "empty",
Chart: "chartsb/empty",
},
},
Repositories: []RepositorySpec{
{
Name: "chartsa",
URL: "localhost:5000/aaa",
OCI: true,
},
{
Name: "chartsb",
URL: "localhost:5000/bbb",
},
},
},
@@ -191,31 +187,29 @@ func TestGetUnresolvedDependenciess(t *testing.T) {
name: "duplicate charts are differentiated by alias",
helmState: &HelmState{
FilePath: "helmfile.yaml",
ReleaseSetSpec: ReleaseSetSpec{
Releases: []ReleaseSpec{
{
Name: "foo",
Chart: "myrepo/abc",
Version: "> 0.2.0",
Namespace: "ns1",
},
{
Name: "bar",
Chart: "myrepo/abc",
Version: "0.1.0",
Namespace: "ns2",
},
{
Name: "baz",
Chart: "myrepo/abc",
Version: "0.3.0",
},
Releases: []ReleaseSpec{
{
Name: "foo",
Chart: "myrepo/abc",
Version: "> 0.2.0",
Namespace: "ns1",
},
Repositories: []RepositorySpec{
{
Name: "myrepo",
URL: "localhost:5000/aaa",
},
{
Name: "bar",
Chart: "myrepo/abc",
Version: "0.1.0",
Namespace: "ns2",
},
{
Name: "baz",
Chart: "myrepo/abc",
Version: "0.3.0",
},
},
Repositories: []RepositorySpec{
{
Name: "myrepo",
URL: "localhost:5000/aaa",
},
},
},