From b223e0a42bba0ada37e84e4cdaf45f152e62a3b5 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 10 Feb 2023 11:34:16 +0100 Subject: [PATCH] buildx: certsDir Signed-off-by: CrazyMax --- __tests__/buildx/buildx.test.ts | 18 ++++++++++++++++++ src/buildx/buildx.ts | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/__tests__/buildx/buildx.test.ts b/__tests__/buildx/buildx.test.ts index 835b44b..d7c6445 100644 --- a/__tests__/buildx/buildx.test.ts +++ b/__tests__/buildx/buildx.test.ts @@ -68,6 +68,24 @@ describe('configDir', () => { }); }); +describe('certsDir', () => { + const originalEnv = process.env; + beforeEach(() => { + jest.resetModules(); + process.env = { + ...originalEnv, + BUILDX_CONFIG: '/var/docker/buildx' + }; + }); + afterEach(() => { + process.env = originalEnv; + }); + it('returns default', async () => { + process.env.BUILDX_CONFIG = '/var/docker/buildx'; + expect(Buildx.certsDir).toEqual(path.join('/var/docker/buildx', 'certs')); + }); +}); + describe('isAvailable', () => { it('docker cli', async () => { const execSpy = jest.spyOn(exec, 'getExecOutput'); diff --git a/src/buildx/buildx.ts b/src/buildx/buildx.ts index 30b47c0..7dac1d7 100644 --- a/src/buildx/buildx.ts +++ b/src/buildx/buildx.ts @@ -47,6 +47,10 @@ export class Buildx { return process.env.BUILDX_CONFIG || path.join(Docker.configDir, 'buildx'); } + static get certsDir(): string { + return path.join(Buildx.configDir, 'certs'); + } + public getCommand(args: Array) { return { command: this.standalone ? 'buildx' : 'docker',