Reverse the sense of a test, to simplify the next change
and remove unused struct
This commit is contained in:
1 parent
faf94b033d
commit
20c8b1eaf6
1 file changed
+13
-22
@@ -2,41 +2,32 @@ package proxy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/fsouza/go-dockerclient"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type startContainerInterceptor struct{ proxy *Proxy }
|
type startContainerInterceptor struct{ proxy *Proxy }
|
||||||
|
|
||||||
type startContainerRequestBody struct {
|
|
||||||
HostConfig *docker.HostConfig `json:"HostConfig,omitempty" yaml:"HostConfig,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
|
func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
|
||||||
container, err := inspectContainerInPath(i.proxy.client, r.URL.Path)
|
container, err := inspectContainerInPath(i.proxy.client, r.URL.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !containerShouldAttach(container) || r.Header.Get("Content-Type") != "application/json" {
|
if containerShouldAttach(container) && r.Header.Get("Content-Type") == "application/json" {
|
||||||
i.proxy.createWait(r, container.ID)
|
hostConfig := map[string]interface{}{}
|
||||||
return nil
|
if err := unmarshalRequestBody(r, &hostConfig); err != nil {
|
||||||
}
|
|
||||||
|
|
||||||
hostConfig := map[string]interface{}{}
|
|
||||||
if err := unmarshalRequestBody(r, &hostConfig); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
i.proxy.addWeaveWaitVolume(hostConfig)
|
|
||||||
if dnsDomain := i.proxy.getDNSDomain(); dnsDomain != "" {
|
|
||||||
if err := i.proxy.setWeaveDNS(hostConfig, container.Config.Hostname, dnsDomain); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if err := marshalRequestBody(r, hostConfig); err != nil {
|
i.proxy.addWeaveWaitVolume(hostConfig)
|
||||||
return err
|
if dnsDomain := i.proxy.getDNSDomain(); dnsDomain != "" {
|
||||||
|
if err := i.proxy.setWeaveDNS(hostConfig, container.Config.Hostname, dnsDomain); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := marshalRequestBody(r, hostConfig); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
i.proxy.createWait(r, container.ID)
|
i.proxy.createWait(r, container.ID)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in new issue
Block a user