buildx: configDir
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -46,6 +46,28 @@ afterEach(() => {
|
|||||||
rimraf.sync(tmpDir);
|
rimraf.sync(tmpDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('configDir', () => {
|
||||||
|
const originalEnv = process.env;
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {
|
||||||
|
...originalEnv,
|
||||||
|
BUILDX_CONFIG: '/var/docker/buildx',
|
||||||
|
DOCKER_CONFIG: '/var/docker/config'
|
||||||
|
};
|
||||||
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
process.env = originalEnv;
|
||||||
|
});
|
||||||
|
it('returns default', async () => {
|
||||||
|
process.env.BUILDX_CONFIG = '';
|
||||||
|
expect(Buildx.configDir).toEqual(path.join('/var/docker/config', 'buildx'));
|
||||||
|
});
|
||||||
|
it('returns from env', async () => {
|
||||||
|
expect(Buildx.configDir).toEqual('/var/docker/buildx');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
it('docker cli', async () => {
|
it('docker cli', async () => {
|
||||||
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
|
||||||
@@ -42,6 +43,10 @@ export class Buildx {
|
|||||||
this.standalone = opts?.standalone ?? !Docker.isAvailable;
|
this.standalone = opts?.standalone ?? !Docker.isAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get configDir(): string {
|
||||||
|
return process.env.BUILDX_CONFIG || path.join(Docker.configDir, 'buildx');
|
||||||
|
}
|
||||||
|
|
||||||
public getCommand(args: Array<string>) {
|
public getCommand(args: Array<string>) {
|
||||||
return {
|
return {
|
||||||
command: this.standalone ? 'buildx' : 'docker',
|
command: this.standalone ? 'buildx' : 'docker',
|
||||||
|
|||||||
Reference in New Issue
Block a user