From 348b9accec7dda9eec8d340f5eff06ec342f165d Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 17 Oct 2024 21:05:11 +0800 Subject: [PATCH 1/4] feat(ci): update helm and go version in ci workflow Signed-off-by: yxxhero --- .github/workflows/ci.yaml | 10 +++++----- .github/workflows/lint.yaml | 2 +- go.mod | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fac22825..bb7fbd60 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] shell: [ default ] experimental: [ false ] - helm-version: [ v3.15.4, v3.16.1 ] + helm-version: [ v3.15.4, v3.16.2 ] include: - os: windows-latest shell: wsl @@ -61,16 +61,16 @@ jobs: - os: windows-latest shell: wsl experimental: false - helm-version: v3.16.1 + helm-version: v3.16.2 - os: windows-latest shell: cygwin experimental: false - helm-version: v3.16.1 + helm-version: v3.16.2 - os: ubuntu-latest container: alpine shell: sh experimental: false - helm-version: v3.16.1 + helm-version: v3.16.2 steps: - name: Disable autocrlf @@ -111,7 +111,7 @@ jobs: # That's why we cover only 2 Helm minor versions in this matrix. # See https://github.com/helmfile/helmfile/pull/286#issuecomment-1250161182 for more context. - helm-version: v3.15.4 - - helm-version: v3.16.1 + - helm-version: v3.16.2 steps: - uses: engineerd/setup-kind@v0.5.0 with: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 972c6e8b..2acfcfef 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,4 +21,4 @@ jobs: go-version-file: 'go.mod' - uses: golangci/golangci-lint-action@v6 with: - version: v1.56.0 + version: v1.61.0 diff --git a/go.mod b/go.mod index 819fe6a7..22f12416 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/databus23/helm-diff/v3 -go 1.22.0 - -toolchain go1.22.4 +go 1.23.2 require ( github.com/Masterminds/semver/v3 v3.3.0 From 56ae907181f9126de75fa730297d14ccfa91cb41 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 17 Oct 2024 21:15:33 +0800 Subject: [PATCH 2/4] refactor: use _ to discard fmt.Fprintf return value Signed-off-by: yxxhero --- .golangci.yaml | 3 ++- diff/diff.go | 6 +++--- diff/report.go | 6 +++--- main_test.go | 14 +++++++------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index acd5a85d..12af8731 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -51,8 +51,9 @@ run: # output configuration options output: + formats: # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: line-number + - format: line-number # print lines of code with issue, default is true print-issued-lines: true diff --git a/diff/diff.go b/diff/diff.go index f78697f0..47da73ab 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -363,14 +363,14 @@ func printDiffRecord(diff difflib.DiffRecord, to io.Writer) { switch diff.Delta { case difflib.RightOnly: - fmt.Fprintf(to, "%s\n", ansi.Color("+ "+text, "green")) + _, _ = fmt.Fprintf(to, "%s\n", ansi.Color("+ "+text, "green")) case difflib.LeftOnly: - fmt.Fprintf(to, "%s\n", ansi.Color("- "+text, "red")) + _, _ = fmt.Fprintf(to, "%s\n", ansi.Color("- "+text, "red")) case difflib.Common: if text == "" { fmt.Fprintln(to) } else { - fmt.Fprintf(to, "%s\n", " "+text) + _, _ = fmt.Fprintf(to, "%s\n", " "+text) } } } diff --git a/diff/report.go b/diff/report.go index 48f1fa94..1638af46 100644 --- a/diff/report.go +++ b/diff/report.go @@ -148,7 +148,7 @@ func setupDiffReport(r *Report) { // print report for default output: diff func printDiffReport(r *Report, to io.Writer) { for _, entry := range r.entries { - fmt.Fprintf(to, ansi.Color("%s %s", "yellow")+"\n", entry.key, r.format.changestyles[entry.changeType].message) + _, _ = fmt.Fprintf(to, ansi.Color("%s %s", "yellow")+"\n", entry.key, r.format.changestyles[entry.changeType].message) printDiffRecords(entry.suppressedKinds, entry.kind, entry.context, entry.diffs, to) } } @@ -170,13 +170,13 @@ func printSimpleReport(r *Report, to io.Writer) { "MODIFY": 0, } for _, entry := range r.entries { - fmt.Fprintf(to, ansi.Color("%s %s", r.format.changestyles[entry.changeType].color)+"\n", + _, _ = fmt.Fprintf(to, ansi.Color("%s %s", r.format.changestyles[entry.changeType].color)+"\n", entry.key, r.format.changestyles[entry.changeType].message, ) summary[entry.changeType]++ } - fmt.Fprintf(to, "Plan: %d to add, %d to change, %d to destroy.\n", summary["ADD"], summary["MODIFY"], summary["REMOVE"]) + _, _ = fmt.Fprintf(to, "Plan: %d to add, %d to change, %d to destroy.\n", summary["ADD"], summary["MODIFY"], summary["REMOVE"]) } func newTemplate(name string) *template.Template { diff --git a/main_test.go b/main_test.go index bcb441b1..44b2b4eb 100644 --- a/main_test.go +++ b/main_test.go @@ -90,7 +90,7 @@ func runFakeHelm() int { } if stub == nil { - fmt.Fprintf(os.Stderr, "no stub for %s\n", cmdAndArgs) + _, _ = fmt.Fprintf(os.Stderr, "no stub for %s\n", cmdAndArgs) return 1 } @@ -100,13 +100,13 @@ func runFakeHelm() int { } got := cmdAndArgs[len(stub.cmd):] if !reflect.DeepEqual(want, got) { - fmt.Fprintf(os.Stderr, "want: %v\n", want) - fmt.Fprintf(os.Stderr, "got : %v\n", got) - fmt.Fprintf(os.Stderr, "args : %v\n", os.Args) - fmt.Fprintf(os.Stderr, "env : %v\n", os.Environ()) + _, _ = fmt.Fprintf(os.Stderr, "want: %v\n", want) + _, _ = fmt.Fprintf(os.Stderr, "got : %v\n", got) + _, _ = fmt.Fprintf(os.Stderr, "args : %v\n", os.Args) + _, _ = fmt.Fprintf(os.Stderr, "env : %v\n", os.Environ()) return 1 } - fmt.Fprintf(os.Stdout, "%s", stub.stdout) - fmt.Fprintf(os.Stderr, "%s", stub.stderr) + _, _ = fmt.Fprintf(os.Stdout, "%s", stub.stdout) + _, _ = fmt.Fprintf(os.Stderr, "%s", stub.stderr) return stub.exitCode } From 9c4ba055705b909180170df73c2caaee363daffe Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 17 Oct 2024 21:18:51 +0800 Subject: [PATCH 3/4] fix more lint issue Signed-off-by: yxxhero --- diff/diff.go | 6 +++--- main_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/diff/diff.go b/diff/diff.go index 47da73ab..aa2cd9b9 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -332,7 +332,7 @@ func printDiffRecords(suppressedKinds []string, kind string, context int, diffs for _, ckind := range suppressedKinds { if ckind == kind { str := fmt.Sprintf("+ Changes suppressed on sensitive content of type %s\n", kind) - fmt.Fprint(to, ansi.Color(str, "yellow")) + _, _ = fmt.Fprint(to, ansi.Color(str, "yellow")) return } } @@ -343,7 +343,7 @@ func printDiffRecords(suppressedKinds []string, kind string, context int, diffs for i, diff := range diffs { if distances[i] > context { if !omitting { - fmt.Fprintln(to, "...") + _, _ = fmt.Fprintln(to, "...") omitting = true } } else { @@ -368,7 +368,7 @@ func printDiffRecord(diff difflib.DiffRecord, to io.Writer) { _, _ = fmt.Fprintf(to, "%s\n", ansi.Color("- "+text, "red")) case difflib.Common: if text == "" { - fmt.Fprintln(to) + _, _ = fmt.Fprintln(to) } else { _, _ = fmt.Fprintf(to, "%s\n", " "+text) } diff --git a/main_test.go b/main_test.go index 44b2b4eb..89445916 100644 --- a/main_test.go +++ b/main_test.go @@ -76,7 +76,7 @@ func runFakeHelm() int { var stub *fakeHelmSubcmd if len(os.Args) < 2 { - fmt.Fprintln(os.Stderr, "fake helm does not support invocations without subcommands") + _, _ = fmt.Fprintln(os.Stderr, "fake helm does not support invocations without subcommands") return 1 } From 50bbf06cfa9fcf5ca74be7f10508404280d6cbfc Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 17 Oct 2024 21:19:42 +0800 Subject: [PATCH 4/4] fix more lint issue Signed-off-by: yxxhero --- .golangci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yaml b/.golangci.yaml index 12af8731..d532c5e9 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -291,7 +291,7 @@ linters: - depguard - errcheck - errorlint - - exportloopref + - copyloopvar - funlen - gci - gocognit