mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 16:35:23 +00:00
fix: Fix non-tty container message parsing
This had a bug where it was using the `in` operator on a list. It may have worked for some cases, but would have failed for others. Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
e148ce0529
commit
760b18dd2a
@ -72,10 +72,13 @@ export class ContainerLogs extends (EventEmitter as {
|
||||
|
||||
private static extractMessage(
|
||||
msgBuf: Buffer,
|
||||
): { message: string; timestamp: number } | null {
|
||||
): { message: string; timestamp: number } | undefined {
|
||||
// Non-tty message format from:
|
||||
// https://docs.docker.com/engine/api/v1.30/#operation/ContainerAttach
|
||||
if (msgBuf[0] in [0, 1, 2] && _.every(msgBuf.slice(1, 7), c => c === 0)) {
|
||||
if (
|
||||
_.includes([0, 1, 2], msgBuf[0]) &&
|
||||
_.every(msgBuf.slice(1, 7), c => c === 0)
|
||||
) {
|
||||
// Take the header from this message, and parse it as normal
|
||||
msgBuf = msgBuf.slice(8);
|
||||
}
|
||||
@ -91,7 +94,7 @@ export class ContainerLogs extends (EventEmitter as {
|
||||
message: logLine.substr(space + 1),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user