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
Branches
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 @@
# It warns if tokens expire soon.
#
# requirements:
# - inc/rest-api-client.sh
# - rest-api-client - https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client
# - 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
. "$( 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_TOKEN='glpat-12345678'
GITLAB_TOKEN="$sSkipvalue"
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=
......@@ -75,7 +76,15 @@ OPTIONS:
-c VALUE critical level (default: $iCriticalLimit)
-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
......@@ -194,8 +203,14 @@ GITLAB_CONFIG=$( ph.getValueWithParam $GITLAB_CONFIG g "$@")
# --- check requirements
ph.require curl
. "${GITLAB_CONFIG}" || ph.abort "UNKNOWN: Could not read gitlab config $GITLAB_CONFIG"
. "${REST_CLIENT}" || ph.abort "UNKNOWN: Could not read $REST_CLIENT"
. "${GITLAB_CONFIG}" || ph.abort "UNKNOWN: Could not source gitlab config $GITLAB_CONFIG"
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."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment