Exemplo n.º 1
0
func Show(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Application UUID",
		HideValue: true,
	})

	var a App

	cmd.Action = func() {
		resp, body, errs := application.Show(*uuid)

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

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

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

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

		printAppDetail(a)
	}
}
Exemplo n.º 2
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)
	}

}