1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Rename Daemon.Get to Daemon.GetContainer.

This is more aligned with `Daemon.GetImage` and less confusing.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2015-12-11 12:39:28 -05:00
parent 5525593a68
commit d7d512bb92
30 changed files with 57 additions and 57 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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")
}

View file

@ -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])
}

View file

@ -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
}

View file

@ -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)

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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)
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}