Skip to content

Commit

Permalink
Run on all file
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Feb 8, 2024
1 parent 56fb59a commit df07ac9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 52 deletions.
68 changes: 29 additions & 39 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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-full

- 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-full]
12 changes: 6 additions & 6 deletions client/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions tests/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit df07ac9

Please sign in to comment.