Select Git revision
100_set_metadata.php
-
Hahn Axel (hahn) authoredHahn Axel (hahn) authored
100_set_metadata.php 1.89 KiB
#!/usr/bin/env php
<?php
echo "
WHAT: Set application metadata
";
$sInifile="configs/metadata.ini";
// --------------------------------------------------------------------
// FUNCTION
// --------------------------------------------------------------------
function compare_strings($sKey, $sIniValue, $aResponseValue=null){
echo "Values for '$sKey':\n INI : $sIniValue\n Response: $aResponseValue\n ";
if ($sIniValue!=$aResponseValue){
_abort("Values differ");
}
_ok(); echo "\n";
}
// --------------------------------------------------------------------
// MAIN
// --------------------------------------------------------------------
// basic check ... the ini file is processed?
_exec("$AMCLI --ini='$sInifile'");
// --------------------------------------------------------------------
// yes. Now let's compare ini values and the response
exec("$AMCLI --ini='$sInifile'", $aOut, $rc);
$aIni=parse_ini_file($sInifile, 1);
$aResponse=json_decode($aOut[0], 1);
// print_r($aIni);
// print_r($aResponse);
// --------------------------------------------------------------------
echo "\n";
compare_strings("host", $aIni["meta"]["host"], $aResponse["meta"]["host"]);
compare_strings("website", $aIni["meta"]["website"], $aResponse["meta"]["website"]);
compare_strings("ttl", $aIni["meta"]["ttl"], $aResponse["meta"]["ttl"]);
foreach($aIni["notifications"]["email"]??[] as $sEmail){
echo "Check Email '$sEmail'\n";
if(array_search($sEmail, $aResponse["meta"]["notifications"]["email"])===false){
_abort("Email not found in response");
}
_ok(); echo "\n";
}
foreach($aIni["notifications"]["slack"]??[] as $sChannel => $sWebhook){
echo "Check Slack '$sChannel'\n";
compare_strings("Check Slack '$sChannel'", $sWebhook, $aResponse["meta"]["notifications"]['slack'][$sChannel]??'');
}
// --------------------------------------------------------------------