1
0
Fork 0
mirror of https://github.com/docker/login-action.git synced 2025-04-27 17:16:35 +02:00

Mostly tests and some small changes (#16)

* Create docker.test.ts
* Add context tests
* test main
This commit is contained in:
Bryan Clark 2020-10-09 03:30:45 -07:00 committed by GitHub
parent 34d5f75b0d
commit 4b15841c41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 148 additions and 8 deletions

View file

@ -7,7 +7,7 @@ export interface Inputs {
logout: string;
}
export async function getInputs(): Promise<Inputs> {
export function getInputs(): Inputs {
return {
registry: core.getInput('registry'),
username: core.getInput('username'),

View file

@ -4,17 +4,16 @@ import {getInputs, Inputs} from './context';
import * as docker from './docker';
import * as stateHelper from './state-helper';
async function run(): Promise<void> {
export async function run(): Promise<void> {
try {
if (os.platform() !== 'linux') {
core.setFailed('Only supported on linux platform');
return;
throw new Error('Only supported on linux platform');
}
let inputs: Inputs = await getInputs();
stateHelper.setRegistry(inputs.registry);
stateHelper.setLogout(inputs.logout);
await docker.login(inputs.registry, inputs.username, inputs.password);
const {registry, username, password, logout} = getInputs();
stateHelper.setRegistry(registry);
stateHelper.setLogout(logout);
await docker.login(registry, username, password);
} catch (error) {
core.setFailed(error.message);
}