From 4259682b27ace497b19bae159bbc8e9dc66bd2cb Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 30 Jan 2023 00:19:03 +0100 Subject: [PATCH] buildx: printInspect Signed-off-by: CrazyMax --- __tests__/builder.test.ts | 3 ++- __tests__/buildx.test.ts | 16 ++++++++++++++++ src/buildx.ts | 7 +++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/__tests__/builder.test.ts b/__tests__/builder.test.ts index 8c03ad2..3d0ae28 100644 --- a/__tests__/builder.test.ts +++ b/__tests__/builder.test.ts @@ -1,6 +1,7 @@ -import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals'; +import {beforeEach, describe, expect, it, jest, test} from '@jest/globals'; import * as fs from 'fs'; import * as path from 'path'; + import {Builder, BuilderInfo} from '../src/builder'; import {Context} from '../src/context'; diff --git a/__tests__/buildx.test.ts b/__tests__/buildx.test.ts index c13befd..e1f8ed1 100644 --- a/__tests__/buildx.test.ts +++ b/__tests__/buildx.test.ts @@ -151,6 +151,22 @@ describe('isAvailable', () => { }); }); +describe('printInspect', () => { + it('prints builder2 instance', () => { + const execSpy = jest.spyOn(exec, 'exec'); + const buildx = new Buildx({ + context: new Context(), + standalone: true + }); + buildx.printInspect('builder2').catch(() => { + // noop + }); + expect(execSpy).toHaveBeenCalledWith(`buildx`, ['inspect', 'builder2'], { + failOnStdErr: false + }); + }); +}); + describe('printVersion', () => { it('docker cli', () => { const execSpy = jest.spyOn(exec, 'exec'); diff --git a/src/buildx.ts b/src/buildx.ts index 98e9605..7223745 100644 --- a/src/buildx.ts +++ b/src/buildx.ts @@ -49,6 +49,13 @@ export class Buildx { }); } + public async printInspect(name: string): Promise { + const cmd = this.getCommand(['inspect', name]); + await exec.exec(cmd.command, cmd.args, { + failOnStdErr: false + }); + } + private async getVersion(): Promise { const cmd = this.getCommand(['version']); return await exec