Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit cf1be96

Browse files
authored
Merge pull request #99 from docker/feat-stop
Add `Stop` command on the gRPC side.
2 parents f0f8e95 + a0dda2d commit cf1be96

File tree

12 files changed

+576
-371
lines changed

12 files changed

+576
-371
lines changed

azure/backend.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
"github.com/docker/api/context/cloud"
12+
"github.com/docker/api/errdefs"
1213

1314
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
1415
"github.com/compose-spec/compose-go/types"
@@ -101,7 +102,7 @@ type aciContainerService struct {
101102
ctx store.AciContext
102103
}
103104

104-
func (cs *aciContainerService) List(ctx context.Context) ([]containers.Container, error) {
105+
func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.Container, error) {
105106
var containerGroups []containerinstance.ContainerGroup
106107
result, err := cs.containerGroupsClient.ListByResourceGroup(ctx, cs.ctx.ResourceGroup)
107108
if err != nil {
@@ -177,6 +178,10 @@ func (cs *aciContainerService) Run(ctx context.Context, r containers.ContainerCo
177178
return createACIContainers(ctx, cs.ctx, groupDefinition)
178179
}
179180

181+
func (cs *aciContainerService) Stop(ctx context.Context, containerName string, timeout *uint32) error {
182+
return errdefs.ErrNotImplemented
183+
}
184+
180185
func getGroupAndContainerName(containerID string) (groupName string, containerName string) {
181186
tokens := strings.Split(containerID, "_")
182187
groupName = tokens[0]

cli/cmd/ps.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
type psOpts struct {
18+
all bool
1819
quiet bool
1920
}
2021

@@ -30,6 +31,7 @@ func PsCommand() *cobra.Command {
3031
}
3132

3233
cmd.Flags().BoolVarP(&opts.quiet, "quiet", "q", false, "Only display IDs")
34+
cmd.Flags().BoolVarP(&opts.all, "all", "a", false, "Show all containers (default shows just running)")
3335

3436
return cmd
3537
}
@@ -40,7 +42,7 @@ func runPs(ctx context.Context, opts psOpts) error {
4042
return errors.Wrap(err, "cannot connect to backend")
4143
}
4244

43-
containers, err := c.ContainerService().List(ctx)
45+
containers, err := c.ContainerService().List(ctx, opts.all)
4446
if err != nil {
4547
return errors.Wrap(err, "fetch containers")
4648
}

containers/api.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ type LogsRequest struct {
5454
// Service interacts with the underlying container backend
5555
type Service interface {
5656
// List returns all the containers
57-
List(ctx context.Context) ([]Container, error)
57+
List(ctx context.Context, all bool) ([]Container, error)
58+
// Stop stops the running container
59+
Stop(ctx context.Context, containerID string, timeout *uint32) error
5860
// Run creates and starts a container
5961
Run(ctx context.Context, config ContainerConfig) error
6062
// Exec executes a command inside a running container

0 commit comments

Comments
 (0)