Skip to content

Commit a7ea4a0

Browse files
author
Matthew Fisher
committed
fix(router): dump host/port info into json object
These keys are currently unused by anything, but will help users use these keys with confd 0.6. See https://github.com/kelseyhightower/confd/blob/master/docs/templates.md#create-the-template
1 parent 4829c37 commit a7ea4a0

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

router/bin/boot

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -eo pipefail
1313
export ETCD_PORT=${ETCD_PORT:-4001}
1414
export ETCD="$HOST:$ETCD_PORT"
1515
export ETCD_PATH=${ETCD_PATH:-/deis/router}
16-
export HOST_ETCD_PATH=${HOST_ETCD_PATH:-/deis/router/$HOST}
16+
export HOST_ETCD_PATH=${HOST_ETCD_PATH:-/deis/router/hosts/$HOST}
1717
export ETCD_TTL=${ETCD_TTL:-10}
1818

1919
# wait for etcd to be available
@@ -85,8 +85,7 @@ if [[ ! -z $EXTERNAL_PORT ]]; then
8585

8686
# while the port is listening, publish to etcd
8787
while [[ ! -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PORT\" && \$1 ~ \"$PROTO.?\"") ]] ; do
88-
etcdctl --no-sync -C $ETCD set $HOST_ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
89-
etcdctl --no-sync -C $ETCD set $HOST_ETCD_PATH/port $EXTERNAL_PORT --ttl $ETCD_TTL >/dev/null
88+
etcdctl --no-sync -C $ETCD set $HOST_ETCD_PATH "{'host': '$HOST', 'port': $EXTERNAL_PORT}" --ttl $ETCD_TTL >/dev/null
9089
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
9190
done
9291

router/tests/router_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ func TestRouter(t *testing.T) {
6060
time.Sleep(5000 * time.Millisecond)
6161
dockercli.DeisServiceTest(t, name, port, "http")
6262
etcdutils.VerifyEtcdValue(t, "/deis/router/gzip", "on", etcdPort)
63-
routerKeyPrefix := "/deis/router/" + host
64-
etcdutils.VerifyEtcdValue(t, routerKeyPrefix+"/host", host, etcdPort)
65-
etcdutils.VerifyEtcdValue(t, routerKeyPrefix+"/port", port, etcdPort)
63+
etcdutils.VerifyEtcdValue(t,
64+
"/deis/router/hosts/"+host,
65+
fmt.Printf("{'host': '%s', 'port': %d}", host, port),
66+
etcdPort)
6667
_ = cli.CmdRm("-f", name)
6768
}

0 commit comments

Comments
 (0)