End of log stream message

pull/273/head
Frostebite 2021-06-06 19:54:07 +01:00
parent 896e754512
commit 4d622063ea
3 changed files with 17 additions and 28 deletions

22
dist/index.js vendored
View File

@ -1042,22 +1042,16 @@ class Kubernetes {
}); });
} }
static streamLogs(name, namespace, container) { static streamLogs(name, namespace, container) {
var _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
let running = true; core.info('Polling logs...');
while (running) { const stream = new stream_1.Writable();
const pod = yield this.kubeClient.readNamespacedPod(name, namespace); stream._write = (chunk, encoding, next) => {
running = ((_a = pod.body.status) === null || _a === void 0 ? void 0 : _a.phase) === 'Running'; core.info(chunk.toString());
yield new Promise((resolve) => setTimeout(resolve, pollInterval)); next();
core.info('Polling logs...'); };
const stream = new stream_1.Writable(); yield new Promise((resolve) => new client_node_1.Log(this.kubeConfig).log(namespace, name, container, stream, resolve));
stream._write = (chunk, encoding, next) => { core.info('end of log stream');
core.info(chunk.toString());
next();
};
yield new Promise((resolve) => new client_node_1.Log(this.kubeConfig).log(namespace, name, container, stream, resolve));
}
} }
catch (error) { catch (error) {
core.error(JSON.stringify(error, undefined, 4)); core.error(JSON.stringify(error, undefined, 4));

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -334,19 +334,14 @@ class Kubernetes {
static async streamLogs(name: string, namespace: string, container: string) { static async streamLogs(name: string, namespace: string, container: string) {
try { try {
let running = true; core.info('Polling logs...');
while (running) { const stream = new Writable();
const pod = await this.kubeClient.readNamespacedPod(name, namespace); stream._write = (chunk, encoding, next) => {
running = pod.body.status?.phase === 'Running'; core.info(chunk.toString());
await new Promise((resolve) => setTimeout(resolve, pollInterval)); next();
core.info('Polling logs...'); };
const stream = new Writable(); await new Promise((resolve) => new Log(this.kubeConfig).log(namespace, name, container, stream, resolve));
stream._write = (chunk, encoding, next) => { core.info('end of log stream');
core.info(chunk.toString());
next();
};
await new Promise((resolve) => new Log(this.kubeConfig).log(namespace, name, container, stream, resolve));
}
} catch (error) { } catch (error) {
core.error(JSON.stringify(error, undefined, 4)); core.error(JSON.stringify(error, undefined, 4));
throw error; throw error;