From e821c28630856448502ff33bd7d8f1570da4f9ee Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Wed, 7 Feb 2024 19:35:12 -0800 Subject: [PATCH] Run on all file --- .pre-commit-config.yaml | 68 ++++++++++++++++++----------------------- client/nginx.go | 12 ++++---- tests/client_test.go | 7 ----- 3 files changed, 35 insertions(+), 52 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a860e1d3..0d214ee8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,47 +1,37 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - args: [--allow-multiple-documents] - - id: check-added-large-files - - id: check-merge-conflict - - id: check-shebang-scripts-are-executable - - id: check-case-conflict - - id: check-vcs-permalinks - - id: mixed-line-ending - args: [--fix=lf] - - id: no-commit-to-branch - - id: fix-byte-order-marker + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + args: [--allow-multiple-documents] + - id: check-added-large-files + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-case-conflict + - id: check-vcs-permalinks + - id: mixed-line-ending + args: [--fix=lf] + - id: no-commit-to-branch + - id: fix-byte-order-marker -- repo: local - hooks: - - id: golang-diff - name: create-go-diff - entry: bash -c 'git diff -p origin/main > /tmp/diff.patch' - language: system - types: [go] - pass_filenames: false + - repo: https://github.com/golangci/golangci-lint + rev: v1.55.2 + hooks: + - id: golangci-lint -- repo: https://github.com/golangci/golangci-lint - rev: v1.55.2 - hooks: - - id: golangci-lint - args: [--new-from-patch=/tmp/diff.patch] + - repo: https://github.com/gitleaks/gitleaks + rev: v8.18.2 + hooks: + - id: gitleaks -- repo: https://github.com/gitleaks/gitleaks - rev: v8.18.2 - hooks: - - id: gitleaks - -- repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.12.1 - hooks: - - id: markdownlint-cli2 + - repo: https://github.com/DavidAnson/markdownlint-cli2 + rev: v0.12.1 + hooks: + - id: markdownlint-cli2 ci: - skip: [golang-diff, golangci-lint] + skip: [golangci-lint] diff --git a/client/nginx.go b/client/nginx.go index 41bb77be..7b06d65a 100644 --- a/client/nginx.go +++ b/client/nginx.go @@ -560,7 +560,7 @@ func NewNginxClient(apiEndpoint string, opts ...Option) (*NginxClient, error) { } if c.httpClient == nil { - return nil, fmt.Errorf("http client is not set") + return nil, errors.New("http client is not set") } if !versionSupported(c.apiVersion) { @@ -1510,7 +1510,7 @@ func (client *NginxClient) getKeyValPairs(zone string, stream bool) (KeyValPairs base = "stream" } if zone == "" { - return nil, fmt.Errorf("zone required") + return nil, errors.New("zone required") } path := fmt.Sprintf("%v/keyvals/%v", base, zone) @@ -1563,7 +1563,7 @@ func (client *NginxClient) addKeyValPair(zone string, key string, val string, st base = "stream" } if zone == "" { - return fmt.Errorf("zone required") + return errors.New("zone required") } path := fmt.Sprintf("%v/keyvals/%v", base, zone) @@ -1591,7 +1591,7 @@ func (client *NginxClient) modifyKeyValPair(zone string, key string, val string, base = "stream" } if zone == "" { - return fmt.Errorf("zone required") + return errors.New("zone required") } path := fmt.Sprintf("%v/keyvals/%v", base, zone) @@ -1621,7 +1621,7 @@ func (client *NginxClient) deleteKeyValuePair(zone string, key string, stream bo base = "stream" } if zone == "" { - return fmt.Errorf("zone required") + return errors.New("zone required") } // map[string]string can't have a nil value so we use a different type here. @@ -1652,7 +1652,7 @@ func (client *NginxClient) deleteKeyValPairs(zone string, stream bool) error { base = "stream" } if zone == "" { - return fmt.Errorf("zone required") + return errors.New("zone required") } path := fmt.Sprintf("%v/keyvals/%v", base, zone) diff --git a/tests/client_test.go b/tests/client_test.go index f580ad71..5a65a539 100644 --- a/tests/client_test.go +++ b/tests/client_test.go @@ -48,7 +48,6 @@ func TestStreamClient(t *testing.T) { // test adding a stream server err = c.AddStreamServer(streamUpstream, streamServer) - if err != nil { t.Fatalf("Error when adding a server: %v", err) } @@ -211,7 +210,6 @@ func TestStreamClient(t *testing.T) { // updating with 2 new servers, 1 existing added, deleted, updated, err = c.UpdateStreamServers(streamUpstream, streamServers2) - if err != nil { t.Fatalf("Error when updating servers: %v", err) } @@ -228,7 +226,6 @@ func TestStreamClient(t *testing.T) { // updating with zero servers - removing added, deleted, updated, err = c.UpdateStreamServers(streamUpstream, []client.StreamUpstreamServer{}) - if err != nil { t.Fatalf("Error when updating servers: %v", err) } @@ -326,7 +323,6 @@ func TestClient(t *testing.T) { // test adding a http server err = c.AddHTTPServer(upstream, server) - if err != nil { t.Fatalf("Error when adding a server: %v", err) } @@ -391,7 +387,6 @@ func TestClient(t *testing.T) { // updating with the same servers added, deleted, updated, err = c.UpdateHTTPServers(upstream, servers1) - if err != nil { t.Fatalf("Error when updating servers: %v", err) } @@ -484,7 +479,6 @@ func TestClient(t *testing.T) { // updating with 2 new servers, 1 existing added, deleted, updated, err = c.UpdateHTTPServers(upstream, servers2) - if err != nil { t.Fatalf("Error when updating servers: %v", err) } @@ -501,7 +495,6 @@ func TestClient(t *testing.T) { // updating with zero servers - removing added, deleted, updated, err = c.UpdateHTTPServers(upstream, []client.UpstreamServer{}) - if err != nil { t.Fatalf("Error when updating servers: %v", err) }