-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.go
56 lines (48 loc) · 899 Bytes
/
deploy.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
package main
import (
"fmt"
"github.com/urfave/cli/v2"
"io/ioutil"
)
func deploy(c *cli.Context) error {
app := c.String("name")
stack := c.Args().Get(0)
if stack == "" {
files, err := ioutil.ReadDir("./")
if err != nil {
return ee(err)
}
for _, f := range files {
fn := f.Name()
if fn == "stack.yml" {
stack = fn
fmt.Println("Using " + fn)
break
}
if fn == "docker-compose.yml" {
stack = fn
fmt.Println("Using " + fn)
break
}
}
}
if stack == "" {
return e1("cannot find docker-compose file")
}
auto, unsafe := c.Bool("auto"), c.Bool("unsafe")
if !auto && unsafe {
return e1("you have to use --auto if you want to use --unsafe")
}
if auto {
err := n.DeployAuto(app, stack, unsafe)
if len(err) > 0 {
return e(err)
}
} else {
err := n.Deploy(app, stack)
if len(err) > 0 {
return e(err)
}
}
return nil
}