forked from pkallberg/cx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redeploy.go
40 lines (33 loc) · 966 Bytes
/
redeploy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
)
var cmdRedeploy = &Command{
Run: runRedeploy,
Usage: "redeploy [-y]",
NeedsStack: true,
Category: "stack",
Short: "redeploys stack",
Long: `Enqueues redeployment of the stack.
If the stack is already building, another build will be enqueued and performed immediately
after the current one is finished.
-y answers yes to confirmation question if the stack is production.
`,
}
var flagConfirmation bool
func init() {
cmdRedeploy.Flag.BoolVar(&flagConfirmation, "y", false, "answer yes")
}
func runRedeploy(cmd *Command, args []string) {
stack := mustStack()
// confirmation is needed if the stack is production
if stack.Environment == "production" && !flagConfirmation {
mustConfirm("This is a production stack. Proceed with deployment? [yes/N]", "yes")
}
result, err := client.RedeployStack(stack.Uid)
if err != nil {
printFatal(err.Error())
} else {
fmt.Println(result.Message)
}
}