summaryrefslogtreecommitdiff
path: root/pkg/domain/entities/pods.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-27 16:15:09 +0200
committerGitHub <noreply@github.com>2020-04-27 16:15:09 +0200
commitca1c674d2e027b563c3e9fd92c335eb3f5e5e05d (patch)
tree00dbd2d1590ed9f7fa59531dae3d1f63fdcbf014 /pkg/domain/entities/pods.go
parentfdf64f0c66be4569732b830ce60c98f98a7efe64 (diff)
parent7ee0f7e14c3105be1ef9c8aee00a09b479303677 (diff)
downloadpodman-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/domain/entities/pods.go')
-rw-r--r--pkg/domain/entities/pods.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go
index aa1445a6a..a4896ce4d 100644
--- a/pkg/domain/entities/pods.go
+++ b/pkg/domain/entities/pods.go
@@ -1,6 +1,7 @@
package entities
import (
+ "errors"
"strings"
"time"
@@ -188,3 +189,50 @@ type PodInspectOptions struct {
type PodInspectReport struct {
*define.InspectPodData
}
+
+// PodStatsOptions are options for the pod stats command.
+type PodStatsOptions struct {
+ // All - provide stats for all running pods.
+ All bool
+ // Latest - provide stats for the latest pod.
+ Latest bool
+}
+
+// PodStatsReport includes pod-resource statistics data.
+type PodStatsReport struct {
+ CPU string
+ MemUsage string
+ Mem string
+ NetIO string
+ BlockIO string
+ PIDS string
+ Pod string
+ CID string
+ Name string
+}
+
+// ValidatePodStatsOptions validates the specified slice and options. Allows
+// for sharing code in the front- and the back-end.
+func ValidatePodStatsOptions(args []string, options *PodStatsOptions) error {
+ num := 0
+ if len(args) > 0 {
+ num++
+ }
+ if options.All {
+ num++
+ }
+ if options.Latest {
+ num++
+ }
+ switch num {
+ case 0:
+ // Podman v1 compat: if nothing's specified get all running
+ // pods.
+ options.All = true
+ return nil
+ case 1:
+ return nil
+ default:
+ return errors.New("--all, --latest and arguments cannot be used together")
+ }
+}