This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
63 lines (55 loc) · 1.65 KB
/
commands.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
package main
import (
"fmt"
"log"
"github.com/spf13/cobra"
)
var cfgFile string
var tplFile string
func init() {
generateCmd.Flags().StringVarP(&cfgFile, "config", "c", "config", "path to config file")
generateCmd.Flags().StringVarP(&tplFile, "template", "t", "template", "path to template file")
deployCmd.Flags().StringVarP(&cfgFile, "config", "c", "config", "path to config file")
deployCmd.Flags().StringVarP(&tplFile, "template", "t", "template", "path to template file")
terminateCmd.Flags().StringVarP(&cfgFile, "config", "c", "config", "path to config file")
rootCmd.AddCommand(generateCmd, deployCmd, terminateCmd)
}
// root command (calls all other commands)
var rootCmd = &cobra.Command{
Use: "bora",
Short: "bora is a simple wrapper around cloudformation. ",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
},
}
var generateCmd = &cobra.Command{
Use: "generate",
Short: "Generates a JSON or YAML template",
Run: func(cmd *cobra.Command, args []string) {
configReader(cfgFile)
log.Println("Generating a template for", stackname)
tpl := templateParser(tplFile)
fmt.Println(tpl)
},
}
var deployCmd = &cobra.Command{
Use: "deploy",
Short: "Deploys a stack",
Run: func(cmd *cobra.Command, args []string) {
configReader(cfgFile)
log.Println("Deploying a template for", stackname)
tpl := templateParser(tplFile)
_, sess := awsSession()
deployStack(tpl, sess)
},
}
var terminateCmd = &cobra.Command{
Use: "terminate",
Short: "Terminates a stack",
Run: func(cmd *cobra.Command, args []string) {
configReader(cfgFile)
log.Println("Terminating stack", stackname)
_, sess := awsSession()
terminateStack(sess)
},
}