-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (44 loc) · 1.27 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
package main
import (
"flag"
"fmt"
"terramate-bootstrap/fileutils"
"terramate-bootstrap/tmimports"
"terramate-bootstrap/tmtemplates"
"terramate-bootstrap/tmutils"
)
func main() {
// check if terramate is installed
tmutils.CheckVersion()
// flag for config file
use_yaml_config := flag.String("config", "", "Path to a configuration file.")
// flag for help
flag.Usage = func() {
fmt.Println("Usage terramate-bootstrap [options]")
fmt.Println("Options")
fmt.Println(" -config=./path/to/config.yaml Pass config file to create stacks")
fmt.Println(" -h, --help Show help information.")
}
// parse flags
flag.Parse()
// process config file
if *use_yaml_config != "" {
config, err := fileutils.ParseConfigFile(use_yaml_config)
if err != nil {
fmt.Println("error")
}
tmtemplates.TMGlobals(config.Backend)
tmimports.ImportProvider()
tmimports.ImportTerraformBlock()
tmimports.ImportsFile()
fmt.Println("Creating terramate structure from config file.")
fmt.Print(config.Stacks)
if config.Stacks.DeployEnvironmentStacks {
tmutils.DeployEnvironmentStacks(config.Stacks)
}
if config.Stacks.DeployRegionStacks {
tmutils.DeployRegionStacks(config.Stacks)
}
tmutils.DeployResourceStacks(config.Stacks)
}
}