-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.go
100 lines (92 loc) · 2.38 KB
/
main.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
94
95
96
97
98
99
100
package main
import (
"context"
"fmt"
"os"
"github.com/containerd/containerd/namespaces"
"github.com/crosbymichael/boss/api"
"github.com/crosbymichael/boss/api/v1"
"github.com/crosbymichael/boss/version"
raven "github.com/getsentry/raven-go"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var Version string
func main() {
app := cli.NewApp()
app.Name = "boss"
// haha semver
app.Version = version.Version
app.Usage = "run containers like a ross"
app.Description = `
___ ___ ___
_____ /\ \ /\__\ /\__\
/::\ \ /::\ \ /:/ _/_ /:/ _/_
/:/\:\ \ /:/\:\ \ /:/ /\ \ /:/ /\ \
/:/ /::\__\ /:/ \:\ \ /:/ /::\ \ /:/ /::\ \
/:/_/:/\:|__| /:/__/ \:\__\ /:/_/:/\:\__\ /:/_/:/\:\__\
\:\/:/ /:/ / \:\ \ /:/ / \:\/:/ /:/ / \:\/:/ /:/ /
\::/_/:/ / \:\ /:/ / \::/ /:/ / \::/ /:/ /
\:\/:/ / \:\/:/ / \/_/:/ / \/_/:/ /
\::/ / \::/ / /:/ / /:/ /
\/__/ \/__/ \/__/ \/__/
run containers like a boss`
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "enable debug output in the logs",
},
cli.StringFlag{
Name: "agent",
Usage: "agent address",
Value: "0.0.0.0:1337",
EnvVar: "BOSS_AGENT",
},
cli.StringFlag{
Name: "sentry-dsn",
Usage: "sentry DSN",
EnvVar: "SENTRY_DSN",
},
}
app.Before = func(clix *cli.Context) error {
if clix.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
if dsn := clix.GlobalString("sentry-dsn"); dsn != "" {
raven.SetDSN(dsn)
raven.DefaultClient.SetRelease(version.Version)
}
return nil
}
app.Commands = []cli.Command{
agentCommand,
buildCommand,
checkpointCommand,
createCommand,
deleteCommand,
getCommand,
initCommand,
killCommand,
listCommand,
migrateCommand,
networkCommand,
pushCommand,
restoreCommand,
rollbackCommand,
startCommand,
stopCommand,
systemdCommand,
updateCommand,
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
raven.CaptureErrorAndWait(err, nil)
os.Exit(1)
}
}
func Context() context.Context {
return namespaces.WithNamespace(context.Background(), v1.DefaultNamespace)
}
func Agent(clix *cli.Context) (*api.LocalAgent, error) {
return api.Agent(clix.GlobalString("agent"))
}