This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
/
maintenance.go
93 lines (79 loc) · 1.83 KB
/
maintenance.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"fmt"
"log"
"os"
"github.com/heroku/hk/Godeps/_workspace/src/github.com/bgentry/heroku-go"
)
var cmdMaintenance = &Command{
Run: runMaintenance,
Usage: "maintenance",
NeedsApp: true,
Category: "app",
Short: "show app maintenance mode" + extra,
Long: `
Maintenance shows the current maintenance mode state of an app.
Example:
$ hk maintenance
enabled
`,
}
func runMaintenance(cmd *Command, args []string) {
if len(args) != 0 {
cmd.PrintUsage()
os.Exit(2)
}
app, err := client.AppInfo(mustApp())
must(err)
state := "disabled"
if app.Maintenance {
state = "enabled"
}
fmt.Println(state)
}
var cmdMaintenanceEnable = &Command{
Run: runMaintenanceEnable,
Usage: "maintenance-enable",
NeedsApp: true,
Category: "app",
Short: "enable maintenance mode" + extra,
Long: `
Enables maintenance mode on an app.
Example:
$ hk maintenance-enable
Enabled maintenance mode on myapp.
`,
}
func runMaintenanceEnable(cmd *Command, args []string) {
if len(args) != 0 {
cmd.PrintUsage()
os.Exit(2)
}
newmode := true
app, err := client.AppUpdate(mustApp(), &heroku.AppUpdateOpts{Maintenance: &newmode})
must(err)
log.Printf("Enabled maintenance mode on %s.", app.Name)
}
var cmdMaintenanceDisable = &Command{
Run: runMaintenanceDisable,
Usage: "maintenance-disable",
NeedsApp: true,
Category: "app",
Short: "disable maintenance mode" + extra,
Long: `
Disables maintenance mode on an app.
Example:
$ hk maintenance-disable
Disabled maintenance mode on myapp.
`,
}
func runMaintenanceDisable(cmd *Command, args []string) {
if len(args) != 0 {
cmd.PrintUsage()
os.Exit(2)
}
newmode := false
app, err := client.AppUpdate(mustApp(), &heroku.AppUpdateOpts{Maintenance: &newmode})
must(err)
log.Printf("Disabled maintenance mode on %s.", app.Name)
}