TODO: read also configuration to be able to tell which plugins /
plugin tasks are available for each service
12059
function (serviceDir, selectedConfiguration) {
    if (!serviceDir.startsWith('/')) {
      throw new Error(`serviceDir (${serviceDir}) must be absolute path.`);
    }

    // Create services folder if it doesn't exist.
    if (!fs.existsSync(serviceDir)) {
      fs.mkdirSync(serviceDir);
    }

    // Names of all the services (must have directory serviceName/config)
    var serviceNames = _.filter(fs.readdirSync(serviceDir), function(fileName) {
      var serviceConfigPath = path.join(serviceDir, fileName, 'config');
      try {
        return fs.lstatSync(serviceConfigPath).isDirectory();
      } catch (err) {
        return false;
      }
    });

    return _.map(serviceNames, function (serviceName) {
      var servicePath = path.join(serviceDir, serviceName);
      var configurationPath = path.join(servicePath, 'config', selectedConfiguration);
      var configuration = null;

      if (!configurationPath.startsWith('/')) {
        configurationPath = './' + configurationPath;
      }

      try {
        configuration = require(configurationPath);
        configuration = configuration.default || configuration;

        // pass directories etc. to configuration
        if (_.isFunction(configuration)) {
          configuration = configuration({
            servicePath: servicePath
          });
        }
      } catch (err) {
        // rethrow if the error was not about missing module
        if ( err.code !== 'MODULE_NOT_FOUND' ) {
            throw err;
        }
        // ignore missing module errors silently, maybe given profile was not defined for
        // the service, which is totally cool... no prob bro!
      }

      var tasks = [];
      if (configuration) {
        // TODO: move these tasks to separate file and test that they do what they should
        tasks.push({
          name: 'serve',
          run: function () {
            var app = require('../app/express/main');
            return app.start(configuration);
          },
          description: 'Start the express app of the service.'
        });

        // add tasks declared by features to build
        var features = plugins.loadFeatures(configuration);
        _.each(features, function(featureDescription) {
          _.each(featureDescription.tasks, function (task) {
            // wrap task runner function to closure which passes required parameters  to call, which takes only global configuration as parameter and pass feature config implicitly
            tasks.push({
              name: task.name,
              description: task.description,
              run: function () {
                return task.run(featureDescription.featureDef.config, configuration, servicePath);
              }
            });
          });
        });
      }

      return {
        name: serviceName,
        configPath: configurationPath,
        config: configuration,
        tasks: tasks
      };
    });
  }
601142
def get_available_plugins(self):
        
        available_plugins = []
        PluginData = namedtuple('PluginData', 'name, plugin_class, conf, is_allowed_to_fail')
        for plugin_request in self.plugins_conf:
            plugin_name = plugin_request['name']
            try:
                plugin_class = self.plugin_classes[plugin_name]
            except KeyError:
                if plugin_request.get('required', True):
                    msg = ("no such plugin: '%s', did you set "
                           "the correct plugin type?") % plugin_name
                    exc = PluginFailedException(msg)
                    self.on_plugin_failed(plugin_name, exc)
                    logger.error(msg)
                    raise exc
                else:
                    # This plugin is marked as not being required
                    logger.warning("plugin '%s' requested but not available",
                                   plugin_name)
                    continue
            plugin_is_allowed_to_fail = plugin_request.get('is_allowed_to_fail',
                                                           getattr(plugin_class,
                                                                   "is_allowed_to_fail", True))
            plugin_conf = plugin_request.get("args", {})
            plugin = PluginData(plugin_name,
                                plugin_class,
                                plugin_conf,
                                plugin_is_allowed_to_fail)
            available_plugins.append(plugin)
        return available_plugins
