Example #1
0
func Deploy(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Application UUID",
		HideValue: true,
	})

	cmd.Action = func() {

		var a App

		resp, body, errs := application.Show(*uuid) // TODO remove this duplication of application.Show() logic

		if errs != nil {
			log.Fatalf("Could not retrieve deployment token: %s", errs)
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Could not retrieve deployment token: %s", resp.Status)
		}

		err := json.Unmarshal([]byte(body), &a)

		if err != nil {
			log.Fatal(err)
		}

		resp, _, errs = application.Deploy(*uuid, a.DeploymentToken)

		if errs != nil {
			log.Fatalf("Could not deploy applications: %s", errs)
		}

		if resp.StatusCode != 202 {
			log.Fatalf("Could not deploy applications: %s", resp.Status)
		}

		fmt.Printf("Deploying application %s\n", *uuid)
	}

}
Example #2
0
//Deploy an Application
func Deploy(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Application UUID",
		HideValue: true,
	})

	cmd.Action = func() {
		app := application.Application{
			UUID: *uuid,
		}

		application, resp, errs := app.Show() // TODO remove this duplication of application.Show() logic

		if errs != nil {
			log.Fatalf("Could not retrieve deployment token: %s", errs)
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Could not retrieve deployment token: %s", resp.Status)
		}

		application, resp, errs = application.Deploy()

		if errs != nil {
			log.Fatalf("Could not deploy application: %s", errs)
		}

		if resp.StatusCode != 202 {
			log.Fatalf("Could not deploy application: %s", resp.Status)
		}

		fmt.Printf("Deploying application %s\n", application.UUID)
	}

}