refactor proxy entrypoint rewriting to match docker daemon

Closes #709
This commit is contained in:
Paul Bellamy committed 2015-05-20 11:41:15 +01:00
1 parent 7396f61222
commit 369466d3d4
1 file changed
+11 -18
+11 -18
View File
@@ -57,29 +57,22 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
} }
func (i *createContainerInterceptor) setWeaveWaitEntrypoint(container *docker.Config) error { func (i *createContainerInterceptor) setWeaveWaitEntrypoint(container *docker.Config) error {
var image *docker.Config if len(container.Entrypoint) == 0 {
if !configHasEntrypoint(container) || !configHasCmd(container) { image, err := i.client.InspectImage(container.Image)
imageInfo, err := i.client.InspectImage(container.Image)
if err != nil { if err != nil {
return err return err
} }
image = imageInfo.Config
if len(container.Cmd) == 0 {
container.Cmd = image.Config.Cmd
}
if container.Entrypoint == nil {
container.Entrypoint = image.Config.Entrypoint
}
} }
var entry, command []string container.Entrypoint = append(weaveWaitEntrypoint, container.Entrypoint...)
if configHasEntrypoint(container) {
entry = container.Entrypoint
} else if configHasEntrypoint(image) {
entry = image.Entrypoint
}
if configHasCmd(container) {
command = container.Cmd
} else if configHasCmd(image) {
command = image.Cmd
}
container.Entrypoint = weaveWaitEntrypoint
container.Cmd = append(entry, command...)
return nil return nil
} }