forked from coinbase/fenrir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfenrir.go
66 lines (58 loc) · 1.28 KB
/
fenrir.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
package main
import (
"fmt"
"os"
"github.com/coinbase/fenrir/client"
"github.com/coinbase/fenrir/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
}
step_fn := to.Strp("coinbase-fenrir")
switch command {
case "json":
// This is required to use the step to deploy
run.JSON(deployer.StateMachine())
case "deploy":
releaseFile := &arg
if is.EmptyStr(releaseFile) {
releaseFile = to.Strp("./template.yml")
}
err := client.Deploy(step_fn, releaseFile)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
case "package":
releaseFile := &arg
if is.EmptyStr(releaseFile) {
releaseFile = to.Strp("./template.yml")
}
err := client.Package(releaseFile)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
default:
printUsage() // Print how to use and exit
}
}
func printUsage() {
fmt.Println("Usage: fenrir json|deploy|package <release_file> (No args starts Lambda)")
os.Exit(0)
}