Skip to content

Commit

Permalink
Add pre-commit and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Aug 2, 2023
1 parent 17fc1a7 commit 55fe6e7
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 89 deletions.
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A clear and concise description of what the bug is.
**To Reproduce**

Steps to reproduce the behavior, such as:

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

**Your environment**
* Version of nginx-plus-go-client
* Version of NGINX Plus
* Version of the OS

- Version of nginx-plus-go-client
- Version of NGINX Plus
- Version of the OS

**Additional context**
Add any other context about the problem here.
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
### Proposed changes
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).

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).

### Checklist

Before creating a PR, run through this checklist and mark each as complete.

- [ ] I have read the [CONTRIBUTING](https://github.com/nginxinc/nginx-plus-go-client/blob/main/CONTRIBUTING.md) doc
Expand Down
18 changes: 18 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Rule configuration.
# For rule descriptions and how to fix: https://github.com/DavidAnson/markdownlint/tree/main#rules--aliases
config:
ul-style:
style: dash
no-duplicate-heading:
siblings_only: true
line-length:
line_length: 120
code_blocks: false
tables: false

# Define glob expressions to ignore
ignores:
- ".github/"

# Fix any fixable errors
fix: true
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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.4.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.53.3
hooks:
- id: golangci-lint
args: [--new-from-patch=/tmp/diff.patch]

- repo: https://github.com/gitleaks/gitleaks
rev: v8.17.0
hooks:
- id: gitleaks

- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.8.1
hooks:
- id: markdownlint-cli2

ci:
skip: [golang-diff, golangci-lint]
93 changes: 66 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Changelog

## 0.10.0 (Jul 19, 2022)

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)
Expand All @@ -11,65 +13,102 @@ An automatically generated list of changes can be found on GitHub at: [0.9.0 Rel
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)

## 0.7.0 (Jul 10, 2020)

FEATURES:
* [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.
* [41](https://github.com/nginxinc/nginx-plus-go-client/pull/41): *Support for /processes API endpoint*. The client now supports retrieving processes info.

- [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.
- [41](https://github.com/nginxinc/nginx-plus-go-client/pull/41): *Support for /processes API endpoint*. The client now
supports retrieving processes info.

CHANGES:
* The version of NGINX Plus for e2e testing was changed to R22.
* The version of Go was changed to 1.14

- The version of NGINX Plus for e2e testing was changed to R22.
- The version of Go was changed to 1.14

## 0.6.0 (Nov 8, 2019)

FEATURES:
* [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.

- [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.

CHANGES:
* 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.
* Client will assume port `80` in addresses of updated servers of `UpdateHTTPServers` and `UpdateStreamServers` if port is not explicitly set.
* The version of Go was changed to 1.13

- 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.
- Client will assume port `80` in addresses of updated servers of `UpdateHTTPServers` and `UpdateStreamServers` if port
is not explicitly set.
- The version of Go was changed to 1.13

## 0.5.0 (Sep 25, 2019)

FEATURES:
* [30](https://github.com/nginxinc/nginx-plus-go-client/pull/30): *Support additional upstream server parameters*.
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.
* [31](https://github.com/nginxinc/nginx-plus-go-client/pull/31): *Support location zones and resolver metrics*.

BUGFIXES:
* [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`.
- [30](https://github.com/nginxinc/nginx-plus-go-client/pull/30): *Support additional upstream server parameters*. 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.
- [31](https://github.com/nginxinc/nginx-plus-go-client/pull/31): *Support location zones and resolver metrics*.

FIXES:

- [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`.

CHANGES:
* The version of NGINX Plus for e2e testing was changed to R19.
* The version of the API was changed to 5.

- The version of NGINX Plus for e2e testing was changed to R19.
- The version of the API was changed to 5.

## 0.4.0 (July 17, 2019)

FEATURES:
* [24](https://github.com/nginxinc/nginx-plus-go-client/pull/24): *Support `MaxConns` in upstream servers*.

BUGFIXES:
* [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`.
- [24](https://github.com/nginxinc/nginx-plus-go-client/pull/24): *Support `MaxConns` in upstream servers*.

FIXES:

- [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`.

## 0.3.1 (June 10, 2019)

CHANGES:
* [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.

- [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.

## 0.3 (May 29, 2019)

FEATURES:
* [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.
* [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.
* [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).

- [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.
- [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.
- [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).

CHANGES:
* 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"`).
* The version of the API was changed to 4.
* The version of NGINX Plus for e2e testing was changed to R18.

- 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"`).
- The version of the API was changed to 4.
- The version of NGINX Plus for e2e testing was changed to R18.

## 0.2 (Sep 7, 2018)

FEATURES:
* [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.

- [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.

CHANGES:
* The version of NGINX Plus for e2e testing was changed to R16.

- The version of NGINX Plus for e2e testing was changed to R16.

## 0.1 (July 30, 2018)

Initial release
24 changes: 12 additions & 12 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

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

Examples of unacceptable behavior by participants include:

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

## Our Responsibilities
Expand All @@ -57,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
reported by contacting the project team at <[email protected]>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand All @@ -70,6 +70,6 @@ members of the project's leadership.
## Attribution

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

[homepage]: https://www.contributor-covenant.org
55 changes: 33 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Contributing Guidelines

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

#### Table Of Contents
## Table Of Contents

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

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

[Style Guides](#style-guides)
* [Git Style Guide](#git-style-guide)
* [Go Style Guide](#go-style-guide)

- [Git Style Guide](#git-style-guide)
- [Go Style Guide](#go-style-guide)

[Code of Conduct](CODE_OF_CONDUCT.md)

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

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


## Contributing

### Report a Bug

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.
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.

### Suggest an Enhancement

To suggest an enhancement, please create an issue on GitHub with the label `enhancement` using the available feature issue template.
To suggest an enhancement, please create an issue on GitHub with the label `enhancement` using the available feature
issue template.

### Open a Pull Request

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

> **Note**
>
> If you’d like to implement a new feature, please consider creating a feature request issue first to start a discussion about the feature.
> If you’d like to implement a new feature, please consider creating a feature request issue first to start a discussion
> about the feature.
### Issue lifecycle

* 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.
- 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.

## Style Guides

### Git Style Guide

* Keep a clean, concise and meaningful git commit history on your branch, rebasing locally and squashing before submitting a PR
* 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
* In the subject line, use the present tense ("Add feature" not "Added feature")
* In the subject line, use the imperative mood ("Move cursor to..." not "Moves cursor to...")
* Limit the subject line to 72 characters or less
* Reference issues and pull requests liberally after the subject line
* 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`)
- Keep a clean, concise and meaningful git commit history on your branch, rebasing locally and squashing before
submitting a PR
- 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
- In the subject line, use the present tense ("Add feature" not "Added feature")
- In the subject line, use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the subject line to 72 characters or less
- Reference issues and pull requests liberally after the subject line
- 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`)

### Go Style Guide

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

0 comments on commit 55fe6e7

Please sign in to comment.