diff --git a/daemon/archive.go b/daemon/archive.go index 6257961b67..39429899a3 100644 --- a/daemon/archive.go +++ b/daemon/archive.go @@ -22,7 +22,7 @@ var ErrExtractPointNotDirectory = errors.New("extraction point is not a director // ContainerCopy performs a deprecated operation of archiving the resource at // the specified path in the conatiner identified by the given name. func (daemon *Daemon) ContainerCopy(name string, res string) (io.ReadCloser, error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, err } @@ -37,7 +37,7 @@ func (daemon *Daemon) ContainerCopy(name string, res string) (io.ReadCloser, err // ContainerStatPath stats the filesystem resource at the specified path in the // container identified by the given name. func (daemon *Daemon) ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, err } @@ -49,7 +49,7 @@ func (daemon *Daemon) ContainerStatPath(name string, path string) (stat *types.C // specified path in the container identified by the given name. Returns a // tar archive of the resource and whether it was a directory or a single file. func (daemon *Daemon) ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, nil, err } @@ -64,7 +64,7 @@ func (daemon *Daemon) ContainerArchivePath(name string, path string) (content io // be an error if unpacking the given content would cause an existing directory // to be replaced with a non-directory and vice versa. func (daemon *Daemon) ContainerExtractToDir(name, path string, noOverwriteDirNonDir bool, content io.Reader) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/attach.go b/daemon/attach.go index b024a063fd..12b206e13b 100644 --- a/daemon/attach.go +++ b/daemon/attach.go @@ -20,7 +20,7 @@ type ContainerAttachWithLogsConfig struct { // ContainerAttachWithLogs attaches to logs according to the config passed in. See ContainerAttachWithLogsConfig. func (daemon *Daemon) ContainerAttachWithLogs(prefixOrName string, c *ContainerAttachWithLogsConfig) error { - container, err := daemon.Get(prefixOrName) + container, err := daemon.GetContainer(prefixOrName) if err != nil { return err } @@ -60,7 +60,7 @@ type ContainerWsAttachWithLogsConfig struct { // ContainerWsAttachWithLogs websocket connection func (daemon *Daemon) ContainerWsAttachWithLogs(prefixOrName string, c *ContainerWsAttachWithLogsConfig) error { - container, err := daemon.Get(prefixOrName) + container, err := daemon.GetContainer(prefixOrName) if err != nil { return err } diff --git a/daemon/changes.go b/daemon/changes.go index 181ac5a973..5bc5b9d55e 100644 --- a/daemon/changes.go +++ b/daemon/changes.go @@ -4,7 +4,7 @@ import "github.com/docker/docker/pkg/archive" // ContainerChanges returns a list of container fs changes func (daemon *Daemon) ContainerChanges(name string) ([]archive.Change, error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, err } diff --git a/daemon/commit.go b/daemon/commit.go index 3e22add8dd..1d3d738959 100644 --- a/daemon/commit.go +++ b/daemon/commit.go @@ -21,7 +21,7 @@ import ( // Commit creates a new filesystem image from the current state of a container. // The image can optionally be tagged into a repository. func (daemon *Daemon) Commit(name string, c *types.ContainerCommitConfig) (string, error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return "", err } diff --git a/daemon/container_operations_unix.go b/daemon/container_operations_unix.go index 0cc9b089d8..5afe1244fc 100644 --- a/daemon/container_operations_unix.go +++ b/daemon/container_operations_unix.go @@ -417,7 +417,7 @@ func (daemon *Daemon) buildSandboxOptions(container *container.Container, n libn continue } - c, err := daemon.Get(ref.ParentID) + c, err := daemon.GetContainer(ref.ParentID) if err != nil { logrus.Error(err) } @@ -785,7 +785,7 @@ func (daemon *Daemon) setNetworkNamespaceKey(containerID string, pid int) error func (daemon *Daemon) getIpcContainer(container *container.Container) (*container.Container, error) { containerID := container.HostConfig.IpcMode.Container() - c, err := daemon.Get(containerID) + c, err := daemon.GetContainer(containerID) if err != nil { return nil, err } @@ -796,7 +796,7 @@ func (daemon *Daemon) getIpcContainer(container *container.Container) (*containe } func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID string) (*container.Container, error) { - nc, err := daemon.Get(connectedContainerID) + nc, err := daemon.GetContainer(connectedContainerID) if err != nil { return nil, err } diff --git a/daemon/create.go b/daemon/create.go index 8e67d91d4a..ff6bca7f3d 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -119,7 +119,7 @@ func (daemon *Daemon) generateSecurityOpt(ipcMode runconfig.IpcMode, pidMode run return label.DisableSecOpt(), nil } if ipcContainer := ipcMode.Container(); ipcContainer != "" { - c, err := daemon.Get(ipcContainer) + c, err := daemon.GetContainer(ipcContainer) if err != nil { return nil, err } diff --git a/daemon/daemon.go b/daemon/daemon.go index 9d8a8e6eef..eec193401c 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -163,14 +163,14 @@ type Daemon struct { imageStore image.Store } -// Get looks for a container using the provided information, which could be +// GetContainer looks for a container using the provided information, which could be // one of the following inputs from the caller: // - A full container ID, which will exact match a container in daemon's list // - A container name, which will only exact match via the GetByName() function // - A partial container ID prefix (e.g. short ID) of any length that is // unique enough to only return a single container object // If none of these searches succeed, an error is returned -func (daemon *Daemon) Get(prefixOrName string) (*container.Container, error) { +func (daemon *Daemon) GetContainer(prefixOrName string) (*container.Container, error) { if containerByID := daemon.containers.Get(prefixOrName); containerByID != nil { // prefix is an exact match to a full container ID return containerByID, nil @@ -196,13 +196,13 @@ func (daemon *Daemon) Get(prefixOrName string) (*container.Container, error) { // Exists returns a true if a container of the specified ID or name exists, // false otherwise. func (daemon *Daemon) Exists(id string) bool { - c, _ := daemon.Get(id) + c, _ := daemon.GetContainer(id) return c != nil } // IsPaused returns a bool indicating if the specified container is paused. func (daemon *Daemon) IsPaused(id string) bool { - c, _ := daemon.Get(id) + c, _ := daemon.GetContainer(id) return c.State.IsPaused() } @@ -552,7 +552,7 @@ func (daemon *Daemon) getEventFilter(filter filters.Args) *events.Filter { // incoming container filter can be name, id or partial id, convert to // a full container id for _, cn := range filter.Get("container") { - c, err := daemon.Get(cn) + c, err := daemon.GetContainer(cn) filter.Del("container", cn) if err == nil { filter.Add("container", c.ID) @@ -599,7 +599,7 @@ func (daemon *Daemon) children(name string) (map[string]*container.Container, er children := make(map[string]*container.Container) err = daemon.containerGraphDB.Walk(name, func(p string, e *graphdb.Entity) error { - c, err := daemon.Get(e.ID()) + c, err := daemon.GetContainer(e.ID()) if err != nil { return err } diff --git a/daemon/daemon_test.go b/daemon/daemon_test.go index 5f6cc43369..8802d5c65c 100644 --- a/daemon/daemon_test.go +++ b/daemon/daemon_test.go @@ -21,7 +21,7 @@ import ( // https://github.com/docker/docker/issues/8069 // -func TestGet(t *testing.T) { +func TestGetContainer(t *testing.T) { c1 := &container.Container{ CommonContainer: container.CommonContainer{ ID: "5a4ff6a163ad4533d22d69a2b8960bf7fafdcba06e72d2febdba229008b0bf57", @@ -91,32 +91,32 @@ func TestGet(t *testing.T) { containerGraphDB: graph, } - if container, _ := daemon.Get("3cdbd1aa394fd68559fd1441d6eff2ab7c1e6363582c82febfaa8045df3bd8de"); container != c2 { + if container, _ := daemon.GetContainer("3cdbd1aa394fd68559fd1441d6eff2ab7c1e6363582c82febfaa8045df3bd8de"); container != c2 { t.Fatal("Should explicitly match full container IDs") } - if container, _ := daemon.Get("75fb0b8009"); container != c4 { + if container, _ := daemon.GetContainer("75fb0b8009"); container != c4 { t.Fatal("Should match a partial ID") } - if container, _ := daemon.Get("drunk_hawking"); container != c2 { + if container, _ := daemon.GetContainer("drunk_hawking"); container != c2 { t.Fatal("Should match a full name") } // c3.Name is a partial match for both c3.ID and c2.ID - if c, _ := daemon.Get("3cdbd1aa"); c != c3 { + if c, _ := daemon.GetContainer("3cdbd1aa"); c != c3 { t.Fatal("Should match a full name even though it collides with another container's ID") } - if container, _ := daemon.Get("d22d69a2b896"); container != c5 { + if container, _ := daemon.GetContainer("d22d69a2b896"); container != c5 { t.Fatal("Should match a container where the provided prefix is an exact match to the it's name, and is also a prefix for it's ID") } - if _, err := daemon.Get("3cdbd1"); err == nil { + if _, err := daemon.GetContainer("3cdbd1"); err == nil { t.Fatal("Should return an error when provided a prefix that partially matches multiple container ID's") } - if _, err := daemon.Get("nothing"); err == nil { + if _, err := daemon.GetContainer("nothing"); err == nil { t.Fatal("Should return an error when provided a prefix that is neither a name or a partial match to an ID") } diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index a386535fd0..bad43248a0 100755 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -632,14 +632,14 @@ func (daemon *Daemon) registerLinks(container *container.Container, hostConfig * if err != nil { return err } - child, err := daemon.Get(name) + child, err := daemon.GetContainer(name) if err != nil { - //An error from daemon.Get() means this name could not be found + //An error from daemon.GetContainer() means this name could not be found return fmt.Errorf("Could not get container for %s", name) } for child.HostConfig.NetworkMode.IsContainer() { parts := strings.SplitN(string(child.HostConfig.NetworkMode), ":", 2) - child, err = daemon.Get(parts[1]) + child, err = daemon.GetContainer(parts[1]) if err != nil { return fmt.Errorf("Could not get container for %s", parts[1]) } diff --git a/daemon/daemonbuilder/builder.go b/daemon/daemonbuilder/builder.go index 4cd28c1bff..6414bf904a 100644 --- a/daemon/daemonbuilder/builder.go +++ b/daemon/daemonbuilder/builder.go @@ -82,7 +82,7 @@ func (d Docker) Pull(name string) (*image.Image, error) { // Container looks up a Docker container referenced by `id`. func (d Docker) Container(id string) (*container.Container, error) { - return d.Daemon.Get(id) + return d.Daemon.GetContainer(id) } // Create creates a new Docker container and returns potential warnings @@ -96,7 +96,7 @@ func (d Docker) Create(cfg *runconfig.Config, hostCfg *runconfig.HostConfig) (*c if err != nil { return nil, nil, err } - container, err := d.Daemon.Get(ccr.ID) + container, err := d.Container(ccr.ID) if err != nil { return nil, ccr.Warnings, err } diff --git a/daemon/delete.go b/daemon/delete.go index c8f08182dc..a282f3a9f9 100644 --- a/daemon/delete.go +++ b/daemon/delete.go @@ -17,7 +17,7 @@ import ( // fails. If the remove succeeds, the container name is released, and // network links are removed. func (daemon *Daemon) ContainerRm(name string, config *types.ContainerRmConfig) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } @@ -72,7 +72,7 @@ func (daemon *Daemon) rmLink(name string) error { return err } - parentContainer, _ := daemon.Get(pe.ID()) + parentContainer, _ := daemon.GetContainer(pe.ID()) if parentContainer != nil { if err := daemon.updateNetwork(parentContainer); err != nil { logrus.Debugf("Could not update network to remove link %s: %v", n, err) diff --git a/daemon/exec.go b/daemon/exec.go index c3f2ef4c42..50b1edc3b3 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -64,7 +64,7 @@ func (d *Daemon) unregisterExecCommand(container *container.Container, execConfi } func (d *Daemon) getActiveContainer(name string) (*container.Container, error) { - container, err := d.Get(name) + container, err := d.GetContainer(name) if err != nil { return nil, err } diff --git a/daemon/export.go b/daemon/export.go index 4446caf0b1..9e3d8da340 100644 --- a/daemon/export.go +++ b/daemon/export.go @@ -12,7 +12,7 @@ import ( // ContainerExport writes the contents of the container to the given // writer. An error is returned if the container cannot be found. func (daemon *Daemon) ContainerExport(name string, out io.Writer) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/inspect.go b/daemon/inspect.go index b98d71e595..562ad78741 100644 --- a/daemon/inspect.go +++ b/daemon/inspect.go @@ -28,7 +28,7 @@ func (daemon *Daemon) ContainerInspect(name string, size bool, version version.V } func (daemon *Daemon) containerInspectCurrent(name string, size bool) (*types.ContainerJSON, error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, err } @@ -68,7 +68,7 @@ func (daemon *Daemon) containerInspectCurrent(name string, size bool) (*types.Co // containerInspect120 serializes the master version of a container into a json type. func (daemon *Daemon) containerInspect120(name string) (*v1p20.ContainerJSON, error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, err } diff --git a/daemon/inspect_unix.go b/daemon/inspect_unix.go index b72e09b338..e1c2823595 100644 --- a/daemon/inspect_unix.go +++ b/daemon/inspect_unix.go @@ -20,7 +20,7 @@ func setPlatformSpecificContainerFields(container *container.Container, contJSON // containerInspectPre120 gets containers for pre 1.20 APIs. func (daemon *Daemon) containerInspectPre120(name string) (*v1p19.ContainerJSON, error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, err } diff --git a/daemon/kill.go b/daemon/kill.go index 2bead8ba1e..06f6314955 100644 --- a/daemon/kill.go +++ b/daemon/kill.go @@ -17,7 +17,7 @@ import ( // for the container to exit. // If a signal is given, then just send it to the container and return. func (daemon *Daemon) ContainerKill(name string, sig uint64) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/list.go b/daemon/list.go index 356515b99a..a0ede7b5b2 100644 --- a/daemon/list.go +++ b/daemon/list.go @@ -162,7 +162,7 @@ func (daemon *Daemon) foldFilter(config *ContainersConfig) (*listContext, error) var beforeContFilter, sinceContFilter *container.Container err = psFilters.WalkValues("before", func(value string) error { - beforeContFilter, err = daemon.Get(value) + beforeContFilter, err = daemon.GetContainer(value) return err }) if err != nil { @@ -170,7 +170,7 @@ func (daemon *Daemon) foldFilter(config *ContainersConfig) (*listContext, error) } err = psFilters.WalkValues("since", func(value string) error { - sinceContFilter, err = daemon.Get(value) + sinceContFilter, err = daemon.GetContainer(value) return err }) if err != nil { @@ -204,14 +204,14 @@ func (daemon *Daemon) foldFilter(config *ContainersConfig) (*listContext, error) }, 1) if config.Before != "" && beforeContFilter == nil { - beforeContFilter, err = daemon.Get(config.Before) + beforeContFilter, err = daemon.GetContainer(config.Before) if err != nil { return nil, err } } if config.Since != "" && sinceContFilter == nil { - sinceContFilter, err = daemon.Get(config.Since) + sinceContFilter, err = daemon.GetContainer(config.Since) if err != nil { return nil, err } diff --git a/daemon/logs.go b/daemon/logs.go index 057bdda73e..b10f7df769 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -33,7 +33,7 @@ type ContainerLogsConfig struct { // ContainerLogs hooks up a container's stdout and stderr streams // configured with the given struct. func (daemon *Daemon) ContainerLogs(containerName string, config *ContainerLogsConfig) error { - container, err := daemon.Get(containerName) + container, err := daemon.GetContainer(containerName) if err != nil { return derr.ErrorCodeNoSuchContainer.WithArgs(containerName) } diff --git a/daemon/network.go b/daemon/network.go index 1b1dc8e166..78459d2808 100644 --- a/daemon/network.go +++ b/daemon/network.go @@ -130,7 +130,7 @@ func getIpamConfig(data []network.IPAMConfig) ([]*libnetwork.IpamConf, []*libnet // network. If either cannot be found, an err is returned. If the // network cannot be set up, an err is returned. func (daemon *Daemon) ConnectContainerToNetwork(containerName, networkName string) error { - container, err := daemon.Get(containerName) + container, err := daemon.GetContainer(containerName) if err != nil { return err } @@ -140,7 +140,7 @@ func (daemon *Daemon) ConnectContainerToNetwork(containerName, networkName strin // DisconnectContainerFromNetwork disconnects the given container from // the given network. If either cannot be found, an err is returned. func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, network libnetwork.Network) error { - container, err := daemon.Get(containerName) + container, err := daemon.GetContainer(containerName) if err != nil { return err } diff --git a/daemon/pause.go b/daemon/pause.go index c602cda8ef..bcf2280e80 100644 --- a/daemon/pause.go +++ b/daemon/pause.go @@ -7,7 +7,7 @@ import ( // ContainerPause pauses a container func (daemon *Daemon) ContainerPause(name string) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/rename.go b/daemon/rename.go index 5fd0e73df4..c09888c234 100644 --- a/daemon/rename.go +++ b/daemon/rename.go @@ -21,7 +21,7 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error { return derr.ErrorCodeEmptyRename } - container, err := daemon.Get(oldName) + container, err := daemon.GetContainer(oldName) if err != nil { return err } diff --git a/daemon/resize.go b/daemon/resize.go index 91592d06eb..f443af0339 100644 --- a/daemon/resize.go +++ b/daemon/resize.go @@ -5,7 +5,7 @@ import derr "github.com/docker/docker/errors" // ContainerResize changes the size of the TTY of the process running // in the container with the given name to the given height and width. func (daemon *Daemon) ContainerResize(name string, height, width int) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/restart.go b/daemon/restart.go index 846ea2440e..8ee16918cb 100644 --- a/daemon/restart.go +++ b/daemon/restart.go @@ -12,7 +12,7 @@ import ( // stop. Returns an error if the container cannot be found, or if // there is an underlying error at any stage of the restart. func (daemon *Daemon) ContainerRestart(name string, seconds int) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/start.go b/daemon/start.go index 54cadeb305..d9b7b8280a 100644 --- a/daemon/start.go +++ b/daemon/start.go @@ -11,7 +11,7 @@ import ( // ContainerStart starts a container. func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConfig) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/stats.go b/daemon/stats.go index ed829c85ef..e2b2420ca4 100644 --- a/daemon/stats.go +++ b/daemon/stats.go @@ -22,7 +22,7 @@ type ContainerStatsConfig struct { // ContainerStats writes information about the container to the stream // given in the config object. func (daemon *Daemon) ContainerStats(prefixOrName string, config *ContainerStatsConfig) error { - container, err := daemon.Get(prefixOrName) + container, err := daemon.GetContainer(prefixOrName) if err != nil { return err } diff --git a/daemon/stop.go b/daemon/stop.go index 14e9ea8689..e59e36cd6a 100644 --- a/daemon/stop.go +++ b/daemon/stop.go @@ -15,7 +15,7 @@ import ( // container is not found, is already stopped, or if there is a // problem stopping the container. func (daemon *Daemon) ContainerStop(name string, seconds int) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/top_unix.go b/daemon/top_unix.go index 36ace121e6..7bee57af2e 100644 --- a/daemon/top_unix.go +++ b/daemon/top_unix.go @@ -21,7 +21,7 @@ func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.Container psArgs = "-ef" } - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return nil, err } diff --git a/daemon/unpause.go b/daemon/unpause.go index 33a980e8e0..dcf7336a28 100644 --- a/daemon/unpause.go +++ b/daemon/unpause.go @@ -7,7 +7,7 @@ import ( // ContainerUnpause unpauses a container func (daemon *Daemon) ContainerUnpause(name string) error { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return err } diff --git a/daemon/volumes.go b/daemon/volumes.go index 7a09327ed1..513c83d3ce 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -87,7 +87,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo return err } - c, err := daemon.Get(containerID) + c, err := daemon.GetContainer(containerID) if err != nil { return err } diff --git a/daemon/wait.go b/daemon/wait.go index e429c46012..52b335cdd7 100644 --- a/daemon/wait.go +++ b/daemon/wait.go @@ -8,7 +8,7 @@ import "time" // timeout, an error is returned. If you want to wait forever, supply // a negative duration for the timeout. func (daemon *Daemon) ContainerWait(name string, timeout time.Duration) (int, error) { - container, err := daemon.Get(name) + container, err := daemon.GetContainer(name) if err != nil { return -1, err }