Skip to content

Commit a37dac9

Browse files
committed
Added paused health state
1 parent 9ff383b commit a37dac9

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lup-docker",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "NodeJS library to interact with the Docker engine.",
55
"main": "./lib/index",
66
"types": "./lib/index.d.ts",

src/convert.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,15 @@ export function decodeDockerContainer(json: any | undefined): DockerContainer |
375375
if (!json) return undefined;
376376

377377
let healthState: DockerContainerHealthState | undefined = undefined;
378-
if (json.Status.includes('healthy')) {
378+
const statusStr = (json.Status || '').toLowerCase();
379+
if (statusStr.includes('healthy')) {
379380
healthState = 'healthy';
380-
} else if (json.Status.includes('unhealthy')) {
381+
} else if (statusStr.includes('unhealthy')) {
381382
healthState = 'unhealthy';
382-
} else if (json.Status.includes('starting')) {
383+
} else if (statusStr.includes('starting')) {
383384
healthState = 'starting';
385+
} else if (statusStr.includes('paused')) {
386+
healthState = 'paused';
384387
}
385388

386389
return {
@@ -396,6 +399,7 @@ export function decodeDockerContainer(json: any | undefined): DockerContainer |
396399
imageName: json.Image,
397400
imageMetadata: decodeDockerOCIDescriptor(json.ImageManifestDescriptor)!,
398401
isHealthy: json.State === 'running' && healthState !== 'unhealthy',
402+
isPaused: healthState === 'paused',
399403
isRunning: json.State === 'running',
400404
labels: json.Labels || {},
401405
mounts: ((json.Mounts as any[]) || []).map<DockerContainerMountInfo>(

src/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ export type DockerContainer = {
171171
/** Whether the container is healthy or not (false if container is running and explicitly unhealthy). */
172172
isHealthy: boolean;
173173

174+
/** Whether the container is paused. */
175+
isPaused: boolean;
176+
174177
/** Whether the container is currently running. */
175178
isRunning: boolean;
176179
};
@@ -228,7 +231,7 @@ export type DockerContainerCpuStats = {
228231
};
229232
};
230233

231-
export type DockerContainerHealthState = 'starting' | 'healthy' | 'unhealthy';
234+
export type DockerContainerHealthState = 'starting' | 'healthy' | 'paused' | 'unhealthy';
232235

233236
export type DockerContainerInheritedVolume = {
234237
/** Name of the container the volumes are inherited from. */

0 commit comments

Comments
 (0)