make proxy pay attention to WEAVE_HTTP_ADDR

This commit is contained in:
Matthias Radestock committed 2016-02-03 11:28:38 +00:00
1 parent fdd006022d
commit dde244160b
4 files changed
+25 -12

No files matched your search

+20 -1
View File
@@ -13,6 +13,7 @@ import (
)
const (
WeaveHTTPHost = "127.0.0.1"
WeaveHTTPPort = 6784
)
@@ -59,7 +60,25 @@ func (client *Client) httpVerb(verb string, url string, values url.Values) (stri
}
func NewClient(addr string) *Client {
return &Client{baseURL: fmt.Sprintf("http://%s:%d", addr, WeaveHTTPPort)}
host := WeaveHTTPHost
port := fmt.Sprintf("%d", WeaveHTTPPort)
switch parts := strings.Split(addr, ":"); len(parts) {
case 0:
case 1:
if parts[0] != "" {
host = parts[0]
}
case 2:
if parts[0] != "" {
host = parts[0]
}
if parts[1] != "" {
port = parts[1]
}
default:
return &Client{baseURL: fmt.Sprintf("http://%s", addr)}
}
return &Client{baseURL: fmt.Sprintf("http://%s:%s", host, port)}
}
func NewClientWithResolver(resolver func() (string, error)) *Client {
+3
View File
@@ -48,6 +48,9 @@ func callWeave(args ...string) ([]byte, []byte, error) {
// integration test suite breaking things.
propagateEnv("COVERAGE")
// In case the router control endpoint address is non-standard.
propagateEnv("WEAVE_HTTP_ADDR")
Log.Debug("Calling weave args: ", args, "env: ", cmd.Env)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
+1 -11
View File
@@ -559,17 +559,7 @@ func (proxy *Proxy) getDNSDomain() string {
if proxy.WithoutDNS {
return ""
}
weaveContainer, err := proxy.client.InspectContainer("weave")
var weaveIP string
if err == nil && weaveContainer.NetworkSettings != nil {
weaveIP = weaveContainer.NetworkSettings.IPAddress
}
if weaveIP == "" {
weaveIP = "127.0.0.1"
}
weave := weaveapi.NewClient(weaveIP)
weave := weaveapi.NewClient(os.Getenv("WEAVE_HTTP_ADDR"))
domain, _ := weave.DNSDomain()
return domain
}
+1
View File
@@ -1661,6 +1661,7 @@ launch_proxy() {
-e DOCKER_BRIDGE \
-e WEAVE_DEBUG \
-e COVERAGE \
-e WEAVE_HTTP_ADDR \
-e EXEC_IMAGE=$EXEC_IMAGE \
--entrypoint=/home/weave/weaveproxy \
$WEAVEPROXY_DOCKER_ARGS $EXEC_IMAGE $COVERAGE_ARGS $PROXY_ARGS)