mecano
Version:
Common functions for system deployment.
48 lines (43 loc) • 1.16 kB
JavaScript
// Generated by CoffeeScript 1.11.1
var docker, path, util;
module.exports = function(options, callback) {
var cmd, i, k, len, opt, ref, ref1, v;
options.log({
message: "Entering Docker login",
level: 'DEBUG',
module: 'mecano/lib/docker/login'
});
if (options.docker == null) {
options.docker = {};
}
ref = options.docker;
for (k in ref) {
v = ref[k];
if (options[k] == null) {
options[k] = v;
}
}
if (options.image == null) {
return callback(Error('Missing image parameter'));
}
if ((options.content != null) && (options.dockerfile != null)) {
return callback(Error('Can not build from Dockerfile and content'));
}
cmd = 'login';
ref1 = ['email', 'user', 'password'];
for (i = 0, len = ref1.length; i < len; i++) {
opt = ref1[i];
if (options[opt] != null) {
cmd += " -" + (opt.charAt(0)) + " " + options[opt];
}
}
if (options.registry != null) {
cmd += " \"" + options.registry + "\"";
}
return this.execute({
cmd: docker.wrap(options, cmd)
}, docker.callback);
};
docker = require('../misc/docker');
path = require('path');
util = require('util');