UNPKG

gce-elastic-docker

Version:

A package to help setup Elasticsearch / Kibana clusters on Google Compute Engine.

71 lines (70 loc) 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var child_process_1 = require("child_process"); var gce_1 = require("../gce"); var Utils = /** @class */ (function () { function Utils() { } Utils.exec = function (cmd, verbose, wd) { return new Promise(function (resolve, reject) { var proc = child_process_1.exec(cmd, { maxBuffer: 1024 * 100000, cwd: wd }, function (err, stdout) { if (err) { reject(err); } else { resolve(stdout); } }); if (verbose) { proc.stdout.pipe(process.stdout); proc.stderr.pipe(process.stderr); } }); }; Utils.get_zones_in_region = function (region) { if (!region || !gce_1.short_regions[region]) { throw Error(region + " is not a valid gce region!"); } return gce_1.zones.filter(function (zone) { return zone.slice(0, -2) === region; }); }; Utils.is_array = function (v) { return Array.isArray(v); }; Utils.is_bool = function (v) { return typeof v === 'boolean'; }; Utils.is_defined = function (v) { return typeof v !== 'undefined'; }; Utils.is_function = function (v) { return typeof v === 'function'; }; Utils.is_integer = function (v) { return (typeof v === 'number') && (v % 1 === 0); }; Utils.is_null = function (v) { return v === null; }; Utils.is_number = function (v) { return typeof (v) === 'number' && isFinite(v); }; Utils.is_object = function (v) { return v !== null && v instanceof Object; }; Utils.is_string = function (v) { return typeof v === 'string'; }; Utils.is_undefined = function (v) { return typeof v === 'undefined'; }; Utils.is_valid_image_name = function (v) { if (!Utils.is_string(v) || !v || / /.test(v)) { return false; } else { return !!gce_1.registries.filter(function (r) { return v.startsWith(r) + '/'; }).length; } }; return Utils; }()); exports.Utils = Utils;