-
Notifications
You must be signed in to change notification settings - Fork 232
/
shutdown.go
39 lines (34 loc) · 943 Bytes
/
shutdown.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
package main
import (
"fmt"
"github.com/containers/storage"
"github.com/containers/storage/pkg/mflag"
)
var forceShutdown = false
func shutdown(flags *mflag.FlagSet, action string, m storage.Store, args []string) (int, error) {
_, err := m.Shutdown(forceShutdown)
if err != nil {
if jsonOutput {
_, err2 := outputJSON(err)
return 1, err2 // Note that err2 is usually nil
}
return 1, fmt.Errorf("%s: %+v", action, err)
}
if jsonOutput {
return outputJSON(string(""))
}
return 0, nil
}
func init() {
commands = append(commands, command{
names: []string{"shutdown"},
usage: "Shut down layer storage",
minArgs: 0,
maxArgs: 0,
action: shutdown,
addFlags: func(flags *mflag.FlagSet, cmd *command) {
flags.BoolVar(&jsonOutput, []string{"-json", "j"}, jsonOutput, "Prefer JSON output")
flags.BoolVar(&forceShutdown, []string{"-force", "f"}, forceShutdown, "Unmount mounted layers first")
},
})
}