docker.list() .each(container => { ids.push(container.id); ids.push(container.name); }) .then(() => _.includes(ids, utils.getId(data)))
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; })
// Strip it down _.each(process.env, (value, key) => { if (_.includes(key, prefix)) { delete process.env[key]; } });
_(process.env) // Only muck with prefix_ variables .pickBy((value, key) => _.includes(key, prefix)) // Prep the keys for consumption .mapKeys((value, key) => _.camelCase(_.trimStart(key, prefix))) // If we have a JSON string as a value, parse that and assign its sub-keys .mapValues(exports.tryConvertJson) // Resolve the lodash wrapper .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)
// Categorize and colorize URLS if and as appropriate _.forEach(app.info, info => { if (_.has(info, 'urls') && !_.isEmpty(info.urls)) { urls[info.service] = _.filter(app.urls, item => { item.theme = chalk[item.color](item.url); return _.includes(info.urls, item.url); }); } });
// Helper to filter services const filterServices = (service, services = []) => { return !_.isEmpty(services) ? _.includes(services, service) : true; }
// Return mock error code based on commands const errorCode = cmd => { return !_.includes(cmd, 'bomb') ? 0 : _.random(1, 666); }
// Set a different default if needed lando.events.on('cli-ssh-run', 2, data => { if (data.options.service === 'appserver') { // Discovery const services = _.keys(data.options._app.services); const hasRecipe = _.has(data, 'options._app.recipe'); // If this is not a recipe and we have no appserver container then set a new default if (!hasRecipe && !_.includes(services, 'appserver')) { data.options.service = _.first(services); data.options.s = data.options.service; } } });
_.map(overrides.volumes, volume => { if (!_.includes(volume, ':')) { return volume; } else { const local = exports.getHostPath(volume); const remote = _.last(volume.split(':')); // @TODO: I don't think below does anything? const excludes = _.keys(volumes).concat(_.keys(volumes)); const host = exports.normalizePath(local, base, excludes); return [host, remote].join(':'); } })
_(_.merge(_.get(data, 'Config.ExposedPorts', []), {'443/tcp': {}})) .map((value, port) => ({ port: _.head(port.split('/')), protocol: (_.includes(secured, port.split('/')[0])) ? 'https' : 'http'} )) .filter(exposed => _.includes(scan, exposed.port)) .flatMap(ports => _.map(_.get(data, `NetworkSettings.Ports.${ports.port}/tcp`, []), i => _.merge({}, ports, i))) .filter(ports => _.includes([bindAddress, '0.0.0.0'], ports.HostIp)) .map(ports => url.format({ protocol: ports.protocol, hostname: 'localhost', port: _.includes(scan, ports.port) ? ports.HostPort : '', })) .thru(urls => ({service: data.Config.Labels['com.docker.compose.service'], urls})) .value()
// Fake Spawner const fakeSpawn = (cmd, args, opts) => { const command = cmd + ' ' + args.join(' '); return { connected: !_.includes(command, 'van the man'), stdout: {on: (type, fn) => { fn(Buffer.from('SPAWN: ' + command, 'utf8')); }, }, on: (type, fn) => { if (type === 'error') fn(Buffer.from('ERROR', 'utf8')); else if (type === 'close') fn(errorCode(command)); }, }; }
_(cmds) // Set service if needed .map(cmd => _.isString(cmd) ? _.set({}, fallback, cmd) : cmd) // Extract the service data .map(cmd => _.map(cmd, (cmd, service) => ([service, cmd]))) // Flatten the thing .flatten() // Prefix if needed .map(data => { if (_.includes(needsPrefix, data[0])) data[1] = `/helpers/psh-exec.sh ${data[1]}`; return _.set({}, data[0], data[1]); }) // Return .value()
_(opts.pullable).filter(service => { return _.isEmpty(opts.services) || _.includes(opts.services, service); }).value()
_(services) .filter(service => _.includes(SQLServices, service.type)) .value()