_(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()
/* * Paths to / */ const pathsToRoot = (startFrom = process.cwd()) => { return _(_.range(path.dirname(startFrom).split(path.sep).length)) .map(end => _.dropRight(path.dirname(startFrom).split(path.sep), end).join(path.sep)) .unshift(startFrom) .dropRight() .value(); }
/* * Determine whether we are in a browser or not * * While setting the config.mode is helpful this is a deeper check so that we * know how to handle the process object in things shell attaching, stream piping * stdin reading, etc * * @TODO: We might want to either expand the version checks or maybe do a lower * level check of the process file descriptors */ const isBrowser = () => _(process.versions) .reduce((isBrowser, version, thing) => (isBrowser || _.includes(browsers, thing)), false)
_(files) .flatMap(file => traverseUp(path.resolve(startFrom, file))) .sortBy().reverse() .filter(file => fs.existsSync(file) && path.isAbsolute(file)) .thru(files => _.isEmpty(files) ? [] : [_.first(files)]) .flatMap(dirFile => _.map(files, file => path.join(path.dirname(dirFile), file))) .filter(file => fs.existsSync(file)) .value()
_(parsedServices) .map(service => getServiceToolingByType(service, app)) .flatten() .filter(service => service.name) .map(service => ([service.name, _.omit(service, 'name')])) .fromPairs() .value()
_(data) .map((value, index) => new Table(value, opts)) .map(table => table.toString()) .thru(data => data.join(os.EOL)) .value()
_(files) // Filter if file exists .filter(fs.existsSync) // Start collecting .reduce((a, file) => exports.merge(a, yaml.safeLoad(fs.readFileSync(file))), {})
// Helper to get excludes const getExcludes = (data = [], inverse = false) => _(data) .filter(exclude => _.startsWith(exclude, '!') === inverse) .map(exclude => _.trimStart(exclude, '!')) .uniq() .compact() .value()
/* * Helper to find containers that serve */ const getServingContainers = services => _(services) .filter(service => service.type === 'lagoon-nginx') .map('name') .value()
_(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()
/* * Helper to get memcached related tooling commands */ const getMemcachedTooling = (services, app = 'app') => _(services) .map(service => ({ name: service.relationship, description: `Connects to the ${service.relationship} relationship`, cmd: `netcat ${service.service} ${service.port}`, service: app, level: 'app', })) .value()
_(services) .map(service => getServiceToolingByType(service)) .filter(tools => !_.isEmpty(tools)) .map(tools => _.map(tools, (config, name) => ([name, config]))) .flatten() .fromPairs() .value()
/* * Helper to get dynamic service keys for stripping */ const getDynamicKeys = (answer, answers = {}) => _(answers) .map((value, key) => ({key, value})) .filter(data => data.value === answer) .map(data => data.key) .map(key => (_.size(key) === 1) ? `-${key}` : `--${key}`) .value()
_(config) .map((urls, service) => ({ environment: { LANDO_PROXY_NAMES: exports.parse2Sans(urls), }, name: service, labels: exports.parseRoutes(service, urls, sslReady)})) .value()
/* * Helper to get service names by type */ const getServicesByType = (services, type) => _(services) .filter(service => service.type === type) .map('name') .value()