Allow trun ids with links

Only now full ids with docker ls -a
This commit is contained in:
Michael Crosby
2013-10-04 13:21:28 -07:00
parent 6c091462ed
commit 86c96da8d0
3 changed files with 33 additions and 2 deletions
+13 -1
View File
@@ -1015,11 +1015,22 @@ func makeHttpHandler(srv *Server, logging bool, localMethod string, localRoute s
}
func getContainersLinks(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := parseForm(r); err != nil {
return err
}
runtime := srv.runtime
all, err := getBoolParam(r.Form.Get("all"))
if err != nil {
return err
}
out := []APILink{}
err := runtime.containerGraph.Walk("/", func(p string, e *gograph.Entity) error {
err = runtime.containerGraph.Walk("/", func(p string, e *gograph.Entity) error {
if container := runtime.Get(e.ID()); container != nil {
if !all && strings.Contains(p, container.ID) {
return nil
}
out = append(out, APILink{
Path: p,
ContainerID: container.ID,
@@ -1028,6 +1039,7 @@ func getContainersLinks(srv *Server, version float64, w http.ResponseWriter, r *
}
return nil
}, -1)
if err != nil {
return err
}
+7 -1
View File
@@ -1131,11 +1131,17 @@ func (cli *DockerCli) CmdPs(args ...string) error {
func (cli *DockerCli) CmdLs(args ...string) error {
cmd := Subcmd("ls", "", "List links for containers")
flAll := cmd.Bool("a", false, "Show all links")
if err := cmd.Parse(args); err != nil {
return nil
}
v := url.Values{}
if *flAll {
v.Set("all", "1")
}
body, _, err := cli.call("GET", "/containers/links", nil)
body, _, err := cli.call("GET", "/containers/links?"+v.Encode(), nil)
if err != nil {
return err
}
+13
View File
@@ -473,6 +473,10 @@ func (runtime *Runtime) Commit(container *Container, repository, tag, comment, a
}
func (runtime *Runtime) GetByName(name string) (*Container, error) {
if id, err := runtime.idIndex.Get(name); err == nil {
name = id
}
entity := runtime.containerGraph.Get(name)
if entity == nil {
return nil, fmt.Errorf("Could not find entity for %s", name)
@@ -503,6 +507,9 @@ func (runtime *Runtime) Children(name string) (map[string]*Container, error) {
}
func (runtime *Runtime) RenameLink(oldName, newName string) error {
if id, err := runtime.idIndex.Get(oldName); err == nil {
oldName = id
}
entity := runtime.containerGraph.Get(oldName)
if entity == nil {
return fmt.Errorf("Could not find entity for %s", oldName)
@@ -518,10 +525,16 @@ func (runtime *Runtime) RenameLink(oldName, newName string) error {
}
func (runtime *Runtime) Link(parentName, childName, alias string) error {
if id, err := runtime.idIndex.Get(parentName); err == nil {
parentName = id
}
parent := runtime.containerGraph.Get(parentName)
if parent == nil {
return fmt.Errorf("Could not get container for %s", parentName)
}
if id, err := runtime.idIndex.Get(childName); err == nil {
childName = id
}
child := runtime.containerGraph.Get(childName)
if child == nil {
return fmt.Errorf("Could not get container for %s", childName)