示例#1
0
func (a *Application) fillContext(context *Variables, runner TaskRunner, client marathon.Marathon) error {
	tasks, err := client.Tasks(a.ID)
	if err != nil {
		return err
	}

	if tasks == nil || len(tasks.Tasks) == 0 {
		return ErrTaskNotRunning
	}

	return runner.FillContext(context, a, tasks.Tasks[0])
}
示例#2
0
func updateApplication(client marathon.Marathon, app *marathon.Application) (updated *ExpectedDeployment, err error) {
	updated = &ExpectedDeployment{}
	if updatedApp, err := client.UpdateApplication(app, false); err == nil {
		updated.AppId = app.ID
		updated.NewDeployment = false

		deps := updatedApp.DeploymentID
		ln := len(deps)
		updated.DeploymentIds = make([]string, ln, ln)
		for i, el := range deps {
			updated.DeploymentIds[i] = el["id"]
		}
	}
	return
}
示例#3
0
func createNewApplication(client marathon.Marathon, app *marathon.Application) (deployed *ExpectedDeployment, err error) {
	deployed = &ExpectedDeployment{}
	if created, err := client.CreateApplication(app, false); err == nil {
		deployed.AppId = created.ID
		deployed.NewDeployment = true
		deps := created.DeploymentID
		ln := len(deps)
		deployed.DeploymentIds = make([]string, ln, ln)
		for i, el := range deps {
			deployed.DeploymentIds[i] = el["id"]
		}
	}

	return
}
示例#4
0
func (a *Application) checkRunningAndHealthy(client marathon.Marathon) error {
	app, err := client.Application(a.ID)
	if err != nil {
		return err
	}

	if app == nil {
		return ErrApplicationDoesNotExist
	}

	if app.TasksRunning == 0 {
		return ErrTaskNotRunning
	}

	if a.Healthcheck != "" && app.TasksHealthy == 0 {
		return ErrHealthcheckNotPassing
	}

	return nil
}
示例#5
0
func waitOnDeployment(client marathon.Marathon, id *marathon.DeploymentID) {
	Assert(client.WaitOnDeployment(id.DeploymentID, 0))
}