diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-27 16:15:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 16:15:09 +0200 |
commit | ca1c674d2e027b563c3e9fd92c335eb3f5e5e05d (patch) | |
tree | 00dbd2d1590ed9f7fa59531dae3d1f63fdcbf014 /pkg/bindings/pods/pods.go | |
parent | fdf64f0c66be4569732b830ce60c98f98a7efe64 (diff) | |
parent | 7ee0f7e14c3105be1ef9c8aee00a09b479303677 (diff) | |
download | podman-ca1c674d2e027b563c3e9fd92c335eb3f5e5e05d.tar.gz podman-ca1c674d2e027b563c3e9fd92c335eb3f5e5e05d.tar.bz2 podman-ca1c674d2e027b563c3e9fd92c335eb3f5e5e05d.zip |
Merge pull request #5966 from vrothberg/v2-pod-stats
implement pod stats
Diffstat (limited to 'pkg/bindings/pods/pods.go')
-rw-r--r-- | pkg/bindings/pods/pods.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/pkg/bindings/pods/pods.go b/pkg/bindings/pods/pods.go index 3c60fa2a0..b213c8c73 100644 --- a/pkg/bindings/pods/pods.go +++ b/pkg/bindings/pods/pods.go @@ -2,6 +2,7 @@ package pods import ( "context" + "errors" "net/http" "net/url" "strconv" @@ -189,11 +190,6 @@ func Start(ctx context.Context, nameOrID string) (*entities.PodStartReport, erro return &report, response.Process(&report) } -func Stats() error { - // TODO - return bindings.ErrNotImplemented -} - // Stop stops all containers in a Pod. The optional timeout parameter can be // used to override the timeout before the container is killed. func Stop(ctx context.Context, nameOrID string, timeout *int) (*entities.PodStopReport, error) { @@ -264,3 +260,26 @@ func Unpause(ctx context.Context, nameOrID string) (*entities.PodUnpauseReport, } return &report, response.Process(&report) } + +// Stats display resource-usage statistics of one or more pods. +func Stats(ctx context.Context, namesOrIDs []string, options entities.PodStatsOptions) ([]*entities.PodStatsReport, error) { + if options.Latest { + return nil, errors.New("latest is not supported") + } + conn, err := bindings.GetClient(ctx) + if err != nil { + return nil, err + } + params := url.Values{} + for _, i := range namesOrIDs { + params.Add("namesOrIDs", i) + } + params.Set("all", strconv.FormatBool(options.All)) + + var reports []*entities.PodStatsReport + response, err := conn.DoRequest(nil, http.MethodGet, "/pods/stats", params) + if err != nil { + return nil, err + } + return reports, response.Process(&reports) +} |