-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (56 loc) · 1.52 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
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"flag"
"fmt"
"os"
"github.com/gmcoringa/tswitch/pkg/configuration"
"github.com/gmcoringa/tswitch/pkg/db"
"github.com/gmcoringa/tswitch/pkg/hcl"
"github.com/gmcoringa/tswitch/pkg/lib"
formatter "github.com/gmcoringa/tswitch/pkg/log"
tf "github.com/gmcoringa/tswitch/pkg/terraform"
tg "github.com/gmcoringa/tswitch/pkg/terragrunt"
log "github.com/sirupsen/logrus"
)
var (
version = "snapshot"
)
func main() {
formatter := formatter.Format{}
log.SetFormatter(&formatter)
log.SetOutput(os.Stderr)
logLevel := flag.String("log_level", "info", "logging level, valid vaulues: trace, debug, info, warn, error, fatal, panic")
displayVersion := flag.Bool("v", false, "prints current roxy version")
// init other flags
configuration.InitFlags()
level, err := log.ParseLevel(*logLevel)
if err != nil {
level = log.InfoLevel
}
log.SetLevel(level)
if *displayVersion {
fmt.Println(version)
os.Exit(0)
}
configuration, err := configuration.Load()
if err != nil {
log.Error(err)
os.Exit(1)
}
constraints, err := hcl.Parse(configuration.TerragruntFile)
if err != nil {
log.Error(err)
os.Exit(1)
}
db, err := db.Init(configuration)
if err != nil {
log.Error("Failed to load local db", err)
os.Exit(1)
}
tfResolver := tf.Init(configuration)
terraform := lib.CreateInstaller(configuration, db, tfResolver)
terraform.Install(constraints.Terraform)
tgResolver := tg.Init()
terragrunt := lib.CreateInstaller(configuration, db, tgResolver)
terragrunt.Install(constraints.Terragrunt)
}