Introduce pre-commit hooks
This commit is contained in:
parent
28d084da36
commit
675bb089d8
3 changed files with 32 additions and 7 deletions
25
.pre-commit-config.yaml
Normal file
25
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Pre-commit hooks to run tests and ensure code is cleaned.
|
||||||
|
# See https://pre-commit.com for more information
|
||||||
|
---
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/codespell-project/codespell
|
||||||
|
rev: v2.2.2
|
||||||
|
hooks:
|
||||||
|
- id: codespell
|
||||||
|
args:
|
||||||
|
- --ignore-words-list=exten
|
||||||
|
- --skip="./.*,*.csv,*.json,*.ini,*.subject,*.txt,*.html,*.log,*.conf"
|
||||||
|
- --quiet-level=2
|
||||||
|
- --ignore-regex=.*codespell-ignore$
|
||||||
|
#- --write-changes # Uncomment to write changes
|
||||||
|
exclude_types: [csv, json]
|
||||||
|
- repo: https://github.com/adrienverge/yamllint
|
||||||
|
rev: v1.32.0
|
||||||
|
hooks:
|
||||||
|
- id: yamllint
|
||||||
|
ignore: .github/
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
|
rev: v2.7.1
|
||||||
|
hooks:
|
||||||
|
- id: prettier
|
||||||
|
args: ["--print-width", "100"]
|
|
@ -7,7 +7,7 @@ Checks are done by running Icinga/Nagios compatible check plugins inside contain
|
||||||
- `/usr/lib/nagios/plugins/check_apt`: for Debian based image, provide by the `monitoring-plugins-basic` debian package
|
- `/usr/lib/nagios/plugins/check_apt`: for Debian based image, provide by the `monitoring-plugins-basic` debian package
|
||||||
- `/usr/lib/nagios/plugins/check_apk`: for Alpine based image, see [project](https://gitea.zionetrix.net/bn8/check_apk) for install instructions
|
- `/usr/lib/nagios/plugins/check_apk`: for Alpine based image, see [project](https://gitea.zionetrix.net/bn8/check_apk) for install instructions
|
||||||
|
|
||||||
__Note:__ The first plugin detected as installed will be used.
|
**Note:** The first plugin detected as installed will be used.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ fi
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
declare -A CONTAINER_STATUS_FILE
|
declare -A CONTAINER_STATUS_FILE
|
||||||
declare -A CONTAINER_PID
|
declare -A CONTAINER_PID
|
||||||
declare -A UPTODATE
|
declare -A UP_TO_DATE
|
||||||
declare -A ERRORS
|
declare -A ERRORS
|
||||||
declare -A UNKNOWNS
|
declare -A UNKNOWNS
|
||||||
CHECKED_CONTAINERS=( )
|
CHECKED_CONTAINERS=( )
|
||||||
|
@ -232,7 +232,7 @@ do
|
||||||
rm -f ${CONTAINER_STATUS_FILE[$container]}
|
rm -f ${CONTAINER_STATUS_FILE[$container]}
|
||||||
if [ $ex -eq 0 ]
|
if [ $ex -eq 0 ]
|
||||||
then
|
then
|
||||||
UPTODATE+=( ["$container"]=$STATUS )
|
UP_TO_DATE+=( ["$container"]=$STATUS )
|
||||||
else
|
else
|
||||||
ERRORS+=( ["$container"]=$STATUS )
|
ERRORS+=( ["$container"]=$STATUS )
|
||||||
[ $ex -ge 3 ] && UNKNOWNS+=( "$container" )
|
[ $ex -ge 3 ] && UNKNOWNS+=( "$container" )
|
||||||
|
@ -266,7 +266,7 @@ debug "Not found containers (${#NOTFOUNDS[@]}): $( implode ", " "${NOTFOUNDS[@]}
|
||||||
# Compute performance data
|
# Compute performance data
|
||||||
let CONTAINER_COUNTS=${#CHECKED_CONTAINERS[@]}+${#NOTFOUNDS[@]}
|
let CONTAINER_COUNTS=${#CHECKED_CONTAINERS[@]}+${#NOTFOUNDS[@]}
|
||||||
PERF_DATA=(
|
PERF_DATA=(
|
||||||
"uptodate_containers=${#UPTODATE[@]};;;0;$CONTAINER_COUNTS"
|
"uptodate_containers=${#UP_TO_DATE[@]};;;0;$CONTAINER_COUNTS"
|
||||||
"containers_with_errors=${#ERRORS[@]};1;;0;$CONTAINER_COUNTS"
|
"containers_with_errors=${#ERRORS[@]};1;;0;$CONTAINER_COUNTS"
|
||||||
"unknown_state_containers=${#UNKNOWNS[@]};;;0;$CONTAINER_COUNTS"
|
"unknown_state_containers=${#UNKNOWNS[@]};;;0;$CONTAINER_COUNTS"
|
||||||
)
|
)
|
||||||
|
@ -274,7 +274,7 @@ PERF_DATA=(
|
||||||
# Display check result message
|
# Display check result message
|
||||||
case $EXIT_CODE in
|
case $EXIT_CODE in
|
||||||
0)
|
0)
|
||||||
echo -n "OK - All ${#UPTODATE[@]} container(s) are uptodate"
|
echo -n "OK - All ${#UP_TO_DATE[@]} container(s) are up-to-date"
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
echo -n "WARNING - ${#ERRORS[@]} container(s) need to be updated"
|
echo -n "WARNING - ${#ERRORS[@]} container(s) need to be updated"
|
||||||
|
@ -296,9 +296,9 @@ do
|
||||||
echo ${container} - ${ERRORS[${container}]}
|
echo ${container} - ${ERRORS[${container}]}
|
||||||
done
|
done
|
||||||
|
|
||||||
for container in ${!UPTODATE[@]}
|
for container in ${!UP_TO_DATE[@]}
|
||||||
do
|
do
|
||||||
echo ${container} - ${UPTODATE[${container}]}
|
echo ${container} - ${UP_TO_DATE[${container}]}
|
||||||
done
|
done
|
||||||
|
|
||||||
exit $EXIT_CODE
|
exit $EXIT_CODE
|
||||||
|
|
Loading…
Reference in a new issue