Add a containerId request parameter for journal-logs api endpoint, and pass it along to journalctl process options.

Change-Type: minor
Signed-off-by: Ivan <ivanign04.alt@gmail.com>
This commit is contained in:
Ivan 2020-02-22 16:27:28 -07:00
parent 0df6b225ff
commit b5772740ae
2 changed files with 14 additions and 1 deletions

View File

@ -471,8 +471,16 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
const count = checkInt(req.body.count, { positive: true }) || undefined;
const unit = req.body.unit;
const format = req.body.format || 'short';
const containerId = req.body.containerId;
const journald = spawnJournalctl({ all, follow, count, unit, format });
const journald = spawnJournalctl({
all,
follow,
count,
unit,
format,
containerId,
});
res.status(200);
journald.stdout.pipe(res);
res.on('close', () => {

View File

@ -8,6 +8,7 @@ export function spawnJournalctl(opts: {
follow: boolean;
count?: number;
unit?: string;
containerId?: string;
format: string;
}): ChildProcess {
const args = [
@ -25,6 +26,10 @@ export function spawnJournalctl(opts: {
args.push('-u');
args.push(opts.unit);
}
if (opts.containerId != null) {
args.push('-t');
args.push(opts.containerId);
}
if (opts.count != null) {
args.push('-n');
args.push(opts.count.toString());