Browse code

Merge pull request #6683 from vieux/add_links_inspect

add links to inspect for 'linking' containers

Michael Crosby authored on 2014/06/27 09:33:02
Showing 3 changed files
... ...
@@ -2,6 +2,7 @@ package daemon
2 2
 
3 3
 import (
4 4
 	"encoding/json"
5
+	"fmt"
5 6
 
6 7
 	"github.com/dotcloud/docker/engine"
7 8
 	"github.com/dotcloud/docker/runconfig"
... ...
@@ -46,7 +47,16 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
46 46
 		out.Set("ProcessLabel", container.ProcessLabel)
47 47
 		out.SetJson("Volumes", container.Volumes)
48 48
 		out.SetJson("VolumesRW", container.VolumesRW)
49
+
50
+		if children, err := daemon.Children(container.Name); err == nil {
51
+			for linkAlias, child := range children {
52
+				container.hostConfig.Links = append(container.hostConfig.Links, fmt.Sprintf("%s:%s", child.Name, linkAlias))
53
+			}
54
+		}
55
+
49 56
 		out.SetJson("HostConfig", container.hostConfig)
57
+
58
+		container.hostConfig.Links = nil
50 59
 		if _, err := out.WriteTo(job.Stdout); err != nil {
51 60
 			return job.Error(err)
52 61
 		}
... ...
@@ -34,6 +34,11 @@ You can still call an old version of the API using
34 34
 
35 35
 ### What's new
36 36
 
37
+`GET /containers/(name)/json`
38
+
39
+**New!**
40
+The `HostConfig.Links` field is now filled correctly
41
+
37 42
 **New!**
38 43
 `Sockets` parameter added to the `/info` endpoint listing all the sockets the 
39 44
 daemon is configured to listen on.
... ...
@@ -240,7 +240,7 @@ Return low-level information on the container `id`
240 240
                                 }
241 241
                             ]
242 242
                          },
243
-                         "Links": null,
243
+                         "Links": ["/name:alias"],
244 244
                          "PublishAllPorts": false
245 245
                      }
246 246
         }