lib/api.js
function(user, systemName, revision, target, out, cb) {
    var systemId = _sr.findSystem(systemName);

    if (!systemId) {
      logger.error(ERR_NOSYSID); return cb(new Error(ERR_NOSYSID));
    }

    logger.info({ systemId: systemId, revision: revision }, 'building all containers');
    fetchTarget(systemId, target, revision, function(err, target) {
      if (err) { return cb(err); }
      _builder.loadMatchingTargets(systemId, revision, target, function(err, targets) {
        if (err) { return cb(err); }

        out.stdout('--> building all containers for ' + targets[Object.keys(targets)[0]].name + ' revision ' + revision + ' target ' + target);

        var containers = _.chain(targets)
          .filter(function(value, key) {
            return target === 'alltargets' || key === target;
          })
          .map(function(target) {
            return _.map(target.containerDefinitions, function(cdef) {
              return {
                id: cdef.id,
                target: target.topology.name,
                type: cdef.type
              };
            });
          })
          .flatten()
          .reduce(function(acc, cont) {
            var notPresent = !_.find(acc, function(found) {
              return found.id === cont.id && found.type === cont.type;
            });

            if (notPresent) {
              acc.push(cont);
            }

            return acc;
          }, [])
          .value();

        async.eachSeries(containers, function (cont, next) {
          buildContainer(user, systemId, cont.id, revision, cont.target, out, function(err) {
            if (err) { out.stderr(err); }
            // so that buildall fails if one build fail
            next(err);
          });
        }, cb);
      });
    });
  }
function(user, systemName, revision, target, out, cb) {
    var systemId = _sr.findSystem(systemName);

    if (!systemId) {
      logger.error(ERR_NOSYSID); return cb(new Error(ERR_NOSYSID));
    }

    logger.info({ systemId: systemId, revision: revision }, 'building all containers');
    fetchTarget(systemId, target, revision, function(err, target) {
      if (err) { return cb(err); }
      _builder.loadMatchingTargets(systemId, revision, target, function(err, targets) {
        if (err) { return cb(err); }

        out.stdout('--> building all containers for ' + targets[Object.keys(targets)[0]].name + ' revision ' + revision + ' target ' + target);

        var containers = _.chain(targets)
          .filter(function(value, key) {
            return target === 'alltargets' || key === target;
          })
          .map(function(target) {
            return _.map(target.containerDefinitions, function(cdef) {
              return {
                id: cdef.id,
                target: target.topology.name,
                type: cdef.type
              };
            });
          })
          .flatten()
          .reduce(function(acc, cont) {
            var notPresent = !_.find(acc, function(found) {
              return found.id === cont.id && found.type === cont.type;
            });

            if (notPresent) {
              acc.push(cont);
            }

            return acc;
          }, [])
          .value();

        async.eachSeries(containers, function (cont, next) {
          buildContainer(user, systemId, cont.id, revision, cont.target, out, function(err) {
            if (err) { out.stderr(err); }
            // so that buildall fails if one build fail
            next(err);
          });
        }, cb);
      });
    });
  }
function ( user , systemName , revision , target , out , cb ) { var systemId = _sr . findSystem ( systemName ) ; if ( ! systemId ) { logger . error ( ERR_NOSYSID ) ; return cb ( new Error ( ERR_NOSYSID ) ) ; } logger . info ( { systemId : systemId , revision : revision } , 'building all containers' ) ; fetchTarget ( systemId , target , revision , function ( err , target ) { if ( err ) { return cb ( err ) ; } _builder . loadMatchingTargets ( systemId , revision , target , function ( err , targets ) { if ( err ) { return cb ( err ) ; } out . stdout ( '--> building all containers for ' + targets [ Object . keys ( targets ) [ 0 ] ] . name + ' revision ' + revision + ' target ' + target ) ; var containers = _ . chain ( targets ) . filter ( function ( value , key ) { return target === 'alltargets' || key === target ; } ) . map ( function ( target ) { return _ . map ( target . containerDefinitions , function ( cdef ) { return { id : cdef . id , target : target . topology . name , type : cdef . type } ; } ) ; } ) . flatten ( ) . reduce ( function ( acc , cont ) { var notPresent = ! _ . find ( acc , function ( found ) { return found . id === cont . id && found . type === cont . type ; } ) ; if ( notPresent ) { acc . push ( cont ) ; } return acc ; } , [ ] ) . value ( ) ; async . eachSeries ( containers , function ( cont , next ) { buildContainer ( user , systemId , cont . id , revision , cont . target , out , function ( err ) { if ( err ) { out . stderr ( err ) ; } // so that buildall fails if one build fail next ( err ) ; } ) ; } , cb ) ; } ) ; } ) ; }
build all containers belonging to a system, in series
build all containers belonging to a system in series