-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
63 lines (49 loc) · 1.41 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
package main
import (
"flag"
"fmt"
"github.com/fatih/color"
"github.com/miradnan/s3-code-deployer/config"
"github.com/miradnan/s3-code-deployer/deployment"
"io/ioutil"
"log"
"time"
)
var (
Quiet bool
Help bool
Version bool
Config *config.Configuration
)
func main() {
flag.BoolVar(&Help, "h", false, "Help info")
flag.BoolVar(&Quiet, "q", false, "Execute quietly")
flag.BoolVar(&Version, "v", false, "Get version of s3-code-deployer")
flag.Parse()
if Version {
fmt.Println(config.DeloyerVersion)
return
}
Config = config.NewConfig()
if Quiet {
color.Green("Running Quietly")
log.SetOutput(ioutil.Discard)
}
color.Yellow("#################################################")
color.Yellow(fmt.Sprintf("############### %s ##################", Config.Name))
color.Yellow("#################################################")
// Start running deployments
for range time.NewTicker(Config.RevisionCheckDuration * time.Minute).C {
log.Println(color.CyanString(fmt.Sprintf("Executed for %d Minutes", Config.RevisionCheckDuration)))
for i := 0; i < len(Config.Deployments); i++ {
//go func(i int) {
App := &Config.Deployments[i]
if len(App.Environment) <= 0 {
log.Fatal(color.RedString(fmt.Sprintf("Environment is required in application %s", App.Application)))
}
color.Yellow(fmt.Sprintf("Environment: %s", App.Environment))
deployment.Deploy(Config, App)
//}(i)
}
}
}