/* * Parse docker-compose options */ const parseOptions = (opts = {}) => { const flags = _.map(composeFlags, (value, key) => _.get(opts, key, false) ? value : ''); const environment = _.flatMap(opts.environment, (value, key) => ['--env', `${key}=${value}`]); const user = (_.has(opts, 'user')) ? ['--user', opts.user] : []; const workdir = (_.has(opts, 'workdir')) ? ['--workdir', opts.workdir] : []; const entrypoint = _.map(opts.entrypoint, entrypoint => ['--entrypoint', entrypoint]); return _.compact(_.flatten([flags, environment, user, workdir, entrypoint])); }
_(_.flatten([...sources])) .sortBy('date') .groupBy('email') .map(tokens => _.last(tokens)) .value()
/* * Helper to standardize construction of docker commands */ const buildCmd = (run, name, compose, {services, cmd}, opts = {}) => { if (!name) throw new Error('Need to give this composition a project name!'); // @TODO: we need to strip out opts.user on start/stop because we often get it as part of run const project = ['--project-name', name]; const files = _.flatten(_.map(compose, unit => ['--file', unit])); const options = parseOptions(opts); const argz = _.flatten(_.compact([services, cmd])); return _.flatten([project, files, run, options, argz]); }
api.auth().then(() => api.getSiteEnvs(site) .map(env => ({name: env.id, value: env.id})) .filter(env => !_.includes(nopes, env.value)) .then(envs => _.flatten([envs, [{name: 'none', value: 'none'}]]))) .catch(err => { throw (_.has(err, 'response.data')) ? new Error(err.response.data) : err; })
// Helper to parse tokens into choices const parseTokens = tokens => _.flatten([getTokens(tokens), [{name: 'add or refresh a token', value: 'more'}]])
// Add in some computed config eg things after our config has been settled lando.events.on('post-bootstrap-config', ({config}) => { lando.log.verbose('building proxy config...'); // Set some non dependent things config.proxyContainer = `${lando.config.proxyName}_proxy_1`; config.proxyCurrentPorts = {http: config.proxyHttpPort, https: config.proxyHttpsPort}; config.proxyDir = path.join(lando.config.userConfRoot, 'proxy'); config.proxyHttpPorts = _.flatten([config.proxyHttpPort, config.proxyHttpFallbacks]); config.proxyHttpsPorts = _.flatten([config.proxyHttpsPort, config.proxyHttpsFallbacks]); config.proxyLastPorts = lando.cache.get(lando.config.proxyCache); config.proxyNet = `${config.proxyName}_edge`; config.proxyScanHttp = utils.ports2Urls(config.proxyHttpPorts, false, config.proxyBindAddress); config.proxyScanHttps = utils.ports2Urls(config.proxyHttpsPorts, true, config.proxyBindAddress); // And dependent things config.proxyConfigDir = path.join(config.proxyDir, 'config'); });
/* * Helper to get all ports */ const getAllPorts = (noHttp = false, noHttps = false, config) => { const {proxyHttpPort, proxyHttpsPort, proxyHttpFallbacks, proxyHttpsFallbacks} = config; const ports = []; if (noHttp) { ports.push(proxyHttpPort); ports.push(proxyHttpFallbacks); } if (noHttps) { ports.push(proxyHttpsPort); ports.push(proxyHttpsFallbacks); } return _.flatten(ports).join(', '); }
// Helper to get popuylation command const getPopCommand = (excludes = []) => _.compact(_.flatten([['/helpers/mounter.sh'], excludes]))
_(_.flatten([data])) .flatMap(group => _.map(group.data, (compose, index) => ({data: compose, file: `${group.id}-${index}.yml`}))) .map(compose => yaml.dump(path.join(dir, compose.file), compose.data)) .value()
_(deps) .map((version, pkg) => _.flatten([prefix, pkger(pkg, version)])) .map(command => command.join(' ')) .value()
// Helper to get pantheon auth non-interactive options const getInteractiveOptions = (tokens = []) => ({ 'auth': { interactive: { choices: _.flatten([getTokens(tokens), [{name: 'add or refresh a token', value: 'more'}]]), when: answers => !_.isEmpty(tokens), weight: 100, }, }, 'machine-token': { hidden: true, interactive: { name: 'auth', type: 'password', message: 'Enter a Pantheon machine token', when: answers => _.isEmpty(tokens) || (_.get(answers, 'auth', '') === 'more'), weight: 101, }, }, })
_(services) .groupBy('platformsh.type') .map((service, type) => _.merge({}, {type}, { services: _.flatten(_.map(service, s => parsedRelationships[s.name])), })) .value()
_(_.flatten([...sources])) .sortBy('date') .groupBy('email') .map(tokens => _.last(tokens)) .value()
// Helper to sort tokens const sortTokens = (...sources) => _(_.flatten([...sources])) .sortBy('date') .groupBy('user') .map(tokens => _.last(tokens)) .value()
// Helper to get pantheon auth non-interactive options const getInteractiveOptions = (tokens = []) => ({ 'auth': { interactive: { choices: _.flatten([getTokens(tokens), [{name: 'add or refresh a token', value: 'more'}]]), when: answers => !_.isEmpty(tokens), weight: 100, }, }, 'api-token': { hidden: true, interactive: { name: 'auth', type: 'password', message: 'Enter a Platform.sh API token', when: answers => _.isEmpty(tokens) || (_.get(answers, 'auth', '') === 'more'), weight: 101, }, }, })