diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2021-08-04 09:56:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 09:56:57 +0000 |
commit | 3a922cbc99f49b996c0379a9ec90ccc47a325018 (patch) | |
tree | dab0fdf142508614c6b17cc0d277ae91c58d756a /pkg/bindings | |
parent | 1bc8c94409c1c9dc47b4569833af534beba9333f (diff) | |
parent | 34b28d95986a08bdd74dd89ce6647458cda75731 (diff) | |
download | podman-3a922cbc99f49b996c0379a9ec90ccc47a325018.tar.gz podman-3a922cbc99f49b996c0379a9ec90ccc47a325018.tar.bz2 podman-3a922cbc99f49b996c0379a9ec90ccc47a325018.zip |
Merge pull request #11003 from pascomnet/f_stats
stats: add a interval parameter to cli and api stats streaming
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/containers/containers.go | 3 | ||||
-rw-r--r-- | pkg/bindings/containers/types.go | 3 | ||||
-rw-r--r-- | pkg/bindings/containers/types_stats_options.go | 16 |
3 files changed, 21 insertions, 1 deletions
diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go index 86304f392..bc7b0c8c9 100644 --- a/pkg/bindings/containers/containers.go +++ b/pkg/bindings/containers/containers.go @@ -223,6 +223,9 @@ func Stats(ctx context.Context, containers []string, options *StatsOptions) (cha if err != nil { return nil, err } + if !response.IsSuccess() { + return nil, response.Process(nil) + } statsChan := make(chan entities.ContainerStatsReport) diff --git a/pkg/bindings/containers/types.go b/pkg/bindings/containers/types.go index cf088441f..3e9a384de 100644 --- a/pkg/bindings/containers/types.go +++ b/pkg/bindings/containers/types.go @@ -166,7 +166,8 @@ type StartOptions struct { //go:generate go run ../generator/generator.go StatsOptions // StatsOptions are optional options for getting stats on containers type StatsOptions struct { - Stream *bool + Stream *bool + Interval *int } //go:generate go run ../generator/generator.go TopOptions diff --git a/pkg/bindings/containers/types_stats_options.go b/pkg/bindings/containers/types_stats_options.go index 8f6a03301..604004eb6 100644 --- a/pkg/bindings/containers/types_stats_options.go +++ b/pkg/bindings/containers/types_stats_options.go @@ -35,3 +35,19 @@ func (o *StatsOptions) GetStream() bool { } return *o.Stream } + +// WithInterval +func (o *StatsOptions) WithInterval(value int) *StatsOptions { + v := &value + o.Interval = v + return o +} + +// GetInterval +func (o *StatsOptions) GetInterval() int { + var interval int + if o.Interval == nil { + return interval + } + return *o.Interval +} |