Skip to content

Commit 55fe6e7

Browse files
committed
Add pre-commit and fix issues
1 parent 17fc1a7 commit 55fe6e7

File tree

10 files changed

+229
-89
lines changed

10 files changed

+229
-89
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A clear and concise description of what the bug is.
1010
**To Reproduce**
1111

1212
Steps to reproduce the behavior, such as:
13+
1314
1. Try adding upstream through the client
1415
2. Returns a panic
1516
3. Here is the stacktrace
@@ -18,9 +19,10 @@ Steps to reproduce the behavior, such as:
1819
A clear and concise description of what you expected to happen.
1920

2021
**Your environment**
21-
* Version of nginx-plus-go-client
22-
* Version of NGINX Plus
23-
* Version of the OS
22+
23+
- Version of nginx-plus-go-client
24+
- Version of NGINX Plus
25+
- Version of the OS
2426

2527
**Additional context**
2628
Add any other context about the problem here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
### Proposed changes
2-
Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue here in this description (not in the title of the PR).
2+
3+
Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to
4+
that issue here in this description (not in the title of the PR).
35

46
### Checklist
7+
58
Before creating a PR, run through this checklist and mark each as complete.
69

710
- [ ] I have read the [CONTRIBUTING](https://github.com/nginxinc/nginx-plus-go-client/blob/main/CONTRIBUTING.md) doc

.markdownlint-cli2.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Rule configuration.
2+
# For rule descriptions and how to fix: https://github.com/DavidAnson/markdownlint/tree/main#rules--aliases
3+
config:
4+
ul-style:
5+
style: dash
6+
no-duplicate-heading:
7+
siblings_only: true
8+
line-length:
9+
line_length: 120
10+
code_blocks: false
11+
tables: false
12+
13+
# Define glob expressions to ignore
14+
ignores:
15+
- ".github/"
16+
17+
# Fix any fixable errors
18+
fix: true

.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
args: [--allow-multiple-documents]
11+
- id: check-added-large-files
12+
- id: check-merge-conflict
13+
- id: check-shebang-scripts-are-executable
14+
- id: check-case-conflict
15+
- id: check-vcs-permalinks
16+
- id: mixed-line-ending
17+
args: [--fix=lf]
18+
- id: no-commit-to-branch
19+
- id: fix-byte-order-marker
20+
21+
- repo: local
22+
hooks:
23+
- id: golang-diff
24+
name: create-go-diff
25+
entry: bash -c 'git diff -p origin/main > /tmp/diff.patch'
26+
language: system
27+
types: [go]
28+
pass_filenames: false
29+
30+
- repo: https://github.com/golangci/golangci-lint
31+
rev: v1.53.3
32+
hooks:
33+
- id: golangci-lint
34+
args: [--new-from-patch=/tmp/diff.patch]
35+
36+
- repo: https://github.com/gitleaks/gitleaks
37+
rev: v8.17.0
38+
hooks:
39+
- id: gitleaks
40+
41+
- repo: https://github.com/DavidAnson/markdownlint-cli2
42+
rev: v0.8.1
43+
hooks:
44+
- id: markdownlint-cli2
45+
46+
ci:
47+
skip: [golang-diff, golangci-lint]

CHANGELOG.md

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Changelog
2+
13
## 0.10.0 (Jul 19, 2022)
24

35
An automatically generated list of changes can be found on GitHub at: [0.10.0 Release](https://github.com/nginxinc/nginx-plus-go-client/releases/tag/v0.10.0)
@@ -11,65 +13,102 @@ An automatically generated list of changes can be found on GitHub at: [0.9.0 Rel
1113
An automatically generated list of changes can be found on GitHub at: [0.8.0 Release](https://github.com/nginxinc/nginx-plus-go-client/releases/tag/v0.8.0)
1214

1315
## 0.7.0 (Jul 10, 2020)
16+
1417
FEATURES:
15-
* [38](https://github.com/nginxinc/nginx-plus-go-client/pull/38): *Support for /slabs API endpoint*. The client now supports retrieving shared memory zone usage info.
16-
* [41](https://github.com/nginxinc/nginx-plus-go-client/pull/41): *Support for /processes API endpoint*. The client now supports retrieving processes info.
18+
19+
- [38](https://github.com/nginxinc/nginx-plus-go-client/pull/38): *Support for /slabs API endpoint*. The client now
20+
supports retrieving shared memory zone usage info.
21+
- [41](https://github.com/nginxinc/nginx-plus-go-client/pull/41): *Support for /processes API endpoint*. The client now
22+
supports retrieving processes info.
1723

1824
CHANGES:
19-
* The version of NGINX Plus for e2e testing was changed to R22.
20-
* The version of Go was changed to 1.14
25+
26+
- The version of NGINX Plus for e2e testing was changed to R22.
27+
- The version of Go was changed to 1.14
2128

2229
## 0.6.0 (Nov 8, 2019)
30+
2331
FEATURES:
24-
* [34](https://github.com/nginxinc/nginx-plus-go-client/pull/34): *Support for updating upstream servers parameters*. The client now supports updating upstream parameters of servers that already exist in NGINX Plus.
32+
33+
- [34](https://github.com/nginxinc/nginx-plus-go-client/pull/34): *Support for updating upstream servers parameters*.
34+
The client now supports updating upstream parameters of servers that already exist in NGINX Plus.
2535

2636
CHANGES:
27-
* Public methods `UpdateHTTPServers` and `UpdateStreamServers` now return a third slice that includes the updated servers -- i.e. the servers that were already present in NGINX Plus but were updated with different parameters.
28-
* Client will assume port `80` in addresses of updated servers of `UpdateHTTPServers` and `UpdateStreamServers` if port is not explicitly set.
29-
* The version of Go was changed to 1.13
37+
38+
- Public methods `UpdateHTTPServers` and `UpdateStreamServers` now return a third slice that includes the updated
39+
servers -- i.e. the servers that were already present in NGINX Plus but were updated with different parameters.
40+
- Client will assume port `80` in addresses of updated servers of `UpdateHTTPServers` and `UpdateStreamServers` if port
41+
is not explicitly set.
42+
- The version of Go was changed to 1.13
3043

3144
## 0.5.0 (Sep 25, 2019)
45+
3246
FEATURES:
33-
* [30](https://github.com/nginxinc/nginx-plus-go-client/pull/30): *Support additional upstream server parameters*.
34-
The client now supports configuring `route`, `backup`, `down`, `drain`, `weight` and `service` parameters for http upstreams and `backup`, `down`, `weight` and `service` parameters for stream upstreams.
35-
* [31](https://github.com/nginxinc/nginx-plus-go-client/pull/31): *Support location zones and resolver metrics*.
3647

37-
BUGFIXES:
38-
* [29](https://github.com/nginxinc/nginx-plus-go-client/pull/29): *Fix max_fails parameter in upstream servers*. Previously, if the MaxFails field was not explicitly set, the client would incorrectly configure an upstream with the value `0` instead of the correct value `1`.
48+
- [30](https://github.com/nginxinc/nginx-plus-go-client/pull/30): *Support additional upstream server parameters*. The
49+
client now supports configuring `route`, `backup`, `down`, `drain`, `weight` and `service` parameters for http
50+
upstreams and `backup`, `down`, `weight` and `service` parameters for stream upstreams.
51+
- [31](https://github.com/nginxinc/nginx-plus-go-client/pull/31): *Support location zones and resolver metrics*.
52+
53+
FIXES:
54+
55+
- [29](https://github.com/nginxinc/nginx-plus-go-client/pull/29): *Fix max_fails parameter in upstream servers*.
56+
Previously, if the MaxFails field was not explicitly set, the client would incorrectly configure an upstream with the
57+
value `0` instead of the correct value `1`.
3958

4059
CHANGES:
41-
* The version of NGINX Plus for e2e testing was changed to R19.
42-
* The version of the API was changed to 5.
60+
61+
- The version of NGINX Plus for e2e testing was changed to R19.
62+
- The version of the API was changed to 5.
4363

4464
## 0.4.0 (July 17, 2019)
65+
4566
FEATURES:
46-
* [24](https://github.com/nginxinc/nginx-plus-go-client/pull/24): *Support `MaxConns` in upstream servers*.
4767

48-
BUGFIXES:
49-
* [25](https://github.com/nginxinc/nginx-plus-go-client/pull/25): *Fix session metrics for stream server zones*. Session metrics with a status of `4xx` or `5xx` are now correctly reported. Previously they were always reported as `0`.
68+
- [24](https://github.com/nginxinc/nginx-plus-go-client/pull/24): *Support `MaxConns` in upstream servers*.
69+
70+
FIXES:
71+
72+
- [25](https://github.com/nginxinc/nginx-plus-go-client/pull/25): *Fix session metrics for stream server zones*. Session
73+
metrics with a status of `4xx` or `5xx` are now correctly reported. Previously they were always reported as `0`.
5074

5175
## 0.3.1 (June 10, 2019)
76+
5277
CHANGES:
53-
* [22](https://github.com/nginxinc/nginx-plus-go-client/pull/22): *Change in stream zone sync metrics*. `StreamZoneSync` field of the `Stats` type is now a pointer. It will be nil if NGINX Plus doesn't report any zone sync stats.
78+
79+
- [22](https://github.com/nginxinc/nginx-plus-go-client/pull/22): *Change in stream zone sync metrics*. `StreamZoneSync`
80+
field of the `Stats` type is now a pointer. It will be nil if NGINX Plus doesn't report any zone sync stats.
5481

5582
## 0.3 (May 29, 2019)
83+
5684
FEATURES:
57-
* [20](https://github.com/nginxinc/nginx-plus-go-client/pull/20): *Support for stream zone sync metrics*. The client `GetStats` method now additionally returns stream zone sync metrics.
58-
* [13](https://github.com/nginxinc/nginx-plus-go-client/pull/13): *Support for key-value endpoints*. The client implements a set of methods to create/modify/delete key-val pairs for both http and stream contexts.
59-
* [12](https://github.com/nginxinc/nginx-plus-go-client/pull/12) *Support for NGINX status info*. The client `GetStats` method now additionally returns NGINX status metrics. Thanks to [jthurman42](https://github.com/jthurman42).
85+
86+
- [20](https://github.com/nginxinc/nginx-plus-go-client/pull/20): *Support for stream zone sync metrics*. The client
87+
`GetStats` method now additionally returns stream zone sync metrics.
88+
- [13](https://github.com/nginxinc/nginx-plus-go-client/pull/13): *Support for key-value endpoints*. The client
89+
implements a set of methods to create/modify/delete key-val pairs for both http and stream contexts.
90+
- [12](https://github.com/nginxinc/nginx-plus-go-client/pull/12) *Support for NGINX status info*. The client `GetStats`
91+
method now additionally returns NGINX status metrics. Thanks to [jthurman42](https://github.com/jthurman42).
6092

6193
CHANGES:
62-
* The repository was renamed to `nginx-plus-go-client` instead of `nginx-plus-go-sdk`. If the client is used as a dependency, this name needs to be changed in the import section (`import "github.com/nginxinc/nginx-plus-go-client/client"`).
63-
* The version of the API was changed to 4.
64-
* The version of NGINX Plus for e2e testing was changed to R18.
94+
95+
- The repository was renamed to `nginx-plus-go-client` instead of `nginx-plus-go-sdk`. If the client is used as a
96+
dependency, this name needs to be changed in the import section (`import
97+
"github.com/nginxinc/nginx-plus-go-client/client"`).
98+
- The version of the API was changed to 4.
99+
- The version of NGINX Plus for e2e testing was changed to R18.
65100

66101
## 0.2 (Sep 7, 2018)
67102

68103
FEATURES:
69-
* [7](https://github.com/nginxinc/nginx-plus-go-sdk/pull/7): *Support for stream server zone and stream upstream metrics*. The client `GetStats` method now additionally returns stream server zone and stream upstream metrics.
104+
105+
- [7](https://github.com/nginxinc/nginx-plus-go-sdk/pull/7): *Support for stream server zone and stream upstream
106+
metrics*. The client `GetStats` method now additionally returns stream server zone and stream upstream metrics.
70107

71108
CHANGES:
72-
* The version of NGINX Plus for e2e testing was changed to R16.
109+
110+
- The version of NGINX Plus for e2e testing was changed to R16.
73111

74112
## 0.1 (July 30, 2018)
113+
75114
Initial release

CODE_OF_CONDUCT.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ appearance, race, religion, or sexual identity and orientation.
1616
Examples of behavior that contributes to creating a positive environment
1717
include:
1818

19-
* Using welcoming and inclusive language
20-
* Being respectful of differing viewpoints and experiences
21-
* Gracefully accepting constructive criticism
22-
* Focusing on what is best for the community
23-
* Showing empathy towards other community members
19+
- Using welcoming and inclusive language
20+
- Being respectful of differing viewpoints and experiences
21+
- Gracefully accepting constructive criticism
22+
- Focusing on what is best for the community
23+
- Showing empathy towards other community members
2424

2525
Examples of unacceptable behavior by participants include:
2626

27-
* The use of sexualized language or imagery and unwelcome sexual attention or
27+
- The use of sexualized language or imagery and unwelcome sexual attention or
2828
advances
29-
* Trolling, insulting/derogatory comments, and personal or political attacks
30-
* Public or private harassment
31-
* Publishing others' private information, such as a physical or electronic
29+
- Trolling, insulting/derogatory comments, and personal or political attacks
30+
- Public or private harassment
31+
- Publishing others' private information, such as a physical or electronic
3232
address, without explicit permission
33-
* Other conduct which could reasonably be considered inappropriate in a
33+
- Other conduct which could reasonably be considered inappropriate in a
3434
professional setting
3535

3636
## Our Responsibilities
@@ -57,7 +57,7 @@ further defined and clarified by project maintainers.
5757
## Enforcement
5858

5959
Instances of abusive, harassing, or otherwise unacceptable behavior may be
60-
reported by contacting the project team at integrations@nginx.com. All
60+
reported by contacting the project team at <integrations@nginx.com>. All
6161
complaints will be reviewed and investigated and will result in a response that
6262
is deemed necessary and appropriate to the circumstances. The project team is
6363
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -70,6 +70,6 @@ members of the project's leadership.
7070
## Attribution
7171

7272
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
73-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
73+
available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
7474

7575
[homepage]: https://www.contributor-covenant.org

CONTRIBUTING.md

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Contributing Guidelines
22

3-
The following is a set of guidelines for contributing to the NGINX Plus Go Client. We really appreciate that you are considering contributing!
3+
The following is a set of guidelines for contributing to the NGINX Plus Go Client. We really appreciate that you are
4+
considering contributing!
45

5-
#### Table Of Contents
6+
## Table Of Contents
67

78
[Ask a Question](#ask-a-question)
89

@@ -11,8 +12,9 @@ The following is a set of guidelines for contributing to the NGINX Plus Go Clien
1112
[Contributing](#contributing)
1213

1314
[Style Guides](#style-guides)
14-
* [Git Style Guide](#git-style-guide)
15-
* [Go Style Guide](#go-style-guide)
15+
16+
- [Git Style Guide](#git-style-guide)
17+
- [Go Style Guide](#go-style-guide)
1618

1719
[Code of Conduct](CODE_OF_CONDUCT.md)
1820

@@ -28,45 +30,54 @@ Please reserve GitHub issues for feature requests and bugs rather than general q
2830

2931
Read the usage and testing steps in the [README](README.md).
3032

31-
3233
## Contributing
3334

3435
### Report a Bug
3536

36-
To report a bug, open an issue on GitHub with the label `bug` using the available bug report issue template. Please ensure the issue has not already been reported.
37+
To report a bug, open an issue on GitHub with the label `bug` using the available bug report issue template. Please
38+
ensure the issue has not already been reported.
3739

3840
### Suggest an Enhancement
3941

40-
To suggest an enhancement, please create an issue on GitHub with the label `enhancement` using the available feature issue template.
42+
To suggest an enhancement, please create an issue on GitHub with the label `enhancement` using the available feature
43+
issue template.
4144

4245
### Open a Pull Request
4346

44-
* Fork the repo, create a branch, submit a PR when your changes are tested and ready for review
45-
* Fill in [our pull request template](.github/PULL_REQUEST_TEMPLATE.md)
47+
- Fork the repo, create a branch, submit a PR when your changes are tested and ready for review
48+
- Fill in [our pull request template](.github/PULL_REQUEST_TEMPLATE.md)
4649

4750
> **Note**
4851
>
49-
> If you’d like to implement a new feature, please consider creating a feature request issue first to start a discussion about the feature.
52+
> If you’d like to implement a new feature, please consider creating a feature request issue first to start a discussion
53+
> about the feature.
5054
5155
### Issue lifecycle
5256

53-
* When an issue or PR is created, it will be triaged by the core development team and assigned a label to indicate the type of issue it is (bug, feature request, etc) and to determine the milestone. Please see the [Issue Lifecycle](ISSUE_LIFECYCLE.md) document for more information.
57+
- When an issue or PR is created, it will be triaged by the core development team and assigned a label to indicate the
58+
type of issue it is (bug, feature request, etc) and to determine the milestone. Please see the [Issue
59+
Lifecycle](ISSUE_LIFECYCLE.md) document for more information.
5460

5561
## Style Guides
5662

5763
### Git Style Guide
5864

59-
* Keep a clean, concise and meaningful git commit history on your branch, rebasing locally and squashing before submitting a PR
60-
* Follow the guidelines of writing a good commit message as described here https://chris.beams.io/posts/git-commit/ and summarized in the next few points
61-
* In the subject line, use the present tense ("Add feature" not "Added feature")
62-
* In the subject line, use the imperative mood ("Move cursor to..." not "Moves cursor to...")
63-
* Limit the subject line to 72 characters or less
64-
* Reference issues and pull requests liberally after the subject line
65-
* Add more detailed description in the body of the git message (`git commit -a` to give you more space and time in your text editor to write a good message instead of `git commit -am`)
65+
- Keep a clean, concise and meaningful git commit history on your branch, rebasing locally and squashing before
66+
submitting a PR
67+
- Follow the guidelines of writing a good commit message as described here <https://chris.beams.io/posts/git-commit/>
68+
and summarized in the next few points
69+
- In the subject line, use the present tense ("Add feature" not "Added feature")
70+
- In the subject line, use the imperative mood ("Move cursor to..." not "Moves cursor to...")
71+
- Limit the subject line to 72 characters or less
72+
- Reference issues and pull requests liberally after the subject line
73+
- Add more detailed description in the body of the git message (`git commit -a` to give you more space and time in
74+
your text editor to write a good message instead of `git commit -am`)
6675

6776
### Go Style Guide
6877

69-
* Run `gofmt` over your code to automatically resolve a lot of style issues. Most editors support this running automatically when saving a code file.
70-
* Run `go lint` and `go vet` on your code too to catch any other issues.
71-
* Follow this guide on some good practice and idioms for Go - https://github.com/golang/go/wiki/CodeReviewComments
72-
* To check for extra issues, install [golangci-lint](https://github.com/golangci/golangci-lint) and run `make lint` or `golangci-lint run`
78+
- Run `gofmt` over your code to automatically resolve a lot of style issues. Most editors support this running
79+
automatically when saving a code file.
80+
- Run `go lint` and `go vet` on your code too to catch any other issues.
81+
- Follow this guide on some good practice and idioms for Go - <https://github.com/golang/go/wiki/CodeReviewComments>
82+
- To check for extra issues, install [golangci-lint](https://github.com/golangci/golangci-lint) and run `make lint` or
83+
`golangci-lint run`

0 commit comments

Comments
 (0)