sdasd
This commit is contained in:
@@ -38,6 +38,31 @@ final class GiteaDeployStatusService
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function diagnostics(): array
|
||||
{
|
||||
$repositories = array_values(array_filter(array_map(function (mixed $entry): ?string {
|
||||
$normalized = $this->normalizeRepositoryEntry($entry);
|
||||
|
||||
return $normalized['full_name'] ?? null;
|
||||
}, (array) ($this->config['repositories'] ?? []))));
|
||||
|
||||
return [
|
||||
'configured' => $this->isConfigured(),
|
||||
'visibility' => $this->visibility(),
|
||||
'base_url_present' => $this->baseUrl() !== '',
|
||||
'base_url' => $this->baseUrl(),
|
||||
'token_present' => $this->token() !== '',
|
||||
'token_length' => strlen($this->token()),
|
||||
'owner' => trim((string) ($this->config['owner'] ?? '')),
|
||||
'repositories_configured' => $repositories,
|
||||
'poll_idle_seconds' => max(1, (int) ($this->config['poll_idle_seconds'] ?? 5)),
|
||||
'poll_running_seconds' => max(1, (int) ($this->config['poll_running_seconds'] ?? 1)),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
@@ -53,6 +78,7 @@ final class GiteaDeployStatusService
|
||||
'message' => 'Gitea-Status ist noch nicht konfiguriert.',
|
||||
'running_jobs' => [],
|
||||
'repositories_checked' => 0,
|
||||
'diagnostics' => $this->diagnostics(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -96,6 +122,7 @@ final class GiteaDeployStatusService
|
||||
'message' => $message,
|
||||
'running_jobs' => $runningJobs,
|
||||
'repositories_checked' => count($repositories),
|
||||
'diagnostics' => $this->diagnostics(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -105,6 +132,7 @@ final class GiteaDeployStatusService
|
||||
'message' => sprintf('Kein laufendes Gitea-Deployment in %d Repositories.', count($repositories)),
|
||||
'running_jobs' => [],
|
||||
'repositories_checked' => count($repositories),
|
||||
'diagnostics' => $this->diagnostics(),
|
||||
];
|
||||
} catch (\Throwable $exception) {
|
||||
return [
|
||||
@@ -113,6 +141,7 @@ final class GiteaDeployStatusService
|
||||
'message' => 'Gitea-Status konnte nicht geladen werden: ' . $exception->getMessage(),
|
||||
'running_jobs' => [],
|
||||
'repositories_checked' => 0,
|
||||
'diagnostics' => $this->diagnostics(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ $groups = array_values(array_map('strval', (array) ($authUser['groups'] ?? [])))
|
||||
$isAdmin = in_array('administrators', $groups, true);
|
||||
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
$currentEnvironment = ConfigLoader::currentEnvironment();
|
||||
$service = new GiteaDeployStatusService(ConfigLoader::load($projectRoot, 'gitea'));
|
||||
|
||||
if (!$service->shouldShowInTray($isAdmin)) {
|
||||
@@ -24,8 +25,14 @@ if (!$service->shouldShowInTray($isAdmin)) {
|
||||
], 403);
|
||||
}
|
||||
|
||||
$status = $service->status();
|
||||
$diagnostics = is_array($status['diagnostics'] ?? null) ? $status['diagnostics'] : [];
|
||||
$diagnostics['environment'] = $currentEnvironment;
|
||||
$diagnostics['host'] = (string) ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? '');
|
||||
$status['diagnostics'] = $diagnostics;
|
||||
|
||||
respond([
|
||||
'data' => $service->status(),
|
||||
'data' => $status,
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user