From 1c70b92460aed972f25050f0c18e7735b979eb8a Mon Sep 17 00:00:00 2001 From: Stuart Date: Fri, 10 Jul 2020 16:03:45 +0100 Subject: [PATCH] [dockerode] Add types for exec instances (#45954) --- types/dockerode/index.d.ts | 56 +++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts index b7955e1e08..0b060f0b6a 100644 --- a/types/dockerode/index.d.ts +++ b/types/dockerode/index.d.ts @@ -59,8 +59,8 @@ declare namespace Dockerode { unpause(callback: Callback): void; unpause(options?: {}): Promise; - exec(options: {}, callback: Callback): void; - exec(options: {}): Promise; + exec(options: ExecCreateOptions, callback: Callback): void; + exec(options: ExecCreateOptions): Promise; commit(options: {}, callback: Callback): void; commit(callback: Callback): void; @@ -300,11 +300,11 @@ declare namespace Dockerode { modem: any; id: string; - inspect(callback: Callback): void; - inspect(): Promise; + inspect(callback: Callback): void; + inspect(): Promise; - start(options: {}, callback: Callback): void; - start(options: {}): Promise; + start(options: ExecStartOptions, callback: Callback): void; + start(options: ExecStartOptions): Promise; resize(options: {}, callback: Callback): void; resize(options: {}): Promise; @@ -492,7 +492,7 @@ declare namespace Dockerode { MountLabel: string; ProcessLabel: string; AppArmorProfile: string; - ExecIDs?: any; + ExecIDs?: string[]; HostConfig: HostConfig; GraphDriver: { Name: string; @@ -877,6 +877,48 @@ declare namespace Dockerode { [key: string]: EndpointSettings; } + interface ExecCreateOptions { + AttachStdin?: boolean; + AttachStdout?: boolean; + AttachStderr?: boolean; + DetachKeys?: string; + Tty?: boolean; + Env?: string[]; + Cmd?: string[]; + Privileged?: boolean; + User?: string; + WorkingDir?: string; + } + + interface ExecInspectInfo { + CanRemove: boolean; + DetachKeys: string; + ID: string; + Running: boolean; + ExitCode: number | null; + ProcessConfig: { + privileged: boolean; + user: string; + tty: boolean; + entrypoint: string; + arguments: string[]; + }; + OpenStdin: boolean; + OpenStderr: boolean; + OpenStdout: boolean; + ContainerID: string; + Pid: number; + } + + interface ExecStartOptions { + // hijack and stdin are used by docker-modem + hijack?: boolean; + stdin?: boolean; + // Detach and Tty are used by Docker's API + Detach?: boolean; + Tty?: boolean; + } + type MountType = 'bind' | 'volume' | 'tmpfs'; type MountConsistency = 'default' | 'consistent' | 'cached' | 'delegated';