docker: add options to getStats

This commit is contained in:
Girish Ramakrishnan
2025-07-03 22:36:36 +02:00
parent 526f5efb78
commit 9f35801f64
3 changed files with 7 additions and 6 deletions

View File

@@ -660,12 +660,13 @@ async function getEvents(options) {
return stream;
}
async function getStats(containerId) {
async function getStats(containerId, options) {
assert.strictEqual(typeof containerId, 'string');
assert.strictEqual(typeof options, 'object');
const container = gConnection.getContainer(containerId);
const [error, result] = await safe(container.stats({ stream: false }));
const [error, result] = await safe(container.stats({ stream: !!options.stream }));
if (error && error.statusCode === 404) throw new BoxError(BoxError.NOT_FOUND, `Container ${containerId} not found`);
if (error) throw new BoxError(BoxError.DOCKER_ERROR, error);