From 6fe7d54029b11706cb4c1abecf1f68001061abe6 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 25 Feb 2023 16:40:35 +0100 Subject: [PATCH] docker: fix context command Signed-off-by: CrazyMax --- __tests__/docker.test.ts | 2 +- src/docker.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/__tests__/docker.test.ts b/__tests__/docker.test.ts index ea266326..1907632b 100644 --- a/__tests__/docker.test.ts +++ b/__tests__/docker.test.ts @@ -63,7 +63,7 @@ describe('context', () => { await Docker.context().catch(() => { // noop }); - expect(execSpy).toHaveBeenCalledWith(`docker`, ['context', 'show'], { + expect(execSpy).toHaveBeenCalledWith(`docker`, ['context', 'inspect', '--format', '{{.Name}}'], { ignoreReturnCode: true, silent: true }); diff --git a/src/docker.ts b/src/docker.ts index e21c5cde..2ec3b339 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -38,8 +38,12 @@ export class Docker { }); } - public static async context(): Promise { - return await Exec.getExecOutput(`docker`, ['context', 'show'], { + public static async context(name?: string): Promise { + const args = ['context', 'inspect', '--format', '{{.Name}}']; + if (name) { + args.push(name); + } + return await Exec.getExecOutput(`docker`, args, { ignoreReturnCode: true, silent: true }).then(res => {