diff --git a/api/api.go b/api/api.go index cc0493434f..4839e7bc63 100644 --- a/api/api.go +++ b/api/api.go @@ -92,20 +92,20 @@ func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) { if !strings.Contains(tmp.Status, "Up") && !all { continue } - if !container.Node().IsHealthy() { + if !container.Node.IsHealthy() { tmp.Status = "Pending" } // TODO remove the Node Name in the name when we have a good solution tmp.Names = make([]string, len(container.Names)) for i, name := range container.Names { - tmp.Names[i] = "/" + container.Node().Name + name + tmp.Names[i] = "/" + container.Node.Name + name } // insert node IP tmp.Ports = make([]dockerclient.Port, len(container.Ports)) for i, port := range container.Ports { tmp.Ports[i] = port if port.IP == "0.0.0.0" { - tmp.Ports[i].IP = container.Node().IP + tmp.Ports[i].IP = container.Node.IP } } out = append(out, &tmp) @@ -119,7 +119,7 @@ func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) { func getContainerJSON(c *context, w http.ResponseWriter, r *http.Request) { container := c.cluster.Container(mux.Vars(r)["name"]) if container != nil { - resp, err := http.Get(container.Node().Addr + "/containers/" + container.Id + "/json") + resp, err := http.Get(container.Node.Addr + "/containers/" + container.Id + "/json") if err != nil { httpError(w, err.Error(), http.StatusInternalServerError) return @@ -130,7 +130,7 @@ func getContainerJSON(c *context, w http.ResponseWriter, r *http.Request) { return } - n, err := json.Marshal(container.Node()) + n, err := json.Marshal(container.Node) if err != nil { httpError(w, err.Error(), http.StatusInternalServerError) return @@ -140,9 +140,8 @@ func getContainerJSON(c *context, w http.ResponseWriter, r *http.Request) { data = bytes.Replace(data, []byte("\"Name\":\"/"), []byte(fmt.Sprintf("\"Node\":%s,\"Name\":\"/", n)), -1) // insert node IP - data = bytes.Replace(data, []byte("\"HostIp\":\"0.0.0.0\""), []byte(fmt.Sprintf("\"HostIp\":%q", container.Node().IP)), -1) + data = bytes.Replace(data, []byte("\"HostIp\":\"0.0.0.0\""), []byte(fmt.Sprintf("\"HostIp\":%q", container.Node.IP)), -1) w.Write(data) - } } @@ -225,7 +224,7 @@ func proxyContainerAndForceRefresh(c *context, w http.ResponseWriter, r *http.Re } log.Debugf("[REFRESH CONTAINER] --> %s", container.Id) - container.Node().ForceRefreshContainer(container.Container) + container.Node.ForceRefreshContainer(container.Container) } // Proxy a request to the right node diff --git a/api/utils.go b/api/utils.go index 6380e0812e..0468af21af 100644 --- a/api/utils.go +++ b/api/utils.go @@ -45,7 +45,7 @@ func proxy(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseW // RequestURI may not be sent to client r.RequestURI = "" - parts := strings.SplitN(container.Node().Addr, "://", 2) + parts := strings.SplitN(container.Node.Addr, "://", 2) if len(parts) == 2 { r.URL.Scheme = parts[0] r.URL.Host = parts[1] @@ -66,8 +66,8 @@ func proxy(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseW } func hijack(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseWriter, r *http.Request) error { - addr := container.Node().Addr - if parts := strings.SplitN(container.Node().Addr, "://", 2); len(parts) == 2 { + addr := container.Node.Addr + if parts := strings.SplitN(container.Node.Addr, "://", 2); len(parts) == 2 { addr = parts[1] } diff --git a/cluster/cluster.go b/cluster/cluster.go index 5c1e9c6219..047524be35 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -107,7 +107,7 @@ func (c *Cluster) Container(IdOrName string) *Container { // Match name, /name or engine/name. for _, name := range container.Names { - if name == IdOrName || name == "/"+IdOrName || container.node.ID+name == IdOrName || container.node.Name+name == IdOrName { + if name == IdOrName || name == "/"+IdOrName || container.Node.ID+name == IdOrName || container.Node.Name+name == IdOrName { return container } } diff --git a/cluster/container.go b/cluster/container.go index 72b11585fb..066e47afdf 100644 --- a/cluster/container.go +++ b/cluster/container.go @@ -6,9 +6,5 @@ type Container struct { dockerclient.Container Info dockerclient.ContainerInfo - node *Node -} - -func (c *Container) Node() *Node { - return c.node + Node *Node } diff --git a/cluster/node.go b/cluster/node.go index abf3dff258..ccc4eba703 100644 --- a/cluster/node.go +++ b/cluster/node.go @@ -185,7 +185,7 @@ func (n *Node) inspectContainer(c dockerclient.Container, containers map[string] container := &Container{} container.Container = c - container.node = n + container.Node = n info, err := n.client.InspectContainer(c.Id) if err != nil { diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index dcb6625942..3e6afa79a4 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -61,5 +61,5 @@ func (s *Scheduler) RemoveContainer(container *cluster.Container, force bool) er s.Lock() defer s.Unlock() - return container.Node().Destroy(container, force) + return container.Node.Destroy(container, force) }