-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.go
92 lines (76 loc) · 1.9 KB
/
push.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import (
"fmt"
"io/fs"
"io/ioutil"
"log"
"os/exec"
"path/filepath"
"runtime"
"strings"
)
var (
os = runtime.GOOS
sm = make(map[string]string)
paths = []string{}
)
func main() {
filepath.WalkDir("..", getKeyValues)
if len(paths) == 0 {
log.Fatalf("could not get paths")
}
for _, i := range paths {
content, err := ioutil.ReadFile(i)
if err != nil {
log.Fatalf("could not read file %s: %s", i, err)
}
lines := strings.Split(string(content), "\n")
for _, line := range lines {
kv := strings.Split(line, " ")
if len(kv) <= 1 {
continue
}
sm[kv[0]] = kv[1]
}
}
var lp string
var acp string
switch os {
case "windows":
lp = filepath.Join("\\", sm["STABLE_WORKSPACE_DIR"], sm["STABLE_LODESTAR_DIR"])
acp = filepath.Join("\\", sm["STABLE_WORKSPACE_DIR"], sm["STABLE_APPCONFIG_DIR"])
default:
lp = filepath.Join("/", sm["STABLE_WORKSPACE_DIR"], sm["STABLE_LODESTAR_DIR"])
acp = filepath.Join("/", sm["STABLE_WORKSPACE_DIR"], sm["STABLE_APPCONFIG_DIR"])
}
e := sm["STABLE_ENVIRONMENT"]
yk := sm["STABLE_YAML_KEYS"]
t := sm["STABLE_GIT_TOKEN"]
u := sm["STABLE_GIT_USER"]
out, err := exec.Command(lp, "app", "push", "--env", e, "--config-path", acp, "--yaml-keys", yk, "--username", u, "--token", t).Output()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", out)
}
func getKeyValues(s string, d fs.DirEntry, e error) error {
if e != nil {
return e
}
if !d.IsDir() {
switch os {
case "windows":
//to do: get this to work. Paths are not being picked up during crawl. May be a bazel thing but I dont have
//a windows machine to test appropriately
if strings.Contains(s, "stamps.txt") || strings.Contains(s, "lodestar.txt") {
paths = append(paths, s)
fmt.Println(s)
}
default:
if strings.Contains(s, "/stamps.txt") || strings.Contains(s, "/lodestar.txt") {
paths = append(paths, s)
}
}
}
return nil
}