508454
function initServices (config) {
    // get services directory
    var dirs = getDir(config, 'services')
    // load services definitions from each directory
    _.each(dirs, dir => initServicesDir(config, dir))
    // create new service instances from definitions
    _.each(config.services, (service, name) => {
        config.services[name] = new ImmutableCoreService(service)
    })
    // initialize all services
    return ImmutableCoreService.initializeAll()
}
1339823
function possiblyFetch(id, plugins_dir, options) {
    var parsedSpec = pluginSpec.parse(id);
    //Check if a mapping exists for the plugin id
    //if it does, convert id to new name id
    var newId = parsedSpec.scope ? null : pluginMapper.oldToNew[parsedSpec.id];
    if(newId) {
        if(parsedSpec.version) {
            id = newId + '@' + parsedSpec.version;
        } else {
            id = newId;
        }
    }

    // if plugin is a relative path, check if it already exists
    var plugin_src_dir = isAbsolutePath(id) ? id : path.join(plugins_dir, parsedSpec.id);

    // Check that the plugin has already been fetched.
    if (fs.existsSync(plugin_src_dir)) {
        return Q(plugin_src_dir);
    }

    var alias =  parsedSpec.scope ? null : pluginMapper.newToOld[parsedSpec.id] || newId;
    // if the plugin alias has already been fetched, use it.
    if (alias && fs.existsSync(path.join(plugins_dir, alias))) {
        events.emit('warn', 'Plugin with alternate id ' + alias + ' is already fetched, so installing it instead of ' + parsedSpec.id);
        return Q(path.join(plugins_dir, alias));
    }

    // if plugin doesnt exist, use fetch to get it.
    if (newId) {
        events.emit('warn', 'Notice: ' + parsedSpec.id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
    }
    var opts = underscore.extend({}, options, {
        client: 'plugman'
    });

    return plugman.raw.fetch(id, plugins_dir, opts);
}
463244
private List<ServiceInformation> getServiceInformations(URI location, final Map<String, String> params)
            throws IOException {
        final ReadOnlyDiscoveryClient discoveryClient = getDiscoveryClient(params);

        final String serviceType = params.get("serviceType");

        final List<ServiceInformation> services;

        if (serviceType != null) {
            services = discoveryClient.findAllServiceInformation(location.getHost(), serviceType);
        } else {
            services = discoveryClient.findAllServiceInformation(location.getHost());
        }
        return services;
    }
1031147
def pluginNames(cls, enabled=True):
        
        return map(lambda x: x.name(), cls.plugins(enabled))
807206
static Plugin getPluginMetadata(final Class<?> cls) throws PluginException {
        // try to get plugin provider name
        final String pluginname;
        if (!cls.isAnnotationPresent(Plugin.class)) {
            throw new PluginException("No Plugin annotation was found for the class: " + cls.getName());
        }

        final Plugin annotation = (Plugin) cls.getAnnotation(Plugin.class);
        pluginname = annotation.name();
        if (null == pluginname || "".equals(pluginname)) {
            throw new PluginException("Plugin annotation 'name' cannot be empty for the class: " + cls.getName());
        }
        // get service name from annotation
        final String servicename = annotation.service();
        if (null == servicename || "".equals(servicename)) {
            throw new PluginException("Plugin annotation 'service' cannot be empty for the class: " + cls.getName());
        }
        return annotation;
    }
1029091
function (ui, done) {
        Object.keys(ui.defaultPlugins).forEach(function (key) {
            ui.pluginManager.get(key)(ui, ui.bs);
        });
        done();
    }
291554
function parseServiceJson(serviceNameFilter, serviceJson) {
  var services = [],
    config = require('./config')();

  Object.keys(serviceJson).forEach(function(serviceName) {
    if (serviceName === 'env' || serviceName === 'args') return;

    var serviceConfig = serviceJson[serviceName],
      processCount = serviceConfig.processes || 1;

    // if services have a process count > 1,
    // we'll create multiple run-scripts for them.
    _.range(processCount).forEach(function(i) {

      // apply sane defaults as we create
      // the services.
      var service = new Service(_.extend(
        {
          module: serviceName,
          name: i > 0 ? (serviceName + '-' + i) : serviceName
        },
        serviceConfig
      ));

      // override env and args with global args and env.
      service.env = _.extend({},
        dropInterviewQuestions(serviceJson.env),
        dropInterviewQuestions(serviceConfig.env)
      );

      service.args = serviceConfig.args;

      if (_.isArray(serviceConfig.args)) {
        // combine arrays of arguments, if both top-level args.
        // and service-level args are an array.
        if (_.isArray(serviceJson.args)) service.args = [].concat(serviceJson.args, service.args);
      } else {
        // merge objects together if top-level, and service level
        // arguments are maps.
        service.args = _.extend({},
          dropInterviewQuestions(serviceJson.args),
          dropInterviewQuestions(serviceConfig.args)
        );
      }

      // we can optionaly filter to a specific service name.
      if (serviceNameFilter && service.name !== serviceNameFilter && !config.globalPackage) return;

      // replace placeholder variables
      // in the service.json.
      expandVariables(service, i);

      services.push(service);
    });
  });

  return services;
}
613979
function invokeConfigFn(tasks) {
		for (var taskName in tasks) {
			if (tasks.hasOwnProperty(taskName)) {
				tasks[taskName](gulp, plugins, growl, path);
			}
		}
	}
1040114
def get_configuration(self):
        
        mapping = {}
        settings = self.get_settings()
        for service in self.context.getService():
            uid = api.get_uid(service)
            setting = settings.get(uid, {})
            config = {
                "hidden": setting.get("hidden", False),
            }
            mapping[uid] = config
        return mapping
158752
def list_tasks(collector):
    """"""
    print("Usage: aws_syncr <environment> <task>")
    print("")
    print("Available environments to choose from are")
    print("-----------------------------------------")
    print("")
    for environment in os.listdir(collector.configuration_folder):
        location = os.path.join(collector.configuration_folder, environment)
        if os.path.isdir(location) and not environment.startswith("."):
            print("\t{0}".format(environment))

    print("")
    print("Available tasks to choose from are:")
    print("-----------------------------------")
    print("")
    keygetter = lambda item: item[1].label
    tasks = sorted(available_actions.items(), key=keygetter)
    sorted_tasks = sorted(list(tasks), key=lambda item: len(item[0]))
    max_length = max(len(name) for name, _ in sorted_tasks)
    for key, task in sorted_tasks:
        desc = dedent(task.__doc__ or "").strip().split('\n')[0]
        print("\t{0}{1} :-: {2}".format(" " * (max_length-len(key)), key, desc))
    print("")
368233
function doPluginTask(owner, taskCallback) {
        var plugins = grunt.config.get('app_plugins_work_plugins');
        var plugin;
        if (!!plugins && 0 < plugins.length) {
            plugin = plugins.shift();
            // update variable.
            grunt.config.set('app_plugins_work_plugins', plugins);
            taskCallback(plugin);
            grunt.task.run(owner.nameArgs);
        }
    }
1290687
public static List<ExtPluginConfiguration> listPluginConfigurations(
            final Map<String, String> props,
            final String keyprefix,
            final String serviceName,
            final boolean extra
    )
    {
        final ArrayList<ExtPluginConfiguration> list = new ArrayList<>();
        int i = 1;
        boolean done = false;
        while (!done) {
            final String prefix = keyprefix + "." + i;
            if (props.containsKey(prefix + ".type")) {
                final String providerType = props.get(prefix + ".type");
                final Map<String, Object> configProps = new HashMap<>();
                final Map<String, Object> extraData = extra ? new HashMap<>() : null;
                final int len = (prefix + ".config.").length();
                for (final Object o : props.keySet()) {
                    final String key = (String) o;
                    if (key.startsWith(prefix + ".config.")) {
                        configProps.put(key.substring(len), props.get(key));
                    }
                }
                if (extra) {
                    //list all extra props
                    for (String s : props.keySet()) {
                        if (s.startsWith(prefix + ".")) {
                            String suffix = s.substring(prefix.length() + 1);
                            if (!"type".equalsIgnoreCase(suffix) && !suffix.startsWith("config.")) {
                                extraData.put(suffix, props.get(s));
                            }
                        }
                    }
                }
                list.add(new SimplePluginConfiguration(serviceName, providerType, configProps, extraData));
            } else {
                done = true;
            }
            i++;
        }
        return list;
    }
132208
function defaultService (config) {
  const serviceConfig = _.merge({}, baseServiceConfig);

  // Apply MetaData
  serviceConfig.metadata = objectMetadata({
    name: config.projectName,
    namespace: config.namespace.name
  });

  serviceConfig.spec.selector = {
    project: config.projectName,
    provider: 'nodeshift'
  };

  serviceConfig.spec.ports = [
    {
      protocol: 'TCP',
      port: config.port,
      targetPort: config.port,
      name: 'http'
    }
  ];

  serviceConfig.spec.type = 'ClusterIP';

  return serviceConfig;
}
579836
function readFromLocalConfig(parent){
    return readFile(config_file(parent), "utf8")
        .then(function(contents){
            return JSON.parse(contents);
        })
        .catch(function(){
            return {
                data: {},
                installed: [],
            };
        });
}
1258221
function (callback) {
    var plugins = this.internals.plugins;
    var self = this;

    return Promise.resolve(Object.keys(APIHooks))
      .each(function (hook) {
        var plugin = plugins.hook(hook);
        if (!plugin) return;

        var APIHook = APIHooks[hook].bind(self);

        return Promise.resolve(plugin)
          .map(function (plugin) {
            return plugin[hook]();
          })
          .each(function (args) {
            return APIHook.apply(self, args);
          });
      })
      .asCallback(callback);
  }