/*
The deploy event contains:
payload
.id - the deploy id
.repo - the full repository string
510110
function DoDeploy(payload) {
    self.deploy(payload.repo, function(err) {
      if (err) {
        return self.io.emit('deploy.error', payload);
      }
      self.io.emit('deploy.complete', payload);
    });
  }
1350443
function add(data, callback) {
        var id = hat() + '.json';
        repo.contents(id).add({
            content: btoa(JSON.stringify(data)),
            branch: options.branch,
            message: '+'
        }, function(err, res) {
           callback(err, res, id);
        });
    }
1216292
def on(self, dev_id):
        
        path = 'device/on'
        payload = {'id': dev_id}
        return self.rachio.put(path, payload)
509186
private void findDeploymentAddress(final String deploymentID, Handler<AsyncResult<String>> resultHandler) {
    context.execute(new Action<String>() {
      @Override
      public String perform() {
        synchronized (deployments) {
          JsonObject locatedInfo = null;
          Collection<String> sdeploymentsInfo = deployments.get(cluster);
          for (String sdeploymentInfo : sdeploymentsInfo) {
            JsonObject deploymentInfo = new JsonObject(sdeploymentInfo);
            if (deploymentInfo.getString("id").equals(deploymentID)) {
              locatedInfo = deploymentInfo;
              break;
            }
          }
          if (locatedInfo != null) {
            return locatedInfo.getString("address");
          }
          return null;
        }
      }
    }, resultHandler);
  }
842595
function publishDidValidateEvents( events ) {
      events.forEach( event => {
         testEventBus.publish( `didValidate.${event.resource}`, event );
      } );
      testEventBus.flush();
   }
856899
function get(id, callback) {
        _getSHA(id, function(err, sha) {
            if (err) return callback(err);
            repo.git.blobs(sha).fetch(function(err, res) {
                if (err) return callback(err);
                callback(err, JSON.parse(atob(res.content)));
            });
        });
    }
564434
def default_payload
      {
        app_name: config.app_name,
        deployment_remote: deployment_remote,
        force_push: config.force_push,
        reference_point: source_control.reference_point,
      }
    end
98498
def _get_current_deployment_id(self):
        '''
        
        '''
        deploymentId = ''
        stage = __salt__['boto_apigateway.describe_api_stage'](restApiId=self.restApiId,
                                                               stageName=self._stage_name,
                                                               **self._common_aws_args).get('stage')
        if stage:
            deploymentId = stage.get('deploymentId')
        return deploymentId
140624
@Override
    public void metadataInstalling(RepositoryEvent event) {
        log.finer("Installing " + event.getMetadata() + " to " + event.getFile());
    }
473998
function (ID, events) {
        "use strict";
    
        Object.defineProperty(this, 'ID', {
            'get': function () {
                return ID;
            }
        });
    
        var library;
        (function (ID) {
    
            ID = ID.split('/');
            if (ID[0] === 'libraries') {
                library = beyond.libraries.get(ID[1]);
            }
    
        })(ID);
        Object.defineProperty(this, 'library', {
            'get': function () {
                return library;
            }
        });
    
        var path = ID;
        if (library && path === library.path) {
            path = path + '/main';
        }
    
        path = path.split('/');
        if (library) {
            // Remove /libraries/library
            path.splice(0, 2);
        }
        else {
            // Remove /application
            path.splice(0, 1);
        }
    
        path = path.join('/');
    
        Object.defineProperty(this, 'path', {
            'get': function () {
                return path;
            }
        });
    
        var host;
        if (library) {
            host = beyond.hosts.libraries[library.name].js;
        }
        else {
            host = beyond.hosts.application.js;
        }
        host += path;
        Object.defineProperty(this, 'host', {
            'get': function () {
                return host;
            }
        });
    
        var plugins = new Plugins(this);
        Object.defineProperty(this, 'plugins', {
            'get': function () {
                return plugins;
            }
        });
    
        var texts = new Texts(this);
        Object.defineProperty(this, 'texts', {
            'get': function () {
                return texts;
            }
        });
    
        this.react = new ReactRegister(this, events);
    
        this.control = new Control(this);
    
        var dependencies = new Dependencies(this);
        this.dependencies = dependencies;
    
        this.Action = Action(this, events);
    
        this.invalidateCache = function (actionPath, params) {
    
            var request = new Request(this, actionPath, params);
            var cache = new Cache();
    
            return cache.invalidate(request);
    
        };
    
        this.execute = function () {
    
            var args = [].slice.call(arguments);
    
            // options must be after callback
            var actionPath, params, callback, options;
    
            for (var i in args) {
    
                var arg = args[i];
                switch (typeof arg) {
                    case 'string':
                        actionPath = arg;
                        break;
                    case 'function':
                        callback = arg;
                        break;
                    case 'object':
                        if (callback) options = arg;
                        else params = arg;
                }
    
            }
    
            if (typeof params === 'function' && typeof callback === 'undefined') {
                callback = params;
                params = undefined;
            }
    
            var action = new this.Action(actionPath, params);
            action.onResponse = function (response) {
                if (callback) callback(response);
            };
            action.onError = function (error) {
                if (callback) callback(undefined, error);
            };
            action.execute();
    
        };
    
        var styles = new ModuleStyles(this);
        Object.defineProperty(this, 'styles', {
            'get': function () {
                return styles;
            }
        });
    
        Object.defineProperty(this, 'css', {
            'get': function () {
                return styles;
            }
        });
    
        var templates = new ModuleTemplates(this);
        Object.defineProperty(this, 'templates', {
            'get': function () {
                return templates;
            }
        });
    
        this.render = function (path, params) {
            return templates.render(path, params);
        };
    
        Object.defineProperty(this, 'custom', {
            'get': function () {
    
                if (!library) {
                    return;
                }
    
                var custom = 'application/custom/' + library.name + '/' + this.path;
                return custom;
    
            }
        });
    
        this.socket = function (callback) {
    
            if (this.ID.substr(0, 10) === 'libraries/') {
    
                if (!library.socket) {
                    console.error('library does not support server communication', library.name);
                    return;
                }
                library.socket(function (socket) {
                    callback(socket);
                });
    
            }
            else {
    
                beyond.socket(function (socket) {
                    callback(socket);
                });
    
            }
    
        };
    
        var ready;
        Object.defineProperty(this, 'ready', {
            'get': function () {
                return !!ready;
            }
        });
    
        var callbacks = [];
        this.done = function (callback) {
    
            if (ready) {
                callback(dependencies.modules);
                return;
            }
    
            callbacks.push(callback);
    
        };
    
        this.dependencies.done(function () {
    
            ready = true;
    
            for (var i in callbacks) {
                callbacks[i](dependencies.modules);
            }
            callbacks = undefined;
    
        });
    
    }
1233415
function dispatch(action, payload) {
    if (process.env.NODE_ENV !== 'production' && dispatching) {
      throw new Error(`'${action.toString()}' was dispatched while '${dispatching.toString()}' was still updating. Updaters should be pure functions and must not dispatch actions.`);
    }
    try {
      dispatching = action;
      state = updater(state, action, payload);
      if (process.env.NODE_ENV !== 'production' && debug) {
        console.info(state);
      }
    } finally {
      dispatching = null;
    }
    updateUI();
  }
1261162
def deploy(self, ids):
        
        url = build_uri_with_ids('api/v3/vip-request/deploy/%s/', ids)

        return super(ApiVipRequest, self).post(url)
530143
function fetchRepo(fullName) {
  return {
    [CALL_API]: {
      types: [REPO_REQUEST, REPO_SUCCESS, REPO_FAILURE],
      endpoint: `repos/${fullName}`,
      schema: Schemas.REPO
    }
  };
}
182759
function onDeployError(deploy) {
    if (typeof self.FLEETS[deploy.id] === 'undefined') return; //nothing else to do.
    var fleet = self.FLEETS[deploy.id];
    fleet.failed++;
    fleet.failed_total++;
    var allowedError = self.getFleetError(deploy.repo);
    if (allowedError.indexOf('%') === -1) { // we have a number.
      allowedError = parseInt(allowedError, 10);
    } else {  // we have a percentage.
      var perc = parseInt(allowedError.replace('%', ''), 10);
      allowedError = Math.floor(perc / 100 * fleet.total);
    }
    // IF we have a max error rate, we stop the deploy.
    if (fleet.failed_total >= allowedError) {
      self.emit('deploy.error', deploy);
      self.log('fatal', 'Error threshold ' + fleet.failed_total + ' reached for deploy ' + deploy.id + ' on ' + deploy.repo);
      clearTimeout(fleet._timeout);
      delete self.FLEETS[deploy.id];
      return;
    }
    // IF we're still acceptable, we run next.
    createFleet(deploy);
  }
96778
private void doInternalUndeployModule(final Message<JsonObject> message) {
    final String deploymentID = message.body().getString("id");
    if (deploymentID == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No deployment ID specified."));
    } else {
      removeDeployment(deploymentID, new Handler<AsyncResult<String>>() {
        @Override
        public void handle(AsyncResult<String> result) {
          platform.undeployModule(result.succeeded() && result.result() != null ? result.result() : deploymentID, createUndeployHandler(message));
        }
      });
    }
  }
1041740
function(repo) {
    var execOpt = this.execOpt, versions, self = this;

    return new Promise(function(resolve, reject) {
      var url = createGitUrl(self.options.baseurl, repo, self.options.reposuffix, self.auth);
      execGit(['ls-remote', url, 'refs/tags/*', 'refs/heads/*'], execOpt, function(err, stdout, stderr) {
        if (err) {
          if (err.toString().indexOf('not found') === -1) {
            // dont show plain text passwords in error
            var error = new Error(stderr.toString().replace(url, ''));
            error.hideStack = true;
            error.retriable = true;
            reject(error);
          } else {
            resolve({ notfound: true });
          }
        }

        versions = {};
        var refs = stdout.split('\n');
        for (var i = 0; i < refs.length; i++) {
          if (!refs[i]) {
            continue;
          }

          var hash = refs[i].substr(0, refs[i].indexOf('\t'));
          var refName = refs[i].substr(hash.length + 1);
          var version;
          var versionObj = { hash: hash, meta: {} };

          if (refName.substr(0, 11) === 'refs/heads/') {
            version = refName.substr(11);
            versionObj.stable = false;
          } else if (refName.substr(0, 10) === 'refs/tags/') {
            if (refName.substr(refName.length - 3, 3) === '^{}') {
              version = refName.substr(10, refName.length - 13);
            } else {
              version = refName.substr(10);
            }
            if (version.substr(0, 1) === 'v' && semver.valid(version.substr(1))) {
              version = version.substr(1);
              // note when we remove a "v" which versions we need to add it back to
              // to work out the tag version again
              versionObj.meta.vPrefix = true;
            }
          }

          versions[version] = versionObj;
        }

        resolve({ versions: versions });
      });
    });
  }
1213712
def on_post(self, req, resp):
        
        resp.content_type = falcon.MEDIA_TEXT
        resp.status = falcon.HTTP_200

        # verify user input
        payload = {}
        if req.content_length:
            try:
                payload = json.load(req.stream)
            except Exception as e:  # pragma: no cover
                resp.body = "(False, 'malformed payload')"
                return
        else:
            resp.body = "(False, 'malformed payload')"
            return

        # verify payload has a container ID
        if 'id' not in payload:
            resp.body = "(False, 'payload missing id')"
            return

        # connect to docker and stop the given container
        c = None
        try:
            c = docker.from_env()
        except Exception as e:  # pragma: no cover
            resp.body = "(False, 'unable to connect to docker because: " + str(e) + "')"
            return

        # delete containers chosen from CLI
        try:
            for container_id in payload['id']:
                c.containers.get(container_id).remove()
        except Exception as e:  # pragma: no cover
            resp.body = "(False, 'unable to delete containers because: " + str(e) + "')"
            return

        resp.body = '(True, ' + str(payload['id']) + ')'
        return