Skip to content
Snippets Groups Projects
Commit b7ca6b9e authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

xheck_gitlab_tokens: GITLAB_TOKEN=SKIP responds OK without tests

parent 517dcc6e
No related branches found
No related tags found
1 merge request!282OP#7562 Gitlb-token: Skip konfigurierbar machen https://projects.iml.unibe.ch/work_packages/7562
...@@ -5,24 +5,25 @@ ...@@ -5,24 +5,25 @@
# It warns if tokens expire soon. # It warns if tokens expire soon.
# #
# requirements: # requirements:
# - inc/rest-api-client.sh # - rest-api-client - https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client
# - curl # - curl
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2024-10-29 v1.0 <axel.hahn@iml.unibe.ch> # 2024-10-29 v1.0 <axel.hahn@unibe.ch>
# 2024-10-30 v1.1 <axel.hahn@unibe.ch> GITLAB_TOKEN=SKIP responds OK without tests
# ====================================================================== # ======================================================================
cd "$( dirname "$0" )" || exit cd "$( dirname "$0" )" || exit
. "$( dirname $0 )/inc_pluginfunctions" || exit 1 . "$( dirname $0 )/inc_pluginfunctions" || exit 1
export self_APPVERSION=1.0 export self_APPVERSION=1.1
sSkipvalue="SKIP"
GITLAB_API='https://gitlab.example.com/api/v4' GITLAB_API='https://gitlab.example.com/api/v4'
GITLAB_TOKEN='glpat-12345678' GITLAB_TOKEN="$sSkipvalue"
GITLAB_CONFIG=/etc/icinga2/gitlab.cfg GITLAB_CONFIG=/etc/icinga2/gitlab.cfg
REST_CLIENT="$( dirname $0 )/../inc/rest-api-client.sh" REST_CLIENT="/opt/rest-api-client/rest-api-client.sh"
projectUrls= projectUrls=
...@@ -75,7 +76,15 @@ OPTIONS: ...@@ -75,7 +76,15 @@ OPTIONS:
-c VALUE critical level (default: $iCriticalLimit) -c VALUE critical level (default: $iCriticalLimit)
-g FILE path to GITLAB_CONFIG; default: $GITLAB_CONFIG -g FILE path to GITLAB_CONFIG; default: $GITLAB_CONFIG
-r FILE path to REST_CLIENT; default: $REST_CLIENT There you can set/ override:
GITLAB_API='${GITLAB_API}'
GITLAB_CONFIG=<TOKEN>
REST_CLIENT="${REST_CLIENT}"
-r FILE path to REST api client
default: $REST_CLIENT
The parameter overrides the variable REST_CLIENT.
-s DAYS Number of days for max age of token; default: $iSince -s DAYS Number of days for max age of token; default: $iSince
...@@ -194,8 +203,14 @@ GITLAB_CONFIG=$( ph.getValueWithParam $GITLAB_CONFIG g "$@") ...@@ -194,8 +203,14 @@ GITLAB_CONFIG=$( ph.getValueWithParam $GITLAB_CONFIG g "$@")
# --- check requirements # --- check requirements
ph.require curl ph.require curl
. "${GITLAB_CONFIG}" || ph.abort "UNKNOWN: Could not read gitlab config $GITLAB_CONFIG" . "${GITLAB_CONFIG}" || ph.abort "UNKNOWN: Could not source gitlab config $GITLAB_CONFIG"
. "${REST_CLIENT}" || ph.abort "UNKNOWN: Could not read $REST_CLIENT"
if [ "$GITLAB_TOKEN" = "$sSkipvalue" ]; then
ph.status "The check was configured to skip: GITLAB_TOKEN=$sSkipvalue"
ph.exit
fi
. "${REST_CLIENT}" || ph.abort "UNKNOWN: Could not source $REST_CLIENT"
http.help >/dev/null || ph.abort "UNKNOWN: http functions not available. Check -r $REST_CLIENT." http.help >/dev/null || ph.abort "UNKNOWN: http functions not available. Check -r $REST_CLIENT."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment