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

check dynamic values from env

parent 56ca81ba
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ require_once __DIR__.'/../inc_functions.php'; ...@@ -5,7 +5,7 @@ require_once __DIR__.'/../inc_functions.php';
require_once __DIR__.'/../inc_vars.php'; require_once __DIR__.'/../inc_vars.php';
$AMCLI??=__DIR__.'/../src/amcli.php'; $AMCLI??=__DIR__.'/../src/amcli.php';
$AMCLI=__DIR__.'/../built_packages/amcli'; // $AMCLI=__DIR__.'/../built_packages/amcli';
_chdir(__DIR__); _chdir(__DIR__);
......
...@@ -5,7 +5,7 @@ echo " ...@@ -5,7 +5,7 @@ echo "
WHAT: Set application metadata WHAT: Set application metadata
"; ";
$sInifile=__DIR__."/configs/metadata.ini"; $sInifile="configs/metadata.ini";
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// FUNCTION // FUNCTION
...@@ -52,11 +52,7 @@ foreach($aIni["notifications"]["email"]??[] as $sEmail){ ...@@ -52,11 +52,7 @@ foreach($aIni["notifications"]["email"]??[] as $sEmail){
_ok(); echo "\n"; _ok(); echo "\n";
} }
foreach($aIni["notifications"]["slack"]??[] as $sValue){ foreach($aIni["notifications"]["slack"]??[] as $sChannel => $sWebhook){
$aArray = json_decode($sValue, 1);
$sChannel = array_keys($aArray)[0];
$sWebhook = array_values($aArray)[0];
echo "Check Slack '$sChannel'\n"; echo "Check Slack '$sChannel'\n";
compare_strings("Check Slack '$sChannel'", $sWebhook, $aResponse["meta"]["notifications"]['slack'][$sChannel]??''); compare_strings("Check Slack '$sChannel'", $sWebhook, $aResponse["meta"]["notifications"]['slack'][$sChannel]??'');
} }
......
#!/usr/bin/env php
<?php
echo "
WHAT: Test dynamic ini value
";
$sInifile="configs/dynamic_values.ini";
echo "--- Content of ini file:\n"
.preg_replace(
"/.*(params.*\n)\n.*/s",
"$1",
file_get_contents($sInifile)
)."\n"
;
$aIni=parse_ini_file($sInifile, 1);
echo "--- parsed ini value for the check:\n";
print_r($aIni["hello plugin"]['params']);
$sMessage=$aIni["hello plugin"]['params']['message']??false;
if($sMessage)
{
if(strstr($sMessage, "\$\{")){
_abort('in params -> message the variable $\{USER\} was not replaced');
} else {
_ok('in params -> message the variable $\{USER\} was replaced');
}
} else {
_abort("Message param was not found.");
}
; =======================================================================
;
; APPMONITOR CLI CLIENT
;
; to understand the entries of metadata see JSON in
; <https://os-docs.iml.unibe.ch/appmonitor/Client/Description_of_response.html>
;
; for the checks see its parameters
; <https://os-docs.iml.unibe.ch/appmonitor/PHP_client/Plugins/Checks/index.html>
;
; =======================================================================
; -----------------------------------------------------------------------
; CHECKS
; -----------------------------------------------------------------------
["hello plugin"]
description='I test a dynamic value USER = ${USER}'
function="hello"
; to have dynamic values in params do not use JSON but array syntax
params[message]="Here is ${USER}"
; -----------------------------------------------------------------------
...@@ -28,7 +28,7 @@ email[]="webmaster@example.com" ...@@ -28,7 +28,7 @@ email[]="webmaster@example.com"
; for slack use the following format ; for slack use the following format
; <channelname> + comma + <webhook url> ; <channelname> + comma + <webhook url>
slack[]='{ "#support-channel": "https://hooks.slack.com/services/XXXXXX/YYYYYY/ZZZZZ" }' slack["#support-channel2"]="https://hooks.slack.com/services/XXXXXX/YYYYYY/ZZZZZ"
; ----------------------------------------------------------------------- ; -----------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment