Skip to content

Commit 1672191

Browse files
committed
runtime: remove unnecessary intermediate type, Status
Signed-off-by: Burcu Dogan <[email protected]>
1 parent 1ade1f6 commit 1672191

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

api/grpc/server/server.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (s *apiServer) State(ctx context.Context, r *types.StateRequest) (*types.St
201201
Id: c.ID(),
202202
BundlePath: c.Path(),
203203
Processes: procs,
204-
Status: string(c.State().Status),
204+
Status: string(c.State()),
205205
})
206206
}
207207
return state, nil
@@ -213,9 +213,7 @@ func (s *apiServer) UpdateContainer(ctx context.Context, r *types.UpdateContaine
213213
if r.Signal != 0 {
214214
e.Signal = syscall.Signal(r.Signal)
215215
}
216-
e.State = &runtime.State{
217-
Status: runtime.Status(r.Status),
218-
}
216+
e.State = runtime.State(r.Status)
219217
s.sv.SendEvent(e)
220218
if err := <-e.Err; err != nil {
221219
return nil, err

linux/linux.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,19 +289,16 @@ func (c *libcontainerContainer) Pause() error {
289289
}
290290

291291
func (c *libcontainerContainer) State() runtime.State {
292-
s := runtime.State{}
293292
// TODO: what to do with error
294293
state, err := c.c.Status()
295294
if err != nil {
296-
return s
295+
return runtime.State("")
297296
}
298297
switch state {
299298
case libcontainer.Paused, libcontainer.Pausing:
300-
s.Status = runtime.Paused
301-
default:
302-
s.Status = runtime.Running
299+
return runtime.Paused
303300
}
304-
return s
301+
return runtime.State("")
305302
}
306303

307304
func (c *libcontainerContainer) ID() string {

runtime/container.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@ type Process interface {
1515
Signal(os.Signal) error
1616
}
1717

18-
type Status string
18+
type State string
1919

2020
const (
21-
Paused Status = "paused"
22-
Running Status = "running"
21+
Paused = State("paused")
22+
Running = State("running")
2323
)
2424

25-
type State struct {
26-
Status Status
27-
}
28-
2925
type Console interface {
3026
io.ReadWriter
3127
io.Closer

supervisor/event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type Event struct {
5252
Status int
5353
Signal os.Signal
5454
Process *specs.Process
55-
State *runtime.State
55+
State runtime.State
5656
Containers []runtime.Container
5757
Checkpoint *runtime.Checkpoint
5858
Err chan error

supervisor/update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ func (h *UpdateEvent) Handle(e *Event) error {
1212
return ErrContainerNotFound
1313
}
1414
container := i.container
15-
if e.State.Status != "" {
16-
switch e.State.Status {
15+
if e.State != "" {
16+
switch e.State {
1717
case runtime.Running:
1818
if err := container.Resume(); err != nil {
1919
return ErrUnknownContainerStatus

0 commit comments

Comments
 (0)