mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 11:36:10 +08:00
docker: split version and info
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
3c101c4aee
commit
4f2a155c08
@ -16,19 +16,36 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('info', () => {
|
describe('printVersion', () => {
|
||||||
it('standard', () => {
|
it('standard', () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
Docker.info(false);
|
Docker.printVersion(false);
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
|
||||||
failOnStdErr: false
|
failOnStdErr: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('standalone', () => {
|
it('standalone', () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
Docker.info(true);
|
Docker.printVersion(true);
|
||||||
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], {
|
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], {
|
||||||
failOnStdErr: false
|
failOnStdErr: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('printInfo', () => {
|
||||||
|
it('standard', () => {
|
||||||
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
|
Docker.printInfo(false);
|
||||||
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('standalone', () => {
|
||||||
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
|
Docker.printInfo(true);
|
||||||
|
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['info'], {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import * as core from '@actions/core';
|
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
export class Docker {
|
export class Docker {
|
||||||
@ -23,17 +22,23 @@ export class Docker {
|
|||||||
return dockerAvailable;
|
return dockerAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async info(standalone?: boolean) {
|
public static async printVersion(standalone?: boolean) {
|
||||||
const dockerAvailable = standalone ?? !Docker.isAvailable();
|
const noDocker = standalone ?? !Docker.isAvailable();
|
||||||
if (dockerAvailable) {
|
if (noDocker) {
|
||||||
core.info(`Docker info skipped in standalone mode`);
|
return;
|
||||||
} else {
|
}
|
||||||
await exec.exec('docker', ['version'], {
|
await exec.exec('docker', ['version'], {
|
||||||
failOnStdErr: false
|
failOnStdErr: false
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async printInfo(standalone?: boolean) {
|
||||||
|
const noDocker = standalone ?? !Docker.isAvailable();
|
||||||
|
if (noDocker) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await exec.exec('docker', ['info'], {
|
await exec.exec('docker', ['info'], {
|
||||||
failOnStdErr: false
|
failOnStdErr: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user