Merge pull request #94 from rakyll/remove-type
runtime: remove unnecessary intermediate type, Status
This commit is contained in:
commit
c29728a9b0
5 changed files with 11 additions and 20 deletions
|
@ -201,7 +201,7 @@ func (s *apiServer) State(ctx context.Context, r *types.StateRequest) (*types.St
|
|||
Id: c.ID(),
|
||||
BundlePath: c.Path(),
|
||||
Processes: procs,
|
||||
Status: string(c.State().Status),
|
||||
Status: string(c.State()),
|
||||
})
|
||||
}
|
||||
return state, nil
|
||||
|
@ -213,9 +213,7 @@ func (s *apiServer) UpdateContainer(ctx context.Context, r *types.UpdateContaine
|
|||
if r.Signal != 0 {
|
||||
e.Signal = syscall.Signal(r.Signal)
|
||||
}
|
||||
e.State = &runtime.State{
|
||||
Status: runtime.Status(r.Status),
|
||||
}
|
||||
e.State = runtime.State(r.Status)
|
||||
s.sv.SendEvent(e)
|
||||
if err := <-e.Err; err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -289,19 +289,16 @@ func (c *libcontainerContainer) Pause() error {
|
|||
}
|
||||
|
||||
func (c *libcontainerContainer) State() runtime.State {
|
||||
s := runtime.State{}
|
||||
// TODO: what to do with error
|
||||
state, err := c.c.Status()
|
||||
if err != nil {
|
||||
return s
|
||||
return runtime.State("")
|
||||
}
|
||||
switch state {
|
||||
case libcontainer.Paused, libcontainer.Pausing:
|
||||
s.Status = runtime.Paused
|
||||
default:
|
||||
s.Status = runtime.Running
|
||||
return runtime.Paused
|
||||
}
|
||||
return s
|
||||
return runtime.State("")
|
||||
}
|
||||
|
||||
func (c *libcontainerContainer) ID() string {
|
||||
|
|
|
@ -15,17 +15,13 @@ type Process interface {
|
|||
Signal(os.Signal) error
|
||||
}
|
||||
|
||||
type Status string
|
||||
type State string
|
||||
|
||||
const (
|
||||
Paused Status = "paused"
|
||||
Running Status = "running"
|
||||
Paused = State("paused")
|
||||
Running = State("running")
|
||||
)
|
||||
|
||||
type State struct {
|
||||
Status Status
|
||||
}
|
||||
|
||||
type Console interface {
|
||||
io.ReadWriter
|
||||
io.Closer
|
||||
|
|
|
@ -52,7 +52,7 @@ type Event struct {
|
|||
Status int
|
||||
Signal os.Signal
|
||||
Process *specs.Process
|
||||
State *runtime.State
|
||||
State runtime.State
|
||||
Containers []runtime.Container
|
||||
Checkpoint *runtime.Checkpoint
|
||||
Err chan error
|
||||
|
|
|
@ -12,8 +12,8 @@ func (h *UpdateEvent) Handle(e *Event) error {
|
|||
return ErrContainerNotFound
|
||||
}
|
||||
container := i.container
|
||||
if e.State.Status != "" {
|
||||
switch e.State.Status {
|
||||
if e.State != "" {
|
||||
switch e.State {
|
||||
case runtime.Running:
|
||||
if err := container.Resume(); err != nil {
|
||||
return ErrUnknownContainerStatus
|
||||
|
|
Loading…
Reference in a new issue