Move updateContainerNetworkSettings() into proxy
This commit is contained in:
1 parent
5eaff802d4
commit
949f8bb2e7
3 files changed
+24
-24
No files matched your search
@@ -22,31 +22,9 @@ func (i *inspectContainerInterceptor) InterceptResponse(r *http.Response) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := updateContainerNetworkSettings(container, i.proxy); err != nil {
|
if err := i.proxy.updateContainerNetworkSettings(container); err != nil {
|
||||||
Log.Warningf("Inspecting container %s failed: %s", container["Id"], err)
|
Log.Warningf("Inspecting container %s failed: %s", container["Id"], err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return marshalResponseBody(r, container)
|
return marshalResponseBody(r, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateContainerNetworkSettings(container jsonObject, proxy *Proxy) error {
|
|
||||||
containerID, err := container.String("Id")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy.waitForStartByIdent(containerID)
|
|
||||||
mac, ips, nets, err := weaveContainerIPs(containerID)
|
|
||||||
if err != nil || len(ips) == 0 {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
networkSettings, err := container.Object("NetworkSettings")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
networkSettings["MacAddress"] = mac
|
|
||||||
networkSettings["IPAddress"] = ips[0].String()
|
|
||||||
networkSettings["IPPrefixLen"], _ = nets[0].Mask.Size()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,7 @@ func (i *inspectExecInterceptor) InterceptResponse(r *http.Response) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := updateContainerNetworkSettings(container, i.proxy); err != nil {
|
if err := i.proxy.updateContainerNetworkSettings(container); err != nil {
|
||||||
Log.Warningf("Inspecting exec %s failed: %s", exec["Id"], err)
|
Log.Warningf("Inspecting exec %s failed: %s", exec["Id"], err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -512,3 +512,25 @@ func (proxy *Proxy) getDNSDomain() (domain string) {
|
|||||||
|
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (proxy *Proxy) updateContainerNetworkSettings(container jsonObject) error {
|
||||||
|
containerID, err := container.String("Id")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy.waitForStartByIdent(containerID)
|
||||||
|
mac, ips, nets, err := weaveContainerIPs(containerID)
|
||||||
|
if err != nil || len(ips) == 0 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
networkSettings, err := container.Object("NetworkSettings")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
networkSettings["MacAddress"] = mac
|
||||||
|
networkSettings["IPAddress"] = ips[0].String()
|
||||||
|
networkSettings["IPPrefixLen"], _ = nets[0].Mask.Size()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in new issue
Block a user