Skip to content

Commit

Permalink
feat: container un/pause and restart
Browse files Browse the repository at this point in the history
Signed-off-by: thediveo <[email protected]>
  • Loading branch information
thediveo committed Jun 24, 2024
1 parent 8c73f2a commit d03d65e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
42 changes: 42 additions & 0 deletions client_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,24 @@ func newWrappedClient(ctrl *mock.Controller, wrapped moby.Client, withouts []str
return wrapped.ContainerList(ctx, options)
})
}
if !slices.Contains(withouts, "ContainerPause") {
rec.ContainerPause(Any, Any).AnyTimes().
DoAndReturn(func(ctx context.Context, containerID string) error {
return wrapped.ContainerPause(ctx, containerID)
})
}
if !slices.Contains(withouts, "ContainerRemove") {
rec.ContainerRemove(Any, Any, Any).AnyTimes().
DoAndReturn(func(ctx context.Context, containerID string, options container.RemoveOptions) error {
return wrapped.ContainerRemove(ctx, containerID, options)
})
}
if !slices.Contains(withouts, "ContainerRestart") {
rec.ContainerRestart(Any, Any, Any).AnyTimes().
DoAndReturn(func(ctx context.Context, containerID string, options container.StopOptions) error {
return wrapped.ContainerRestart(ctx, containerID, options)
})
}
if !slices.Contains(withouts, "ContainerStart") {
rec.ContainerStart(Any, Any, Any).AnyTimes().
DoAndReturn(func(ctx context.Context, containerID string, options container.StartOptions) error {
Expand All @@ -104,6 +116,12 @@ func newWrappedClient(ctrl *mock.Controller, wrapped moby.Client, withouts []str
return wrapped.ContainerStop(ctx, containerID, options)
})
}
if !slices.Contains(withouts, "ContainerUnpause") {
rec.ContainerUnpause(Any, Any).AnyTimes().
DoAndReturn(func(ctx context.Context, containerID string) error {
return wrapped.ContainerUnpause(ctx, containerID)
})
}
if !slices.Contains(withouts, "ContainerWait") {
rec.ContainerWait(Any, Any, Any).AnyTimes().
DoAndReturn(func(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) {
Expand Down
3 changes: 3 additions & 0 deletions moby/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ type Client interface {
ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
ContainerKill(ctx context.Context, containerID, signal string) error
ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
ContainerPause(ctx context.Context, containerID string) error
ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
ContainerRestart(ctx context.Context, containerID string, options container.StopOptions) error
ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
ContainerUnpause(ctx context.Context, containerID string) error
ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)

ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
Expand Down

0 comments on commit d03d65e

Please sign in to comment.