summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-01-25 23:23:39 -0800
committerGitHub <noreply@github.com>2020-01-25 23:23:39 -0800
commitd07f611885311538895fe5b665dccf75d1448fc3 (patch)
treec308c5445220b675567d67e0e3c296d31b90528d /cmd
parent689da532fa8f9c72d4fd7afe963d6eb44fe0e623 (diff)
parent5da70b04dd95263a536cc148288d2e20cd9dea30 (diff)
downloadpodman-d07f611885311538895fe5b665dccf75d1448fc3.tar.gz
podman-d07f611885311538895fe5b665dccf75d1448fc3.tar.bz2
podman-d07f611885311538895fe5b665dccf75d1448fc3.zip
Merge pull request #4965 from baude/reviewcorrections3
APIv2 review corrections #3
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/shared/pod.go56
1 files changed, 25 insertions, 31 deletions
diff --git a/cmd/podman/shared/pod.go b/cmd/podman/shared/pod.go
index d8d69c8fc..7b0b497fc 100644
--- a/cmd/podman/shared/pod.go
+++ b/cmd/podman/shared/pod.go
@@ -10,14 +10,8 @@ import (
"github.com/pkg/errors"
)
-const (
- PodStateStopped = "Stopped"
- PodStateRunning = "Running"
- PodStatePaused = "Paused"
- PodStateExited = "Exited"
- PodStateErrored = "Error"
- PodStateCreated = "Created"
-)
+// TODO GetPodStatus and CreatePodStatusResults should removed once the adapter
+// and shared packages are reworked. It has now been duplicated in libpod proper.
// GetPodStatus determines the status of the pod based on the
// statuses of the containers in the pod.
@@ -25,7 +19,7 @@ const (
func GetPodStatus(pod *libpod.Pod) (string, error) {
ctrStatuses, err := pod.Status()
if err != nil {
- return PodStateErrored, err
+ return define.PodStateErrored, err
}
return CreatePodStatusResults(ctrStatuses)
}
@@ -33,45 +27,45 @@ func GetPodStatus(pod *libpod.Pod) (string, error) {
func CreatePodStatusResults(ctrStatuses map[string]define.ContainerStatus) (string, error) {
ctrNum := len(ctrStatuses)
if ctrNum == 0 {
- return PodStateCreated, nil
+ return define.PodStateCreated, nil
}
statuses := map[string]int{
- PodStateStopped: 0,
- PodStateRunning: 0,
- PodStatePaused: 0,
- PodStateCreated: 0,
- PodStateErrored: 0,
+ define.PodStateStopped: 0,
+ define.PodStateRunning: 0,
+ define.PodStatePaused: 0,
+ define.PodStateCreated: 0,
+ define.PodStateErrored: 0,
}
for _, ctrStatus := range ctrStatuses {
switch ctrStatus {
case define.ContainerStateExited:
fallthrough
case define.ContainerStateStopped:
- statuses[PodStateStopped]++
+ statuses[define.PodStateStopped]++
case define.ContainerStateRunning:
- statuses[PodStateRunning]++
+ statuses[define.PodStateRunning]++
case define.ContainerStatePaused:
- statuses[PodStatePaused]++
+ statuses[define.PodStatePaused]++
case define.ContainerStateCreated, define.ContainerStateConfigured:
- statuses[PodStateCreated]++
+ statuses[define.PodStateCreated]++
default:
- statuses[PodStateErrored]++
+ statuses[define.PodStateErrored]++
}
}
switch {
- case statuses[PodStateRunning] > 0:
- return PodStateRunning, nil
- case statuses[PodStatePaused] == ctrNum:
- return PodStatePaused, nil
- case statuses[PodStateStopped] == ctrNum:
- return PodStateExited, nil
- case statuses[PodStateStopped] > 0:
- return PodStateStopped, nil
- case statuses[PodStateErrored] > 0:
- return PodStateErrored, nil
+ case statuses[define.PodStateRunning] > 0:
+ return define.PodStateRunning, nil
+ case statuses[define.PodStatePaused] == ctrNum:
+ return define.PodStatePaused, nil
+ case statuses[define.PodStateStopped] == ctrNum:
+ return define.PodStateExited, nil
+ case statuses[define.PodStateStopped] > 0:
+ return define.PodStateStopped, nil
+ case statuses[define.PodStateErrored] > 0:
+ return define.PodStateErrored, nil
default:
- return PodStateCreated, nil
+ return define.PodStateCreated, nil
}
}