Rename ContainerState to ContainerStatus

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
This commit is contained in:
Matthew Heon
2018-01-18 11:46:10 -05:00
parent 64d2190ec1
commit 4f2bf5ba1c
4 changed files with 20 additions and 16 deletions

View File

@ -15,28 +15,26 @@ import (
"github.com/ulule/deepcopier" "github.com/ulule/deepcopier"
) )
// ContainerState represents the current state of a container // ContainerStatus represents the current state of a container
type ContainerState int type ContainerStatus int
const ( const (
// ContainerStateUnknown indicates that the container is in an error // ContainerStateUnknown indicates that the container is in an error
// state where information about it cannot be retrieved // state where information about it cannot be retrieved
ContainerStateUnknown ContainerState = iota ContainerStateUnknown ContainerStatus = iota
// ContainerStateConfigured indicates that the container has had its // ContainerStateConfigured indicates that the container has had its
// storage configured but it has not been created in the OCI runtime // storage configured but it has not been created in the OCI runtime
ContainerStateConfigured ContainerState = iota ContainerStateConfigured ContainerStatus = iota
// ContainerStateCreated indicates the container has been created in // ContainerStateCreated indicates the container has been created in
// the OCI runtime but not started // the OCI runtime but not started
ContainerStateCreated ContainerState = iota ContainerStateCreated ContainerStatus = iota
// ContainerStateRunning indicates the container is currently executing // ContainerStateRunning indicates the container is currently executing
ContainerStateRunning ContainerState = iota ContainerStateRunning ContainerStatus = iota
// ContainerStateStopped indicates that the container was running but has // ContainerStateStopped indicates that the container was running but has
// exited // exited
ContainerStateStopped ContainerState = iota ContainerStateStopped ContainerStatus = iota
// ContainerStatePaused indicates that the container has been paused // ContainerStatePaused indicates that the container has been paused
ContainerStatePaused ContainerState = iota ContainerStatePaused ContainerStatus = iota
// name of the directory holding the artifacts
artifactsDir = "artifacts"
) )
// CgroupParent is the default prefix to a cgroup path in libpod // CgroupParent is the default prefix to a cgroup path in libpod
@ -115,7 +113,7 @@ type Container struct {
// It is stored on disk in a tmpfs and recreated on reboot // It is stored on disk in a tmpfs and recreated on reboot
type containerRuntimeInfo struct { type containerRuntimeInfo struct {
// The current state of the running container // The current state of the running container
State ContainerState `json:"state"` State ContainerStatus `json:"state"`
// The path to the JSON OCI runtime spec for this container // The path to the JSON OCI runtime spec for this container
ConfigPath string `json:"configPath,omitempty"` ConfigPath string `json:"configPath,omitempty"`
// RunDir is a per-boot directory for container content // RunDir is a per-boot directory for container content
@ -242,9 +240,9 @@ type ContainerConfig struct {
// TODO log options - logpath for plaintext, others for log drivers // TODO log options - logpath for plaintext, others for log drivers
} }
// ContainerStater returns a string representation for users // ContainerStatus returns a string representation for users
// of a container state // of a container state
func (t ContainerState) String() string { func (t ContainerStatus) String() string {
switch t { switch t {
case ContainerStateUnknown: case ContainerStateUnknown:
return "unknown" return "unknown"
@ -449,7 +447,7 @@ func (c *Container) FinishedTime() (time.Time, error) {
} }
// State returns the current state of the container // State returns the current state of the container
func (c *Container) State() (ContainerState, error) { func (c *Container) State() (ContainerStatus, error) {
if !c.locked { if !c.locked {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()

View File

@ -22,6 +22,12 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
const (
// name of the directory holding the artifacts
artifactsDir = "artifacts"
)
// rootFsSize gets the size of the container's root filesystem // rootFsSize gets the size of the container's root filesystem
// A container FS is split into two parts. The first is the top layer, a // A container FS is split into two parts. The first is the top layer, a
// mutable layer, and the rest is the RootFS: the set of immutable layers // mutable layer, and the rest is the RootFS: the set of immutable layers

View File

@ -528,7 +528,7 @@ func (s *SQLState) UpdateContainer(ctr *Container) error {
} }
newState := new(containerRuntimeInfo) newState := new(containerRuntimeInfo)
newState.State = ContainerState(state) newState.State = ContainerStatus(state)
newState.ConfigPath = configPath newState.ConfigPath = configPath
newState.RunDir = runDir newState.RunDir = runDir
newState.Mountpoint = mountpoint newState.Mountpoint = mountpoint

View File

@ -502,7 +502,7 @@ func (s *SQLState) ctrFromScannable(row scannable) (*Container, error) {
ctr.config.StopTimeout = stopTimeout ctr.config.StopTimeout = stopTimeout
ctr.config.CgroupParent = cgroupParent ctr.config.CgroupParent = cgroupParent
ctr.state.State = ContainerState(state) ctr.state.State = ContainerStatus(state)
ctr.state.ConfigPath = configPath ctr.state.ConfigPath = configPath
ctr.state.RunDir = runDir ctr.state.RunDir = runDir
ctr.state.Mountpoint = mountpoint ctr.state.Mountpoint = mountpoint