Skip to content

Commit

Permalink
Set gateway variable
Browse files Browse the repository at this point in the history
- Always read the default gateway
- Set it as ENVETCD_DEFAULT_GATEWAY
  • Loading branch information
jbriggs-zvelo committed Apr 16, 2015
1 parent 7892bd0 commit f65b753
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions envetcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ func getClient(config *Config) (*etcd.Client, error) {
// $ETCD_PREFIX defaults to "/config"
// $HOSTNAME will be honored if it is set.
func Set(service string) error {
gatewayIP, err := getDefaultRouteGateway()
if err != nil {
return err
}
os.Setenv("ENVETCD_DEFAULT_GATEWAY", gatewayIP.String())

etcdEndpoint := os.Getenv("ETCD_ENDPOINT")
if len(etcdEndpoint) == 0 {
// Look for the default gateway and use that.
gatewayIP, err := getDefaultRouteGateway()
if err != nil {
return err
}
etcdEndpoint = fmt.Sprintf("http://%s:4001", gatewayIP.String())
}

Expand Down

0 comments on commit f65b753

Please sign in to comment.