[proxy] Override sneaky /start HostConfig params
This commit is contained in:
1 parent
846aa98a9c
commit
74c3b0d079
5 files changed
+103
-70
No files matched your search
@@ -2,16 +2,41 @@ package proxy
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/fsouza/go-dockerclient"
|
||||
)
|
||||
|
||||
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 {
|
||||
container, err := inspectContainerInPath(i.proxy.client, r.URL.Path)
|
||||
if err == nil && containerShouldAttach(container) {
|
||||
i.proxy.createWait(r, container.ID)
|
||||
if err != nil || !containerShouldAttach(container) {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
|
||||
if r.Header.Get("Content-Type") != "application/json" {
|
||||
i.proxy.createWait(r, container.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
hostConfig := &docker.HostConfig{}
|
||||
if err := unmarshalRequestBody(r, &hostConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i.proxy.addWeaveWaitVolume(hostConfig)
|
||||
if dnsDomain, withDNS := i.proxy.getDNSDomain(); withDNS {
|
||||
if err := i.proxy.setWeaveDNS(hostConfig, container.Config.Hostname, dnsDomain); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
i.proxy.createWait(r, container.ID)
|
||||
return marshalRequestBody(r, hostConfig)
|
||||
}
|
||||
|
||||
func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
|
||||
|
||||
Reference in new issue
Block a user