function findContainer(systemId, revision, targets, containerIdentifier, cb) {
    var cdefId;
    var types = [];
    async.filter(_.keys(targets), function(key, next) {
      _sr.findContainer(systemId, revision, containerIdentifier, key, function(err, containerDefId, cdef) {
        var def;
        if (!err && containerDefId) {
          cdefId = containerDefId;
          def = _.find(targets[key].containerDefinitions, function(def) {
            return def.id === cdefId;
          });

          if (types.indexOf(def.type) < 0) {
            types.push(def.type);
            return next(true);
          }
        }
        next(false);
      });
    },
    function(keys) {
      var result = keys.reduce(function(acc, key) {
        acc[key] = targets[key];
        return acc;
      }, {});
      cb(null, cdefId, result);
    });
  }
function findContainer(systemId, revision, targets, containerIdentifier, cb) {
    var cdefId;
    var types = [];
    async.filter(_.keys(targets), function(key, next) {
      _sr.findContainer(systemId, revision, containerIdentifier, key, function(err, containerDefId, cdef) {
        var def;
        if (!err && containerDefId) {
          cdefId = containerDefId;
          def = _.find(targets[key].containerDefinitions, function(def) {
            return def.id === cdefId;
          });

          if (types.indexOf(def.type) < 0) {
            types.push(def.type);
            return next(true);
          }
        }
        next(false);
      });
    },
    function(keys) {
      var result = keys.reduce(function(acc, key) {
        acc[key] = targets[key];
        return acc;
      }, {});
      cb(null, cdefId, result);
    });
  }
function findContainer ( systemId , revision , targets , containerIdentifier , cb ) { var cdefId ; var types = [ ] ; async . filter ( _ . keys ( targets ) , function ( key , next ) { _sr . findContainer ( systemId , revision , containerIdentifier , key , function ( err , containerDefId , cdef ) { var def ; if ( ! err && containerDefId ) { cdefId = containerDefId ; def = _ . find ( targets [ key ] . containerDefinitions , function ( def ) { return def . id === cdefId ; } ) ; if ( types . indexOf ( def . type ) < 0 ) { types . push ( def . type ) ; return next ( true ) ; } } next ( false ) ; } ) ; } , function ( keys ) { var result = keys . reduce ( function ( acc , key ) { acc [ key ] = targets [ key ] ; return acc ; } , { } ) ; cb ( null , cdefId , result ) ; } ) ; }
find the container in the supplied target files, return the container with the highest buildHead number
find the container in the supplied target files return the container with the highest buildHead number