firmament-docker
Version:
Typescript classes for performing Docker operations
140 lines • 5.94 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
var ProvisionCommandImpl_1;
const inversify_1 = require("inversify");
const inversify_config_1 = require("../../inversify.config");
const path = require("path");
let ProvisionCommandImpl = ProvisionCommandImpl_1 = class ProvisionCommandImpl {
constructor(dockerProvision) {
this.dockerProvision = dockerProvision;
this.aliases = [];
this.command = '';
this.commandDesc = '';
this.handler = () => {
};
this.options = {};
this.subCommands = [];
this.buildCommandTree();
}
buildCommandTree() {
this.aliases = ['provision', 'p'];
this.command = '<subCommand>';
this.commandDesc = 'Support for provisioning docker swarms & stacks';
this.pushBuildCommand();
this.pushTemplateCommand();
this.pushExtractYamlCommand();
}
;
pushTemplateCommand() {
let templateCommand = inversify_config_1.default.get('CommandImpl');
templateCommand.aliases = ['template', 't'];
templateCommand.commandDesc = 'Create a template JSON spec for creating docker stack/swarm';
templateCommand.options = {
dockermachine: {
alias: 'dm',
type: 'string',
default: 'virtualbox',
desc: `docker-machine host type ['virtualbox','openstack','vmwarevsphere','amazonec2']`,
},
get: {
alias: 'g',
type: 'string',
desc: '.. get [templateName]. If no templateName is specified then lists available templates'
},
yaml: {
alias: 'y',
type: 'string',
desc: 'Name of the input docker-compose YAML file to embed in template'
},
output: {
alias: 'o',
default: ProvisionCommandImpl_1.defaultConfigFilename,
type: 'string',
desc: 'Name of the output JSON file'
}
};
templateCommand.handler = this.dockerProvision.makeTemplate.bind(this.dockerProvision);
this.subCommands.push(templateCommand);
}
;
pushBuildCommand() {
let buildCommand = inversify_config_1.default.get('CommandImpl');
buildCommand.aliases = ['build', 'b'];
buildCommand.commandDesc = 'Build Docker Stack based on JSON spec';
buildCommand.options = {
username: {
alias: 'u',
type: 'string',
desc: 'username for Docker Machine host'
},
password: {
alias: 'p',
type: 'string',
desc: 'password for Docker Machine host'
},
input: {
alias: 'i',
default: ProvisionCommandImpl_1.defaultConfigFilename,
type: 'string',
desc: 'Name the config JSON file'
},
noPorts: {
alias: 'np',
default: false,
type: 'boolean',
desc: 'Suppress port publish blocks in compose files (to support Traefik autoconfig)'
},
noNfs: {
alias: 'nn',
default: false,
type: 'boolean',
desc: 'Suppress NFS server exports check and create'
}
};
buildCommand.handler = this.dockerProvision.buildTemplate.bind(this.dockerProvision);
this.subCommands.push(buildCommand);
}
;
pushExtractYamlCommand() {
let extractYamlCommand = inversify_config_1.default.get('CommandImpl');
extractYamlCommand.aliases = ['extract-yaml', 'x'];
extractYamlCommand.commandDesc = 'Extract Docker Compose (for Swarm) YAML from firmament provision JSON file';
extractYamlCommand.options = {
inputJsonFile: {
alias: 'i',
type: 'string',
default: ProvisionCommandImpl_1.defaultConfigFilename,
desc: 'The input firmament provision JSON file'
},
outputYamlFile: {
alias: 'o',
type: 'string',
desc: 'The output Docker Compose YAML file'
}
};
extractYamlCommand.handler = this.dockerProvision.extractYamlFromJson.bind(this.dockerProvision);
this.subCommands.push(extractYamlCommand);
}
;
};
ProvisionCommandImpl.defaultConfigFilename = 'docker-provision.json';
ProvisionCommandImpl.defaultComposeYamlFilename = path.resolve(__dirname, '../../../docker/merlin.yml');
ProvisionCommandImpl = ProvisionCommandImpl_1 = __decorate([
inversify_1.injectable(),
__param(0, inversify_1.inject('DockerProvision')),
__metadata("design:paramtypes", [Object])
], ProvisionCommandImpl);
exports.ProvisionCommandImpl = ProvisionCommandImpl;
//# sourceMappingURL=provision-command-impl.js.map