refactor: make proxy use weave/api

and extend that api as required, namely with DNSDomain()
This commit is contained in:
Matthias Radestock committed 2016-02-02 20:45:30 +00:00
1 parent 34ab86124b
commit feee4f0494
2 files changed
+9 -15

No files matched your search

+4
View File
@@ -5,6 +5,10 @@ import (
"net/url"
)
func (client *Client) DNSDomain() (string, error) {
return client.httpVerb("GET", "/domain", nil)
}
func (client *Client) RegisterWithDNS(ID string, fqdn string, ip string) error {
data := url.Values{}
data.Add("fqdn", fqdn)
+5 -15
View File
@@ -5,7 +5,6 @@ import (
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
@@ -17,6 +16,7 @@ import (
"time"
docker "github.com/fsouza/go-dockerclient"
weaveapi "github.com/weaveworks/weave/api"
. "github.com/weaveworks/weave/common"
weavedocker "github.com/weaveworks/weave/common/docker"
)
@@ -555,7 +555,7 @@ func (proxy *Proxy) setWeaveDNS(hostConfig jsonObject, hostname, dnsDomain strin
return nil
}
func (proxy *Proxy) getDNSDomain() (domain string) {
func (proxy *Proxy) getDNSDomain() string {
if proxy.WithoutDNS {
return ""
}
@@ -569,19 +569,9 @@ func (proxy *Proxy) getDNSDomain() (domain string) {
weaveIP = "127.0.0.1"
}
url := fmt.Sprintf("http://%s:6784/domain", weaveIP)
resp, err := http.Get(url)
if err != nil || resp.StatusCode != http.StatusOK {
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
return string(b)
weave := weaveapi.NewClient(weaveIP)
domain, _ := weave.DNSDomain()
return domain
}
func (proxy *Proxy) updateContainerNetworkSettings(container jsonObject) error {