summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-06-25 08:40:19 -0500
committerbaude <bbaude@redhat.com>2019-06-27 07:56:24 -0500
commit8561b996447793999a6465f9b9e3f0f7bbea2c6a (patch)
tree133cf8d959934eac882535e6b572aee5d0acf3c5 /libpod/container_api.go
parent58a1777f518657ff12744bb69ccf2dab3d429625 (diff)
downloadpodman-8561b996447793999a6465f9b9e3f0f7bbea2c6a.tar.gz
podman-8561b996447793999a6465f9b9e3f0f7bbea2c6a.tar.bz2
podman-8561b996447793999a6465f9b9e3f0f7bbea2c6a.zip
libpod removal from main (phase 2)
this is phase 2 for the removal of libpod from main. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go56
1 files changed, 28 insertions, 28 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index b8c339a39..8d1e5751b 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -37,9 +37,9 @@ func (c *Container) Init(ctx context.Context) (err error) {
}
}
- if !(c.state.State == ContainerStateConfigured ||
- c.state.State == ContainerStateStopped ||
- c.state.State == ContainerStateExited) {
+ if !(c.state.State == define.ContainerStateConfigured ||
+ c.state.State == define.ContainerStateStopped ||
+ c.state.State == define.ContainerStateExited) {
return errors.Wrapf(define.ErrCtrStateInvalid, "container %s has already been created in runtime", c.ID())
}
@@ -55,7 +55,7 @@ func (c *Container) Init(ctx context.Context) (err error) {
return err
}
- if c.state.State == ContainerStateStopped {
+ if c.state.State == define.ContainerStateStopped {
// Reinitialize the container
return c.reinit(ctx, false)
}
@@ -178,14 +178,14 @@ func (c *Container) StopWithTimeout(timeout uint) error {
}
}
- if c.state.State == ContainerStateConfigured ||
- c.state.State == ContainerStateUnknown ||
- c.state.State == ContainerStatePaused {
+ if c.state.State == define.ContainerStateConfigured ||
+ c.state.State == define.ContainerStateUnknown ||
+ c.state.State == define.ContainerStatePaused {
return errors.Wrapf(define.ErrCtrStateInvalid, "can only stop created, running, or stopped containers. %s is in state %s", c.ID(), c.state.State.String())
}
- if c.state.State == ContainerStateStopped ||
- c.state.State == ContainerStateExited {
+ if c.state.State == define.ContainerStateStopped ||
+ c.state.State == define.ContainerStateExited {
return define.ErrCtrStopped
}
defer c.newContainerEvent(events.Stop)
@@ -203,7 +203,7 @@ func (c *Container) Kill(signal uint) error {
}
}
- if c.state.State != ContainerStateRunning {
+ if c.state.State != define.ContainerStateRunning {
return errors.Wrapf(define.ErrCtrStateInvalid, "can only kill running containers. %s is in state %s", c.ID(), c.state.State.String())
}
@@ -241,7 +241,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir
conState := c.state.State
// TODO can probably relax this once we track exec sessions
- if conState != ContainerStateRunning {
+ if conState != define.ContainerStateRunning {
return errors.Wrapf(define.ErrCtrStateInvalid, "cannot exec into container that is not running")
}
if privileged || c.config.Privileged {
@@ -399,9 +399,9 @@ func (c *Container) Attach(streams *AttachStreams, keys string, resize <-chan re
c.lock.Unlock()
}
- if c.state.State != ContainerStateCreated &&
- c.state.State != ContainerStateRunning &&
- c.state.State != ContainerStateExited {
+ if c.state.State != define.ContainerStateCreated &&
+ c.state.State != define.ContainerStateRunning &&
+ c.state.State != define.ContainerStateExited {
return errors.Wrapf(define.ErrCtrStateInvalid, "can only attach to created or running containers")
}
defer c.newContainerEvent(events.Attach)
@@ -440,7 +440,7 @@ func (c *Container) Unmount(force bool) error {
return errors.Wrapf(err, "can't determine how many times %s is mounted, refusing to unmount", c.ID())
}
if mounted == 1 {
- if c.state.State == ContainerStateRunning || c.state.State == ContainerStatePaused {
+ if c.state.State == define.ContainerStateRunning || c.state.State == define.ContainerStatePaused {
return errors.Wrapf(define.ErrCtrStateInvalid, "cannot unmount storage for container %s as it is running or paused", c.ID())
}
if len(c.state.ExecSessions) != 0 {
@@ -464,10 +464,10 @@ func (c *Container) Pause() error {
}
}
- if c.state.State == ContainerStatePaused {
+ if c.state.State == define.ContainerStatePaused {
return errors.Wrapf(define.ErrCtrStateInvalid, "%q is already paused", c.ID())
}
- if c.state.State != ContainerStateRunning {
+ if c.state.State != define.ContainerStateRunning {
return errors.Wrapf(define.ErrCtrStateInvalid, "%q is not running, can't pause", c.state.State)
}
defer c.newContainerEvent(events.Pause)
@@ -485,7 +485,7 @@ func (c *Container) Unpause() error {
}
}
- if c.state.State != ContainerStatePaused {
+ if c.state.State != define.ContainerStatePaused {
return errors.Wrapf(define.ErrCtrStateInvalid, "%q is not paused, can't unpause", c.ID())
}
defer c.newContainerEvent(events.Unpause)
@@ -578,7 +578,7 @@ func (c *Container) Cleanup(ctx context.Context) error {
}
// Check if state is good
- if c.state.State == ContainerStateRunning || c.state.State == ContainerStatePaused {
+ if c.state.State == define.ContainerStateRunning || c.state.State == define.ContainerStatePaused {
return errors.Wrapf(define.ErrCtrStateInvalid, "container %s is running or paused, refusing to clean up", c.ID())
}
@@ -656,9 +656,9 @@ func (c *Container) Sync() error {
// If runtime knows about the container, update its status in runtime
// And then save back to disk
- if (c.state.State != ContainerStateUnknown) &&
- (c.state.State != ContainerStateConfigured) &&
- (c.state.State != ContainerStateExited) {
+ if (c.state.State != define.ContainerStateUnknown) &&
+ (c.state.State != define.ContainerStateConfigured) &&
+ (c.state.State != define.ContainerStateExited) {
oldState := c.state.State
if err := c.ociRuntime.updateContainerStatus(c, true); err != nil {
return err
@@ -687,27 +687,27 @@ func (c *Container) Refresh(ctx context.Context) error {
}
wasCreated := false
- if c.state.State == ContainerStateCreated {
+ if c.state.State == define.ContainerStateCreated {
wasCreated = true
}
wasRunning := false
- if c.state.State == ContainerStateRunning {
+ if c.state.State == define.ContainerStateRunning {
wasRunning = true
}
wasPaused := false
- if c.state.State == ContainerStatePaused {
+ if c.state.State == define.ContainerStatePaused {
wasPaused = true
}
// First, unpause the container if it's paused
- if c.state.State == ContainerStatePaused {
+ if c.state.State == define.ContainerStatePaused {
if err := c.unpause(); err != nil {
return err
}
}
// Next, if the container is running, stop it
- if c.state.State == ContainerStateRunning {
+ if c.state.State == define.ContainerStateRunning {
if err := c.stop(c.config.StopTimeout); err != nil {
return err
}
@@ -724,7 +724,7 @@ func (c *Container) Refresh(ctx context.Context) error {
// If the container is in ContainerStateStopped, we need to delete it
// from the runtime and clear conmon state
- if c.state.State == ContainerStateStopped {
+ if c.state.State == define.ContainerStateStopped {
if err := c.delete(ctx); err != nil {
return err
}