forked from coinbase/odin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodin.go
68 lines (61 loc) · 1.31 KB
/
odin.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
package main
import (
"fmt"
"os"
"github.com/coinbase/odin/client"
"github.com/coinbase/odin/deployer"
"github.com/coinbase/step/utils/is"
"github.com/coinbase/step/utils/run"
"github.com/coinbase/step/utils/to"
)
func main() {
var arg, command string
switch len(os.Args) {
case 1:
fmt.Println("Starting Lambda")
run.LambdaTasks(deployer.TaskHandlers())
case 2:
command = os.Args[1]
arg = ""
case 3:
command = os.Args[1]
arg = os.Args[2]
default:
printUsage() // Print how to use and exit
}
stepFn := to.Strp(os.Getenv("ODIN_STEP"))
if is.EmptyStr(stepFn) {
stepFn = to.Strp("coinbase-odin")
}
switch command {
case "json":
run.JSON(deployer.StateMachine())
case "deploy":
// Send Configuration to the deployer
// arg is a filename
err := client.Deploy(stepFn, &arg)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
case "fails":
// List the recent failures and their causes
err := client.Failures(stepFn)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
case "halt":
err := client.Halt(stepFn, &arg)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
default:
printUsage() // Print how to use and exit
}
}
func printUsage() {
fmt.Println("Usage: odin <json|deploy|halt|fails> <release_file> (No args starts Lambda)")
os.Exit(0)
}