docker: info method

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-23 10:39:14 +01:00
parent aae4a2d7bc
commit 595e2417e8
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
2 changed files with 31 additions and 0 deletions

View File

@ -15,3 +15,20 @@ describe('isAvailable', () => {
}); });
}); });
}); });
describe('info', () => {
it('standard', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.info();
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
failOnStdErr: false
});
});
it('standalone', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.info(true);
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], {
failOnStdErr: false
});
});
});

View File

@ -1,3 +1,4 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
export class Docker { export class Docker {
@ -18,4 +19,17 @@ export class Docker {
return false; return false;
}); });
} }
public static async info(standalone?: boolean) {
if (standalone) {
core.info(`Docker info skipped in standalone mode`);
} else {
await exec.exec('docker', ['version'], {
failOnStdErr: false
});
await exec.exec('docker', ['info'], {
failOnStdErr: false
});
}
}
} }