_(services) // Remove unneeded things from the docker config and determine the type of the service .map((config, name) => _.merge({}, { name, type: _.get(config.labels, 'lando.type'), compose: _.omit(config, ['volumes', 'volumes_from', 'networks', 'user']), config: recipeConfig, })) // Return .value()
/* * 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])); }
/* * Post our key */ postKey(key) { const postKey = ['users', _.get(this.session, 'user_id'), 'keys']; const options = (this.mode === 'node') ? {headers: {'User-Agent': 'Terminus/Lando'}} : {}; const data = _.trim(fs.readFileSync(key, 'utf8')); return pantheonRequest(this.request, this.log, 'post', postKey, JSON.stringify(data), options); }
// Add in the hostname infos app.events.on('post-init', 1, () => { app.log.debug('adding hostnames to the app...'); _.forEach(app.info, data => { data.hostnames = _.get(data, 'hostnames', []); data.hostnames.push([data.service, app.project, 'internal'].join('.')); app.log.debug('hostnames added to %s', data.service, data.hostnames); }); });
_(app.services) // Objectify .map(service => _.merge({name: service}, _.get(app, `config.services.${service}`, {}))) // Set the default .map(config => _.merge({}, config, {app_mount: _.get(config, 'app_mount', 'cached')})) // Filter out disabled mountes .filter(config => config.app_mount !== false && config.app_mount !== 'disabled') // Combine together .map(config => ([config.name, {volumes: [`${app.root}:/app:${config.app_mount}`]}])) .fromPairs() .value()
// If we have an app with a tooling section let's do this app.events.on('post-init', () => { if (!_.isEmpty(_.get(app, 'config.tooling', {}))) { app.log.verbose('additional tooling detected'); // Add the tasks after we init the app _.forEach(utils.getToolingTasks(app.config.tooling, app), task => { app.log.debug('adding app cli task %s', task.name); const injectable = _.has(app, 'engine') ? app : lando; app.tasks.push(buildTask(task, injectable)); }); } });
// Add in local variable overrides as needed _.forEach(app.platformsh.config.applications, application => { if (_.has(app, `config.config.variables.${application.name}`)) { const overrides = _.get(app, `config.config.variables.${application.name}`, {}); application.variables = _.merge({}, application.variables, overrides); } });
/* * Helper to collect relevant error data */ const getErrorData = (err = {}) => ({ code: _.get(err, 'response.status', 200), codeText: _.get(err, 'response.statusText'), method: _.upperCase(_.get(err, 'response.config.method'), 'GET'), path: _.get(err, 'response.config.url'), response: _.get(err, 'response.data'), })