forked from ehazlett/conduit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
125 lines (113 loc) · 2.58 KB
/
main.go
File metadata and controls
125 lines (113 loc) · 2.58 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package main
import (
"os"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/ehazlett/conduit/manager"
"github.com/ehazlett/conduit/version"
)
func run(c *cli.Context) {
if len(c.StringSlice("repo")) == 0 {
cli.ShowAppHelp(c)
log.Fatal("you must specify at least 1 repo")
}
tags := c.StringSlice("tag")
// add default tag if not present
if len(tags) == 0 {
tags = []string{"latest"}
}
managerConfig := &manager.ManagerConfig{
RepoWhitelist: c.StringSlice("repo"),
Tags: tags,
DockerURL: c.String("docker"),
TLSCACert: c.String("tls-ca-cert"),
TLSCert: c.String("tls-cert"),
TLSKey: c.String("tls-key"),
AllowInsecure: c.Bool("allow-insecure"),
AuthUsername: c.String("auth-username"),
AuthPassword: c.String("auth-password"),
AuthEmail: c.String("auth-email"),
Token: c.String("token"),
Debug: c.Bool("debug"),
}
m, err := manager.NewManager(managerConfig)
if err != nil {
log.Fatal(err)
}
m.Run()
}
func main() {
app := cli.NewApp()
app.Name = "conduit"
app.Author = "@ehazlett"
app.Email = ""
app.Usage = "docker auto-deployment system"
app.Version = version.Version
app.Action = run
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "docker, d",
Usage: "URL to Docker",
Value: "unix:///var/run/docker.sock",
EnvVar: "DOCKER_HOST",
},
cli.StringFlag{
Name: "tls-ca-cert",
Usage: "TLS CA Certificate",
Value: "",
},
cli.StringFlag{
Name: "tls-cert",
Usage: "TLS Certificate",
Value: "",
},
cli.StringFlag{
Name: "tls-key",
Usage: "TLS Key",
Value: "",
},
cli.BoolFlag{
Name: "allow-insecure",
Usage: "Allow insecure communication to daemon",
},
cli.StringSliceFlag{
Name: "repo, r",
Usage: "repo for whitelist",
Value: &cli.StringSlice{},
},
cli.StringSliceFlag{
Name: "tag",
Usage: "list of container tags for the repo to deploy",
Value: &cli.StringSlice{},
},
cli.StringFlag{
Name: "auth-username, u",
Usage: "docker auth username (optional)",
Value: "",
EnvVar: "DOCKER_AUTH_USERNAME",
},
cli.StringFlag{
Name: "auth-password, p",
Usage: "docker auth password (optional)",
Value: "",
EnvVar: "DOCKER_AUTH_PASSWORD",
},
cli.StringFlag{
Name: "auth-email, e",
Usage: "docker auth email (optional)",
Value: "",
EnvVar: "DOCKER_AUTH_EMAIL",
},
cli.StringFlag{
Name: "token, t",
Usage: "webhook token",
Value: "",
EnvVar: "TOKEN",
},
cli.BoolFlag{
Name: "debug, D",
Usage: "enable debug",
},
}
app.Run(os.Args)
}