-
Notifications
You must be signed in to change notification settings - Fork 0
/
powerup.go
52 lines (43 loc) · 1.61 KB
/
powerup.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
package main
import (
"fmt"
"log"
"os/exec"
"strings"
"github.com/codegangsta/cli"
"github.com/piotrkowalczuk/sklog"
)
func powerup(ctx *cli.Context) error {
af, err := openAlphasfile(alphasFile)
if err != nil {
log.Fatal(err)
}
if len(af.Service) == 0 {
return nil
}
sklog.Warning(serviceLogger(logger, af.Service[0]), "We need Thunderzord power now!", sklog.KeySubsystem, af.Service[0].Name)
for _, s := range af.Service {
rl := serviceLogger(logger, s)
modified, err := isGitModifiedLocaly(s)
if err != nil {
sklog.Fatal(rl, fmt.Errorf("Ayiyiyiyi!: %s", err.Error()), sklog.KeySubsystem, "alpha")
}
if modified {
sklog.Warning(logger, fmt.Sprintf("Alpha and I will have to analyze your powers, %s, to see if they can be restored to you permanently.", s.Name), sklog.KeySubsystem, "zordon", keyColorReset, colorReset)
continue
}
if s.Branch == "" || s.Branch == "master" {
update := exec.Command("go", "get", "-u", "-t", s.Import)
if err := run(update, s, rl); err != nil {
sklog.Fatal(rl, fmt.Errorf("Ayiyiyiyi!: %s", err.Error()), sklog.KeySubsystem, "alpha")
}
} else {
if err := updateRepository(s); err != nil {
sklog.Fatal(rl, fmt.Errorf("Ayiyiyiyi!: %s", err.Error()), sklog.KeySubsystem, "alpha")
}
}
sklog.Info(rl, fmt.Sprintf("%s Thunderzord Power!", strings.ToTitle(s.Name)), sklog.KeySubsystem, s.Name)
}
sklog.Log(logger, sklog.KeyMessage, "ThunderZords shall be yours, powerful and agile. When joined together, all shall form the Thunder MegaZord.", sklog.KeySubsystem, "zordon", sklog.KeyLevel, sklog.LevelInfo, keyColorReset, colorReset)
return nil
}