50 lines
4.1 KiB
JavaScript
50 lines
4.1 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const plugins = require("./mod.plugins");
|
|
const npmci_bash_1 = require("../npmci.bash");
|
|
class DockerRegistry {
|
|
constructor(optionsArg) {
|
|
this.registryUrl = optionsArg.registryUrl;
|
|
this.username = optionsArg.username;
|
|
this.password = optionsArg.password;
|
|
plugins.beautylog.info(`created DockerRegistry for ${this.registryUrl}`);
|
|
}
|
|
static fromEnvString(envString) {
|
|
let dockerRegexResultArray = envString.split('|');
|
|
if (dockerRegexResultArray.length !== 3) {
|
|
plugins.beautylog.error('malformed docker env var...');
|
|
process.exit(1);
|
|
return;
|
|
}
|
|
let registryUrl = dockerRegexResultArray[0];
|
|
let username = dockerRegexResultArray[1];
|
|
let password = dockerRegexResultArray[2];
|
|
return new DockerRegistry({
|
|
registryUrl: registryUrl,
|
|
username: username,
|
|
password: password
|
|
});
|
|
}
|
|
login() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (this.registryUrl === 'docker.io') {
|
|
yield npmci_bash_1.bash(`docker login -u ${this.username} -p ${this.password}`);
|
|
plugins.beautylog.info('Logged in to standard docker hub');
|
|
}
|
|
else {
|
|
yield npmci_bash_1.bash(`docker login -u ${this.username} -p ${this.password} ${this.registryUrl}`);
|
|
}
|
|
plugins.beautylog.ok(`docker authenticated for ${this.registryUrl}!`);
|
|
});
|
|
}
|
|
}
|
|
exports.DockerRegistry = DockerRegistry;
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