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

Commit

Permalink
Merge pull request #99 from docker/feat-stop
Browse files Browse the repository at this point in the history
Add `Stop` command on the gRPC side.
  • Loading branch information
rumpl authored May 18, 2020
2 parents f0f8e95 + a0dda2d commit cf1be96
Show file tree
Hide file tree
Showing 12 changed files with 576 additions and 371 deletions.
7 changes: 6 additions & 1 deletion azure/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/docker/api/context/cloud"
"github.com/docker/api/errdefs"

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

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

func (cs *aciContainerService) Stop(ctx context.Context, containerName string, timeout *uint32) error {
return errdefs.ErrNotImplemented
}

func getGroupAndContainerName(containerID string) (groupName string, containerName string) {
tokens := strings.Split(containerID, "_")
groupName = tokens[0]
Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

type psOpts struct {
all bool
quiet bool
}

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

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

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

containers, err := c.ContainerService().List(ctx)
containers, err := c.ContainerService().List(ctx, opts.all)
if err != nil {
return errors.Wrap(err, "fetch containers")
}
Expand Down
4 changes: 3 additions & 1 deletion containers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ type LogsRequest struct {
// Service interacts with the underlying container backend
type Service interface {
// List returns all the containers
List(ctx context.Context) ([]Container, error)
List(ctx context.Context, all bool) ([]Container, error)
// Stop stops the running container
Stop(ctx context.Context, containerID string, timeout *uint32) error
// Run creates and starts a container
Run(ctx context.Context, config ContainerConfig) error
// Exec executes a command inside a running container
Expand Down
Loading

0 comments on commit cf1be96

Please sign in to comment.