From 9812804f754120fcf14256bf0ed9cd00c36bf9f7 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Fri, 27 Mar 2020 11:46:33 +0100 Subject: podmanv2: implement pod top Implement `podman pod top` for podmanV2. Signed-off-by: Valentin Rothberg --- pkg/domain/infra/tunnel/pods.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pkg/domain/infra/tunnel') diff --git a/pkg/domain/infra/tunnel/pods.go b/pkg/domain/infra/tunnel/pods.go index 4894874e5..9561a9807 100644 --- a/pkg/domain/infra/tunnel/pods.go +++ b/pkg/domain/infra/tunnel/pods.go @@ -6,6 +6,7 @@ import ( "github.com/containers/libpod/pkg/bindings/pods" "github.com/containers/libpod/pkg/domain/entities" "github.com/containers/libpod/pkg/specgen" + "github.com/pkg/errors" ) func (ic *ContainerEngine) PodExists(ctx context.Context, nameOrId string) (*entities.BoolReport, error) { @@ -177,3 +178,18 @@ func (ic *ContainerEngine) PodCreate(ctx context.Context, opts entities.PodCreat opts.ToPodSpecGen(podSpec) return pods.CreatePodFromSpec(ic.ClientCxt, podSpec) } + +func (ic *ContainerEngine) PodTop(ctx context.Context, options entities.PodTopOptions) (*entities.StringSliceReport, error) { + switch { + case options.Latest: + return nil, errors.New("latest is not supported") + case options.NameOrID == "": + return nil, errors.New("NameOrID must be specified") + } + + topOutput, err := pods.Top(ic.ClientCxt, options.NameOrID, options.Descriptors) + if err != nil { + return nil, err + } + return &entities.StringSliceReport{Value: topOutput}, nil +} -- cgit v1.2.3-54-g00ecf