Skip to content

Commit 5508c45

Browse files
committed
fix(builder): added back the check-repos script
Per #4338, I have replaced the script and toml file that I overzealously removed in an earlier builder revision.
1 parent c04fc58 commit 5508c45

5 files changed

Lines changed: 49 additions & 5 deletions

File tree

builder/env/envvar.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ func Get(c cookoo.Context, params *cookoo.Params) (interface{}, cookoo.Interrupt
2929
var val string
3030
if val = os.Getenv(name); len(val) == 0 {
3131
def := def.(string)
32+
val = os.ExpandEnv(def)
3233
// We want to make sure that any subsequent calls to Getenv
3334
// return the same default.
34-
os.Setenv(name, def)
35+
os.Setenv(name, val)
3536

36-
val = os.ExpandEnv(def)
3737
}
3838
c.Put(name, val)
3939
log.Debugf(c, "Name: %s, Val: %s", name, val)

builder/env/envvar_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,24 @@ func TestGet(t *testing.T) {
5353
if both := cxt.Get(snack, "").(string); both != "coffee and chocolate chip cookies" {
5454
t.Errorf("Expected 'coffee and chocolate chip cookies'. Got '%s'", both)
5555
}
56+
}
57+
58+
// TestGetInterpolation is a regression test to make sure that values are
59+
// interpolated correctly.
60+
func TestGetInterpolation(t *testing.T) {
61+
reg, router, cxt := cookoo.Cookoo()
62+
63+
os.Setenv("TEST_ENV", "is")
64+
65+
reg.Route("test", "Test route").
66+
Does(Get, "res").
67+
Using("TEST_ENV2").WithDefault("de$TEST_ENV")
68+
69+
if err := router.HandleRequest("test", cxt, true); err != nil {
70+
t.Error(err)
71+
}
5672

57-
if both := os.Getenv(snack); both != snackVal {
58-
t.Errorf("Expected %s to not be expanded. Got '%s'", snack, both)
73+
if os.Getenv("TEST_ENV2") != "deis" {
74+
t.Errorf("Expected 'deis', got '%s'", os.Getenv("TEST_ENV2"))
5975
}
6076
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[template]
2+
src = "check-repos"
3+
dest = "/home/git/check-repos"
4+
uid = 0
5+
gid = 0
6+
mode = "0755"
7+
keys = [
8+
"/deis/registry",
9+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
export ETCD=${ETCD:-$HOST:4001}
4+
5+
cd $(dirname $0) # absolute path
6+
7+
for repo in $(ls | grep .git)
8+
do
9+
reponame="${repo%.*}"
10+
etcdctl -C "$ETCD" ls /deis/services/"$reponame" > /dev/null 2>&1
11+
if [[ $? -eq 4 ]]
12+
then
13+
rm -rf "$repo"
14+
appname="{{ getv "/deis/registry/host" }}:{{ getv "/deis/registry/port" }}/$reponame"
15+
docker images | grep $appname | awk '{ print $3 }' | xargs -r docker rmi -f
16+
# remove any dangling images left over from the cleanup
17+
docker images --filter "dangling=true" | awk '{ print $3 }' | grep -v IMAGE | xargs -r docker rmi -f
18+
fi
19+
done

builder/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func routes(reg *cookoo.Registry) {
4242
Name: "vars2",
4343
Fn: env.Get,
4444
Using: []cookoo.Param{
45-
{Name: "ETCD", DefaultValue: "http://$HOST:$ETCD_PORT"},
45+
{Name: "ETCD", DefaultValue: "$HOST:$ETCD_PORT"},
4646
},
4747
},
4848

0 commit comments

Comments
 (0)