-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11465ea
commit 56378e5
Showing
62 changed files
with
4,592 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
prometheus-rds-exporter | ||
metrics | ||
|
||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
coverage.txt | ||
coverage.xml | ||
lint-report.xml | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
# Build files | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
run: | ||
concurrency: 4 | ||
deadline: 2m | ||
issues-exit-code: 1 | ||
tests: true | ||
|
||
output: | ||
format: colored-line-number | ||
print-issued-lines: true | ||
print-linter-name: true | ||
|
||
linters: | ||
enable-all: false | ||
disable-all: false | ||
enable: | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- typecheck | ||
- unused | ||
- asciicheck | ||
- bodyclose | ||
- dogsled | ||
- durationcheck | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- forcetypeassert | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- godox | ||
- goerr113 | ||
- gofmt | ||
- gofumpt | ||
- goimports | ||
- gomnd | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- importas | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- prealloc | ||
- predeclared | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- stylecheck | ||
- testpackage | ||
- thelper | ||
- tparallel | ||
- unconvert | ||
- unparam | ||
- wastedassign | ||
- whitespace | ||
- wrapcheck | ||
- wsl | ||
|
||
linters-settings: | ||
gocyclo: | ||
min-complexity: 35 | ||
|
||
revive: | ||
rules: | ||
- name: exported | ||
disabled: true | ||
|
||
lll: | ||
line-length: 120 | ||
|
||
issues: | ||
exclude-use-default: false | ||
max-per-linter: 1024 | ||
max-same: 1024 | ||
|
||
exclude-rules: | ||
# Exclude some linters from running on test files | ||
- path: _test\.go | ||
linters: | ||
# bodyclose reports some false-positives when using a test request recorder | ||
- bodyclose | ||
# It's overkill to use `NewRequestWithContext` in tests | ||
- noctx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
env: | ||
- BUILD_INFO_PACKAGE_PATH=github.com/qonto/prometheus-rds-exporter/internal/infra/build | ||
- DOCKER_REGISTRY=public.ecr.aws/g1r8z6f4 | ||
- DOCKER_IMAGE_NAME=prometheus-rds-exporter | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
ldflags: | ||
- '-s' | ||
- '-w' | ||
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.Version={{.Version}}"' | ||
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.Commit={{.Commit}}"' | ||
- '-X "{{ .Env.BUILD_INFO_PACKAGE_PATH }}.Date={{.Date}}"' | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
|
||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of uname. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
# use zip for windows archives | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
|
||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
|
||
# changelog: | ||
# sort: asc | ||
# use: github | ||
# filters: | ||
# exclude: | ||
# - "^test:" | ||
# - "^chore" | ||
# - "merge conflict" | ||
# - Merge pull request | ||
# - Merge remote-tracking branch | ||
# - Merge branch | ||
# - go mod tidy | ||
# groups: | ||
# - title: Dependency updates | ||
# regexp: '^.*?(feat|fix)\(deps\)!?:.+$' | ||
# order: 300 | ||
# - title: "New Features" | ||
# regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' | ||
# order: 100 | ||
# - title: "Security updates" | ||
# regexp: '^.*?sec(\([[:word:]]+\))??!?:.+$' | ||
# order: 150 | ||
# - title: "Bug fixes" | ||
# regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' | ||
# order: 200 | ||
# - title: "Documentation updates" | ||
# regexp: ^.*?doc(\([[:word:]]+\))??!?:.+$ | ||
# order: 400 | ||
# - title: "Build process updates" | ||
# regexp: ^.*?build(\([[:word:]]+\))??!?:.+$ | ||
# order: 400 | ||
# - title: Other work | ||
# order: 9999 | ||
|
||
dockers: | ||
- image_templates: | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-amd64" | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-amd64" | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-amd64" | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-amd64" | ||
dockerfile: configs/goreleaser/Dockerfile | ||
build_flag_templates: | ||
- --label=org.opencontainers.image.title={{ .ProjectName }} | ||
- --label=org.opencontainers.image.description={{ .ProjectName }} | ||
- --label=org.opencontainers.image.url=https://github.com/goreleaser/example | ||
- --label=org.opencontainers.image.source=https://github.com/goreleaser/example | ||
- --label=org.opencontainers.image.version={{ .Version }} | ||
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} | ||
- --label=org.opencontainers.image.revision={{ .FullCommit }} | ||
- --label=org.opencontainers.image.licenses=MIT | ||
- "--pull" | ||
- "--platform=linux/amd64" | ||
- "--builder=desktop-linux" # TODO remove before public release | ||
use: buildx | ||
- image_templates: | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-arm64" | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-arm64" | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-arm64" | ||
- "{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-arm64" | ||
dockerfile: configs/goreleaser/Dockerfile | ||
build_flag_templates: | ||
- --label=org.opencontainers.image.title={{ .ProjectName }} | ||
- --label=org.opencontainers.image.description={{ .ProjectName }} | ||
- --label=org.opencontainers.image.url=https://github.com/goreleaser/example | ||
- --label=org.opencontainers.image.source=https://github.com/goreleaser/example | ||
- --label=org.opencontainers.image.version={{ .Version }} | ||
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} | ||
- --label=org.opencontainers.image.revision={{ .FullCommit }} | ||
- --label=org.opencontainers.image.licenses=MIT | ||
- "--pull" | ||
- "--platform=linux/arm64" | ||
- "--builder=desktop-linux" # TODO remove before public release | ||
goarch: arm64 | ||
|
||
docker_manifests: | ||
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}' | ||
image_templates: | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-amd64' | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Tag }}-arm64' | ||
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}' | ||
image_templates: | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-amd64' | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}-arm64' | ||
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}' | ||
image_templates: | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-amd64' | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:v{{ .Major }}.{{ .Minor }}-arm64' | ||
- name_template: '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest' | ||
image_templates: | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-amd64' | ||
- '{{ .Env.DOCKER_REGISTRY }}/{{ .Env.DOCKER_IMAGE_NAME }}:latest-arm64' | ||
|
||
release: | ||
disable: true | ||
github: | ||
owner: qonto | ||
name: prometheus-rds-exporter | ||
name_template: "v{{.Version}}" | ||
footer: | | ||
**Full Changelog**: https://github.com/qonto/poc-goreleaser/compare/{{ .PreviousTag }}...{{ .Tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Contributing | ||
|
||
Prometheus RDS exporter uses GitHub to manage reviews of pull requests. | ||
|
||
* If you are a new contributor see: [Steps to Contribute](#steps-to-contribute) | ||
|
||
* If you have a trivial fix or improvement, go ahead and create a pull request | ||
|
||
* Relevant coding style guidelines are the [Go Code Review | ||
Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) | ||
and the _Formatting and style_ section of Peter Bourgon's [Go: Best | ||
Practices for Production | ||
Environments](https://peter.bourgon.org/go-in-production/#formatting-and-style). | ||
|
||
* Be sure to enabled [signed commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) | ||
|
||
## Steps to Contribute | ||
|
||
Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on it. This is to prevent duplicated efforts from contributors on the same issue. | ||
|
||
For quickly compiling and testing your changes do: | ||
|
||
```bash | ||
# For building. | ||
make build | ||
./rds_exporter | ||
|
||
# For testing. | ||
make test # Make sure all the tests pass before you commit and push :) | ||
``` | ||
|
||
We use [`golangci-lint`](https://github.com/golangci/golangci-lint) for linting the code. If it reports an issue and you think that the warning needs to be disregarded or is a false-positive, you can add a special comment `//nolint:linter1[,linter2,...]` before the offending line. Use this sparingly though, fixing the code to comply with the linter's recommendation is in general the preferred course of action. | ||
|
||
All our issues are regularly tagged so that you can also filter down the issues involving the components you want to work on. | ||
|
||
## Pull Request Checklist | ||
|
||
* Branch from the `main` branch and, if needed, rebase to the current main branch before submitting your pull request. If it doesn't merge cleanly with main you may be asked to rebase your changes. | ||
|
||
* Commits should be as small as possible, while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests). | ||
|
||
* Add tests relevant to the fixed bug or new feature. | ||
|
||
* New Prometheus metrics must follow the [metric and label naming guidelines](https://prometheus.io/docs/practices/naming/) and be added in the `README.md` | ||
|
||
## Dependency management | ||
|
||
Project uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages. | ||
|
||
To add or update a new dependency, use the `go get` command: | ||
|
||
```bash | ||
# Pick the latest tagged release. | ||
go get example.com/some/module/pkg@latest | ||
|
||
# Pick a specific version. | ||
go get example.com/some/module/[email protected] | ||
``` | ||
|
||
Tidy up the `go.mod` and `go.sum` files: | ||
|
||
```bash | ||
# The GO111MODULE variable can be omitted when the code isn't located in GOPATH. | ||
GO111MODULE=on go mod tidy | ||
``` | ||
|
||
You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
kubeconform_command := kubeconform -kubernetes-version $${KUBERNETES_VERSION-1.25.0} -cache $${KUBECONFORM_CACHE_DIRECTORY-/tmp} -summary -exit-on-error --strict -schema-location default -schema-location 'kubeconform/{{ .ResourceKind }}{{ .KindSuffix }}.json' -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' | ||
BUILD_INFO_PACKAGE_PATH=github.com/qonto/prometheus-rds-exporter/internal/infra/build | ||
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
GIT_COMMIT_SHA=$(shell git rev-parse HEAD) | ||
AWS_ECR_PUBLIC_ORGANIZATION=g1r8z6f4 | ||
|
||
all: build | ||
|
||
.PHONY: format | ||
format: | ||
gofumpt -l -w . | ||
|
||
.PHONY: build | ||
build: | ||
CGO_ENABLED=0 go build -v -ldflags="-X '$(BUILD_INFO_PACKAGE_PATH).Version=development' -X '$(BUILD_INFO_PACKAGE_PATH).CommitSHA=$(GIT_COMMIT_SHA)' -X '$(BUILD_INFO_PACKAGE_PATH).Date=$(BUILD_DATE)'" -o prometheus-rds-exporter | ||
|
||
.PHONY: run | ||
run: | ||
./prometheus-rds-exporter $(argument) | ||
|
||
.PHONY: test | ||
test: | ||
go test -race -v ./... -coverprofile=coverage.txt -covermode atomic | ||
go install github.com/boumenot/gocover-cobertura@latest | ||
go run github.com/boumenot/gocover-cobertura@latest < coverage.txt > coverage.xml | ||
|
||
.PHONY: lint | ||
lint: | ||
golangci-lint run --verbose --timeout 2m --out-format junit-xml:lint-report.xml,colored-line-number | ||
|
||
.PHONY: helm-test | ||
helm-test: | ||
helm unittest configs/helm | ||
|
||
.PHONY: helm-release | ||
helm-release: | ||
./scripts/helm-release.sh prometheus-rds-exporter-chart $(RELEASE_VERSION) $(AWS_ECR_PUBLIC_ORGANIZATION) | ||
|
||
.PHONY: kubeconform | ||
kubeconform: | ||
helm template configs/helm | $(kubeconform_command) | ||
|
||
.PHONY: metrics-list | ||
metrics-list: | ||
echo "| Name | Description |" > metrics | ||
echo "| ------ | ----------- |" >> metrics | ||
curl -s localhost:9043/metrics | grep -E '^# HELP' | awk '{metric = $$3; $$1=$$2=$$3=""; print "| " metric " | " $$0 " | "}' | sed -e's/ */ /g' >> metrics | ||
|
||
.PHONY: all-tests | ||
all-tests: test kubeconform helm-test |
Oops, something went wrong.