Add pre-commit to the repo
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This adds pre-commit which can be used to enforce consistent style and common errors (like committing large files)
This commit is contained in:
parent
b808df7365
commit
9b9f803231
@ -13,6 +13,12 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- make test
|
- make test
|
||||||
|
|
||||||
|
- name: check
|
||||||
|
image: python:3
|
||||||
|
commands:
|
||||||
|
- pip install pre-commit==1.20.0
|
||||||
|
- make check
|
||||||
|
|
||||||
- name: notify
|
- name: notify
|
||||||
image: drillster/drone-email
|
image: drillster/drone-email
|
||||||
settings:
|
settings:
|
||||||
|
19
.pre-commit-config.yaml
Normal file
19
.pre-commit-config.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v2.4.0
|
||||||
|
hooks:
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-yaml
|
||||||
|
args:
|
||||||
|
- --allow-multiple-documents
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- repo: git://github.com/dnephin/pre-commit-golang
|
||||||
|
rev: v0.3.5
|
||||||
|
hooks:
|
||||||
|
- id: go-fmt
|
||||||
|
- id: go-imports
|
||||||
|
# - id: gometalinter
|
||||||
|
# - id: golangci-lint
|
20
LICENSE
20
LICENSE
@ -7,17 +7,17 @@ AND DISTRIBUTION
|
|||||||
|
|
||||||
1. Definitions.
|
1. Definitions.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction, and distribution
|
"License" shall mean the terms and conditions for use, reproduction, and distribution
|
||||||
as defined by Sections 1 through 9 of this document.
|
as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||||
owner that is granting the License.
|
owner that is granting the License.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||||
that control, are controlled by, or are under common control with that entity.
|
that control, are controlled by, or are under common control with that entity.
|
||||||
@ -26,31 +26,31 @@ or indirect, to cause the direction or management of such entity, whether
|
|||||||
by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
|
by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
|
||||||
of the outstanding shares, or (iii) beneficial ownership of such entity.
|
of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions
|
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions
|
||||||
granted by this License.
|
granted by this License.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications, including
|
"Source" form shall mean the preferred form for making modifications, including
|
||||||
but not limited to software source code, documentation source, and configuration
|
but not limited to software source code, documentation source, and configuration
|
||||||
files.
|
files.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical transformation
|
"Object" form shall mean any form resulting from mechanical transformation
|
||||||
or translation of a Source form, including but not limited to compiled object
|
or translation of a Source form, including but not limited to compiled object
|
||||||
code, generated documentation, and conversions to other media types.
|
code, generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or Object form,
|
"Work" shall mean the work of authorship, whether in Source or Object form,
|
||||||
made available under the License, as indicated by a copyright notice that
|
made available under the License, as indicated by a copyright notice that
|
||||||
is included in or attached to the work (an example is provided in the Appendix
|
is included in or attached to the work (an example is provided in the Appendix
|
||||||
below).
|
below).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object form,
|
"Derivative Works" shall mean any work, whether in Source or Object form,
|
||||||
that is based on (or derived from) the Work and for which the editorial revisions,
|
that is based on (or derived from) the Work and for which the editorial revisions,
|
||||||
@ -59,7 +59,7 @@ original work of authorship. For the purposes of this License, Derivative
|
|||||||
Works shall not include works that remain separable from, or merely link (or
|
Works shall not include works that remain separable from, or merely link (or
|
||||||
bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including the original version
|
"Contribution" shall mean any work of authorship, including the original version
|
||||||
of the Work and any modifications or additions to that Work or Derivative
|
of the Work and any modifications or additions to that Work or Derivative
|
||||||
@ -74,7 +74,7 @@ for the purpose of discussing and improving the Work, but excluding communicatio
|
|||||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||||
owner as "Not a Contribution."
|
owner as "Not a Contribution."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||||
of whom a Contribution has been received by Licensor and subsequently incorporated
|
of whom a Contribution has been received by Licensor and subsequently incorporated
|
||||||
|
10
Makefile
10
Makefile
@ -29,6 +29,16 @@ test:
|
|||||||
@go tool cover -func=coverage.out | awk -v target=80.0% \
|
@go tool cover -func=coverage.out | awk -v target=80.0% \
|
||||||
'/^total:/ { print "Total coverage: " $$3 " Minimum coverage: " target; if ($$3+0.0 >= target+0.0) print "ok"; else { print "fail"; exit 1; } }'
|
'/^total:/ { print "Total coverage: " $$3 " Minimum coverage: " target; if ($$3+0.0 >= target+0.0) print "ok"; else { print "fail"; exit 1; } }'
|
||||||
|
|
||||||
|
# Installs pre-commit hooks
|
||||||
|
.PHONY: install-hooks
|
||||||
|
install-hooks:
|
||||||
|
pre-commit install --install-hooks
|
||||||
|
|
||||||
|
# Checks files for encryption
|
||||||
|
.PHONY: check
|
||||||
|
check:
|
||||||
|
pre-commit run --all-files
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f ./minitor-go
|
rm -f ./minitor-go
|
||||||
|
@ -2,10 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config type is contains all provided user configuration
|
// Config type is contains all provided user configuration
|
||||||
|
@ -2,10 +2,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
// "github.com/prometheus/client_golang/prometheus/promauto"
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Not sure if this is the best way to handle. A global instance for
|
// TODO: Not sure if this is the best way to handle. A global instance for
|
||||||
|
@ -6,4 +6,3 @@ monitors:
|
|||||||
alert_down: [ 'alert_down', 'log_shell', 'log_command' ]
|
alert_down: [ 'alert_down', 'log_shell', 'log_command' ]
|
||||||
# alert_every: -1
|
# alert_every: -1
|
||||||
alert_every: 0
|
alert_every: 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user