Skip to content

Commit

Permalink
Change fetching version to a function
Browse files Browse the repository at this point in the history
Add version and branch to telemetry
  • Loading branch information
austinwbest committed Sep 29, 2024
1 parent 62d9492 commit faf06fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions root/app/www/public/functions/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function apiRequestLocal($endpoint, $parameters = [], $payload = [])
apiResponse(423, ['error' => 'Migration in progress']);
}

return defined('DOCKWATCH_COMMITS') && defined('DOCKWATCH_BRANCH') ? 'v' . APP_X . '.' . APP_Y . '.' . DOCKWATCH_COMMITS . ' - ' . DOCKWATCH_BRANCH : 'v0.0.0';
return 'v' . gitVersion();
case 'stats-getContainersList':
return apiResponse(200, getContainerStats());
case 'stats-getOverview':
Expand Down Expand Up @@ -467,7 +467,7 @@ function apiRequestServerPings()
$servers = [];
foreach ($serversTable as $server) {
if ($server['id'] == APP_SERVER_ID) {
$servers[strtolower($server['name'])] = ['id' => $server['id'], 'name' => $server['name'] . ' [' . (defined('DOCKWATCH_COMMITS') && defined('DOCKWATCH_BRANCH') ? 'v' . APP_X . '.' . APP_Y . '.' . DOCKWATCH_COMMITS . ' - ' . DOCKWATCH_BRANCH : 'v0.0.0') . ']', 'code' => 200];
$servers[strtolower($server['name'])] = ['id' => $server['id'], 'name' => $server['name'] . ' [v' . gitVersion() . ']', 'code' => 200];
} else {
apiSetActiveServer($server['id'], $serversTable);

Expand Down
23 changes: 16 additions & 7 deletions root/app/www/public/functions/git.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,35 @@
function gitBranch()
{
if (!defined('DOCKWATCH_BRANCH')) {
return 'Unknown';
} else {
return DOCKWATCH_BRANCH;
return 'Source';
}

return DOCKWATCH_BRANCH;
}

function gitHash()
{
if (!defined('DOCKWATCH_COMMIT')) {
return 'Unknown';
} else {
return DOCKWATCH_COMMIT;
}

return DOCKWATCH_COMMIT;
}

function gitMessage()
{
if (!defined('DOCKWATCH_COMMIT_MSG')) {
return 'Unknown';
} else {
return DOCKWATCH_COMMIT_MSG;
}

return DOCKWATCH_COMMIT_MSG;
}

function gitVersion()
{
if (!defined('DOCKWATCH_COMMITS') && !defined('DOCKWATCH_BRANCH')) {
return '0.0.0';
}

return APP_X . '.' . APP_Y . '.' . DOCKWATCH_COMMITS . ' - ' . DOCKWATCH_BRANCH;
}
4 changes: 3 additions & 1 deletion root/app/www/public/functions/telemetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ function telemetry($send = false)
$notificationTable = $database->getNotificationLinks();

//-- ONE WAY HASH() OF AN MD5() HASHED HOSTNAME + APIKEY TO KEEP THINGS UNIQUE
$telemetry['token'] = hash('sha256', md5($_SERVER['HOSTNAME'] . $serversTable[1]['apikey']));
$telemetry['token'] = hash('sha256', md5($_SERVER['HOSTNAME'] . $serversTable[1]['apikey']));
$telemetry['branch'] = gitBranch();
$telemetry['version'] = gitVersion();

//-- CONTAINER INFO
$auto = $check = $ignore = 0;
Expand Down

0 comments on commit faf06fa

Please sign in to comment.