forked from rancher/rancher-compose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
132 lines (126 loc) · 2.57 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
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
126
127
128
129
130
131
132
package main
import (
"fmt"
"os"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
cliApp "github.com/rancherio/rancher-compose/app"
"github.com/rancherio/rancher-compose/librcompose"
)
var VERSION = "0.0.0-dev"
func main() {
app := cli.NewApp()
app.Name = "rancher-compose"
app.Usage = "Docker-compose to Rancher"
app.Version = librcompose.VERSION
app.Author = "Rancher"
app.Email = ""
app.Before = func(c *cli.Context) error {
if c.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
return nil
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
cli.StringFlag{
Name: "url",
Usage: fmt.Sprintf(
"Specify the Rancher API endpoint URL",
),
EnvVar: "RANCHER_URL",
},
cli.StringFlag{
Name: "access-key",
Usage: fmt.Sprintf(
"Specify Rancher API access key",
),
EnvVar: "RANCHER_ACCESS_KEY",
},
cli.StringFlag{
Name: "secret-key",
Usage: fmt.Sprintf(
"Specify Rancher API secret key",
),
EnvVar: "RANCHER_SECRET_KEY",
},
cli.StringFlag{
Name: "file,f",
Usage: "Specify an alternate compose file (default: docker-compose.yml)",
Value: "docker-compose.yml",
},
cli.StringFlag{
Name: "rancher-file,r",
Usage: "Specify an alternate Rancher compose file (default: rancher-compose.yml)",
},
cli.StringFlag{
Name: "project-name,p",
Usage: "Specify an alternate project name (default: directory name)",
},
}
app.Commands = []cli.Command{
{
Name: "create",
Usage: "Create all services but do not start",
Action: cliApp.ProjectCreate,
},
{
Name: "up",
Usage: "Bring all services up",
Action: cliApp.ProjectUp,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "d",
Usage: "Do not block and log",
},
},
},
{
Name: "start",
Usage: "Start services",
Action: cliApp.ProjectUp,
},
{
Name: "logs",
Usage: "Get service logs",
Action: cliApp.ProjectLog,
Flags: []cli.Flag{
cli.IntFlag{
Name: "lines",
Usage: "number of lines to tail",
Value: 100,
},
},
},
{
Name: "restart",
Usage: "Restart services",
Action: cliApp.ProjectRestart,
},
{
Name: "stop",
ShortName: "down",
Usage: "Stop services",
Action: cliApp.ProjectDown,
},
{
Name: "scale",
Usage: "Scale services",
Action: cliApp.Scale,
},
{
Name: "rm",
Usage: "Delete services",
Action: cliApp.ProjectDelete,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force,f",
Usage: "Allow deletion of all services",
},
},
},
}
app.Run(os.Args)
}