mirror of
https://github.com/docker/login-action.git
synced 2024-11-25 09:51:05 -05:00
Username required
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
4b15841c41
commit
1c2cf9942d
4 changed files with 30 additions and 40 deletions
|
@ -29,22 +29,22 @@ test('errors without password', async () => {
|
|||
});
|
||||
|
||||
test('successful with only password', async () => {
|
||||
const platSpy = jest.spyOn(osm, 'platform');
|
||||
platSpy.mockImplementation(() => 'linux');
|
||||
const platSpy = jest.spyOn(osm, 'platform');
|
||||
platSpy.mockImplementation(() => 'linux');
|
||||
|
||||
const setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
|
||||
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
|
||||
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
|
||||
dockerSpy.mockImplementation(() => {});
|
||||
const setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
|
||||
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
|
||||
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
|
||||
dockerSpy.mockImplementation(() => {});
|
||||
|
||||
const password: string = 'groundcontrol';
|
||||
process.env[`INPUT_PASSWORD`] = password;
|
||||
const password: string = 'groundcontrol';
|
||||
process.env[`INPUT_PASSWORD`] = password;
|
||||
|
||||
await run();
|
||||
await run();
|
||||
|
||||
expect(setRegistrySpy).toHaveBeenCalledWith('');
|
||||
expect(setLogoutSpy).toHaveBeenCalledWith('');
|
||||
expect(dockerSpy).toHaveBeenCalledWith('', '', password);
|
||||
expect(setRegistrySpy).toHaveBeenCalledWith('');
|
||||
expect(setLogoutSpy).toHaveBeenCalledWith('');
|
||||
expect(dockerSpy).toHaveBeenCalledWith('', '', password);
|
||||
});
|
||||
|
||||
test('calls docker login', async () => {
|
||||
|
@ -66,7 +66,7 @@ test('calls docker login', async () => {
|
|||
process.env[`INPUT_REGISTRY`] = registry;
|
||||
|
||||
const logout: string = 'true';
|
||||
process.env['INPUT_LOGOUT'] = logout
|
||||
process.env['INPUT_LOGOUT'] = logout;
|
||||
|
||||
await run();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ inputs:
|
|||
required: false
|
||||
username:
|
||||
description: 'Username used to log against the Docker registry'
|
||||
required: false
|
||||
required: true
|
||||
password:
|
||||
description: 'Password or personal access token used to log against the Docker registry'
|
||||
required: true
|
||||
|
|
36
dist/index.js
generated
vendored
36
dist/index.js
generated
vendored
|
@ -496,6 +496,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.run = void 0;
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const core = __importStar(__webpack_require__(186));
|
||||
const context_1 = __webpack_require__(842);
|
||||
|
@ -505,19 +506,19 @@ function run() {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
if (os.platform() !== 'linux') {
|
||||
core.setFailed('Only supported on linux platform');
|
||||
return;
|
||||
throw new Error('Only supported on linux platform');
|
||||
}
|
||||
let inputs = yield context_1.getInputs();
|
||||
stateHelper.setRegistry(inputs.registry);
|
||||
stateHelper.setLogout(inputs.logout);
|
||||
yield docker.login(inputs.registry, inputs.username, inputs.password);
|
||||
const { registry, username, password, logout } = context_1.getInputs();
|
||||
stateHelper.setRegistry(registry);
|
||||
stateHelper.setLogout(logout);
|
||||
yield docker.login(registry, username, password);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.run = run;
|
||||
function logout() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!stateHelper.logout) {
|
||||
|
@ -3640,27 +3641,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getInputs = void 0;
|
||||
const core = __importStar(__webpack_require__(186));
|
||||
function getInputs() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return {
|
||||
registry: core.getInput('registry'),
|
||||
username: core.getInput('username'),
|
||||
password: core.getInput('password', { required: true }),
|
||||
logout: core.getInput('logout')
|
||||
};
|
||||
});
|
||||
return {
|
||||
registry: core.getInput('registry'),
|
||||
username: core.getInput('username', { required: true }),
|
||||
password: core.getInput('password', { required: true }),
|
||||
logout: core.getInput('logout')
|
||||
};
|
||||
}
|
||||
exports.getInputs = getInputs;
|
||||
//# sourceMappingURL=context.js.map
|
||||
|
|
|
@ -10,7 +10,7 @@ export interface Inputs {
|
|||
export function getInputs(): Inputs {
|
||||
return {
|
||||
registry: core.getInput('registry'),
|
||||
username: core.getInput('username'),
|
||||
username: core.getInput('username', {required: true}),
|
||||
password: core.getInput('password', {required: true}),
|
||||
logout: core.getInput('logout')
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue