mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-27 09:45:58 -04:00
feat(logs): accept all for log lines and keep -1
API log endpoints and the GetLogs UI now treat `all` as unbounded output, with `-1` remaining as a compatibility alias. MCP still falls back to a positive default. Traefik version checks run from CheckForUpdatesJob instead of a weekly schedule.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Concerns\ResolvesResource;
|
||||
use App\Models\Server;
|
||||
|
||||
it('normalizes requested log line counts', function () {
|
||||
@@ -12,12 +13,44 @@ it('normalizes requested log line counts', function () {
|
||||
expect(normalizeLogLines(null))->toBe(100)
|
||||
->and(normalizeLogLines(''))->toBe(100)
|
||||
->and(normalizeLogLines('abc'))->toBe(100)
|
||||
->and(normalizeLogLines('0'))->toBe(100)
|
||||
->and(normalizeLogLines('all'))->toBe('all')
|
||||
->and(normalizeLogLines('ALL'))->toBe(100)
|
||||
->and(normalizeLogLines('-1'))->toBe('all')
|
||||
->and(normalizeLogLines('0'))->toBe(0)
|
||||
->and(normalizeLogLines('-5'))->toBe(100)
|
||||
->and(normalizeLogLines('50'))->toBe(50)
|
||||
->and(normalizeLogLines('50000'))->toBe(10000);
|
||||
});
|
||||
|
||||
it('keeps MCP log requests bounded', function () {
|
||||
$normalizer = new class
|
||||
{
|
||||
use ResolvesResource;
|
||||
|
||||
public function normalize(mixed $lines): int
|
||||
{
|
||||
return $this->normalizeMcpLogLines($lines);
|
||||
}
|
||||
};
|
||||
|
||||
expect($normalizer->normalize('all'))->toBe(100)
|
||||
->and($normalizer->normalize('-1'))->toBe(100)
|
||||
->and($normalizer->normalize('0'))->toBe(100)
|
||||
->and($normalizer->normalize('501'))->toBe(500);
|
||||
});
|
||||
|
||||
it('documents the named all logs option on every REST log endpoint', function (string $controller) {
|
||||
$source = file_get_contents(__DIR__."/../../../app/Http/Controllers/Api/{$controller}.php");
|
||||
|
||||
expect($source)->toContain('Use `all` to return all logs. `-1` remains available as a compatibility alias.');
|
||||
})->with([
|
||||
'applications' => 'ApplicationsController',
|
||||
'databases' => 'DatabasesController',
|
||||
'services' => 'ServicesController',
|
||||
'service applications' => 'ServiceApplicationsController',
|
||||
'service databases' => 'ServiceDatabasesController',
|
||||
]);
|
||||
|
||||
it('normalizes service resource log line counts before invoking Docker', function (string $controller, mixed $lines, int $expectedLines) {
|
||||
$source = file_get_contents(__DIR__."/../../../app/Http/Controllers/Api/{$controller}.php");
|
||||
|
||||
@@ -63,6 +96,16 @@ it('builds docker log commands with options before an escaped container id', fun
|
||||
->toBe("docker logs -n 25 --timestamps 'container-1' 2>&1");
|
||||
});
|
||||
|
||||
it('builds docker log commands for all and zero lines', function () {
|
||||
$server = new Server;
|
||||
$server->settings = ['is_swarm_manager' => false];
|
||||
|
||||
expect(buildContainerLogsCommand($server, 'container-1', 'all'))
|
||||
->toBe("docker logs -n all 'container-1' 2>&1")
|
||||
->and(buildContainerLogsCommand($server, 'container-1', 0))
|
||||
->toBe("docker logs -n 0 'container-1' 2>&1");
|
||||
});
|
||||
|
||||
it('builds swarm service log commands with options before an escaped service id', function () {
|
||||
if (! function_exists('buildContainerLogsCommand')) {
|
||||
expect(function_exists('buildContainerLogsCommand'))->toBeTrue();
|
||||
|
||||
Reference in New Issue
Block a user