Merge remote-tracking branch 'upstream/1.0'

This commit is contained in:
Paul Bellamy committed 2015-07-31 11:01:19 +01:00
commit 55051f0194
4 files changed
+46 -1

No files matched your search

+24
View File
@@ -50,6 +50,7 @@ type Proxy struct {
client *docker.Client
dockerBridgeIP string
hostnameMatchRegexp *regexp.Regexp
weaveWaitVolume string
}
func NewProxy(c Config) (*Proxy, error) {
@@ -79,6 +80,10 @@ func NewProxy(c Config) (*Proxy, error) {
return nil, err
}
if err = p.findWeaveWaitVolume(); err != nil {
return nil, err
}
return p, nil
}
@@ -86,6 +91,25 @@ func (proxy *Proxy) Dial() (net.Conn, error) {
return net.Dial("unix", dockerSock)
}
func (proxy *Proxy) findWeaveWaitVolume() error {
container, err := proxy.client.InspectContainer("weaveproxy")
if err != nil {
return fmt.Errorf("Could not find the weavewait volume: %s", err)
}
if container.Volumes == nil {
return fmt.Errorf("Could not find the weavewait volume")
}
volume, ok := container.Volumes["/w"]
if !ok {
return fmt.Errorf("Could not find the weavewait volume")
}
proxy.weaveWaitVolume = volume
return nil
}
func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Log.Infof("%s %s", r.Method, r.URL)
path := r.URL.Path