From 48374550e8d1bb756a1f3ff2094307bcc61861a4 Mon Sep 17 00:00:00 2001 From: Damien Mulder <122604032+damienmulder@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:34:12 +0100 Subject: [PATCH 1/3] Bump actions/cache from v2 to v4 --- .github/workflows/build-and-publish-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish-image.yml b/.github/workflows/build-and-publish-image.yml index 0292c84..c2e7e76 100644 --- a/.github/workflows/build-and-publish-image.yml +++ b/.github/workflows/build-and-publish-image.yml @@ -39,7 +39,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Cache Docker layers - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} From 2226cb0885b4eaae978a5d2f075d889d726a7cc9 Mon Sep 17 00:00:00 2001 From: Damien Mulder Date: Fri, 28 Feb 2025 12:34:25 +0100 Subject: [PATCH 2/3] Linting --- internal/service/providers/pingdom.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/providers/pingdom.go b/internal/service/providers/pingdom.go index d62190a..2441720 100644 --- a/internal/service/providers/pingdom.go +++ b/internal/service/providers/pingdom.go @@ -220,10 +220,10 @@ func (m *PingdomUptimeProvider) checkToJSON(check model.UptimeCheck, includeType // update messages shouldn't include 'type', since the type of check can't be modified in Pingdom. message["type"] = "http" } - if m.settings.UserIDs != nil && len(m.settings.UserIDs) > 0 { + if len(m.settings.UserIDs) > 0 { message["userids"] = m.settings.UserIDs } - if m.settings.IntegrationIDs != nil && len(m.settings.IntegrationIDs) > 0 { + if len(m.settings.IntegrationIDs) > 0 { message["integrationids"] = m.settings.IntegrationIDs } From 72ad233102a825c181cc9cb600836ced3daa153f Mon Sep 17 00:00:00 2001 From: Richard Kettelerij Date: Fri, 28 Feb 2025 16:17:05 +0100 Subject: [PATCH 3/3] chore: update linting configuration, remove deprecated linters and align with GoKoala config --- .golangci.yml | 25 ++++++++++++++++++------- internal/model/check.go | 6 +++--- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e643524..2903bb3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,10 +16,11 @@ issues: linters: - bodyclose - dupl + - dogsled - funlen output: - format: colored-line-number + formats: colored-line-number print-issued-lines: true print-linter-name: true @@ -37,11 +38,15 @@ linters-settings: skip-tests: true funlen: lines: 100 - gomoddirectives: - replace-allow-list: - - github.com/abbot/go-http-auth # https://github.com/traefik/traefik/issues/6873#issuecomment-637654361 nestif: min-complexity: 6 + forbidigo: + forbid: + - http\.NotFound.* # return RFC 7807 problem details instead + - http\.Error.* # return RFC 7807 problem details instead + gomoddirectives: + replace-allow-list: + - github.com/abbot/go-http-auth linters: disable-all: true @@ -62,16 +67,19 @@ linters: - cyclop # checks function and package cyclomatic complexity - dupl # tool for code clone detection - durationcheck # checks for two durations multiplied together + - dogsled # find assignments/declarations with too many blank identifiers - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 - - execinquery # checks query string in Query function which reads your Go src files and warning it finds - exhaustive # checks exhaustiveness of enum switch statements - - exportloopref # checks for pointers to enclosing loop variables + - exptostd # detects functions from golang.org/x/exp/ that can be replaced by std functions + - copyloopvar # checks for pointers to enclosing loop variables + - fatcontext # detects nested contexts in loops and function literals - forbidigo # forbids identifiers - funlen # tool for detection of long functions - gocheckcompilerdirectives # validates go compiler directive comments (//go:) - goconst # finds repeated strings that could be replaced by a constant - gocritic # provides diagnostics that check for bugs, performance and style issues + - gofmt # checks if the code is formatted according to 'gofmt' command - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod - gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations @@ -79,6 +87,8 @@ linters: - gosec # inspects source code for security problems - loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap) - makezero # finds slice declarations with non-zero initial length + - mirror # reports wrong mirror patterns of bytes/strings usage + - misspell # finds commonly misspelled English words - nakedret # finds naked returns in functions greater than a specified function length - nestif # reports deeply nested if statements - nilerr # finds the code that returns nil even if it checks that the error is not nil @@ -92,7 +102,8 @@ linters: - rowserrcheck # checks whether Err of rows is checked successfully - sqlclosecheck # checks that sql.Rows and sql.Stmt are closed - sloglint # A Go linter that ensures consistent code style when using log/slog - - tenv # detects using os.Setenv instead of t.Setenv since Go1.17 + - tagliatelle # checks the struct tags. + - usetesting # detects using os.Setenv instead of t.Setenv since Go1.17 - testableexamples # checks if examples are testable (have an expected output) - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes - unconvert # removes unnecessary type conversions diff --git a/internal/model/check.go b/internal/model/check.go index db34d80..62200cc 100644 --- a/internal/model/check.go +++ b/internal/model/check.go @@ -29,9 +29,9 @@ type UptimeCheck struct { Name string `json:"name"` URL string `json:"url"` Tags []string `json:"tags"` - RequestHeaders map[string]string `json:"request_headers"` - StringContains string `json:"string_contains"` - StringNotContains string `json:"string_not_contains"` + RequestHeaders map[string]string `json:"request_headers"` //nolint:tagliatelle // grandfathered in + StringContains string `json:"string_contains"` //nolint:tagliatelle // grandfathered in + StringNotContains string `json:"string_not_contains"` //nolint:tagliatelle // grandfathered in } func NewUptimeCheck(ingressName string, annotations map[string]string) (*UptimeCheck, error) {