summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-01-23 11:12:36 -0800
committerGitHub <noreply@github.com>2020-01-23 11:12:36 -0800
commit5bad873c4cd9fab9112e1d84ba376d47073cc8bb (patch)
treeec76af6eb70bebd52e861273228215480df0cbc2 /pkg/api/handlers/libpod
parent8beeb067aac857deb29e91562cf4b6f068fe0328 (diff)
parentcf7be58b2c160e2e1df737015c913fc1aff1dbe8 (diff)
downloadpodman-5bad873c4cd9fab9112e1d84ba376d47073cc8bb.tar.gz
podman-5bad873c4cd9fab9112e1d84ba376d47073cc8bb.tar.bz2
podman-5bad873c4cd9fab9112e1d84ba376d47073cc8bb.zip
Merge pull request #4953 from baude/reviewcorrections2
Review corrections pass #2
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r--pkg/api/handlers/libpod/containers.go42
1 files changed, 25 insertions, 17 deletions
diff --git a/pkg/api/handlers/libpod/containers.go b/pkg/api/handlers/libpod/containers.go
index e16a4ea1f..df16843c7 100644
--- a/pkg/api/handlers/libpod/containers.go
+++ b/pkg/api/handlers/libpod/containers.go
@@ -1,7 +1,9 @@
package libpod
import (
+ "fmt"
"net/http"
+ "strconv"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod"
@@ -46,12 +48,18 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) {
utils.RemoveContainer(w, r, query.Force, query.Vols)
}
func ListContainers(w http.ResponseWriter, r *http.Request) {
+ var (
+ filters []string
+ )
decoder := r.Context().Value("decoder").(*schema.Decoder)
query := struct {
- Filter []string `schema:"filter"`
- Last int `schema:"last"`
- Size bool `schema:"size"`
- Sync bool `schema:"sync"`
+ All bool `schema:"all"`
+ Filter map[string][]string `schema:"filter"`
+ Last int `schema:"last"`
+ Namespace bool `schema:"namespace"`
+ Pod bool `schema:"pod"`
+ Size bool `schema:"size"`
+ Sync bool `schema:"sync"`
}{
// override any golang type defaults
}
@@ -63,15 +71,22 @@ func ListContainers(w http.ResponseWriter, r *http.Request) {
}
runtime := r.Context().Value("runtime").(*libpod.Runtime)
opts := shared.PsOptions{
- All: true,
+ All: query.All,
Last: query.Last,
Size: query.Size,
Sort: "",
- Namespace: true,
+ Namespace: query.Namespace,
+ Pod: query.Pod,
Sync: query.Sync,
}
-
- pss, err := shared.GetPsContainerOutput(runtime, opts, query.Filter, 2)
+ if len(query.Filter) > 0 {
+ for k, v := range query.Filter {
+ for _, val := range v {
+ filters = append(filters, fmt.Sprintf("%s=%s", k, val))
+ }
+ }
+ }
+ pss, err := shared.GetPsContainerOutput(runtime, opts, filters, 2)
if err != nil {
utils.InternalServerError(w, err)
}
@@ -117,19 +132,12 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
}
func WaitContainer(w http.ResponseWriter, r *http.Request) {
- _, err := utils.WaitContainer(w, r)
+ exitCode, err := utils.WaitContainer(w, r)
if err != nil {
utils.InternalServerError(w, err)
return
}
- utils.WriteResponse(w, http.StatusNoContent, "")
-}
-
-func PruneContainers(w http.ResponseWriter, r *http.Request) {
- // TODO Needs rebase to get filers; Also would be handy to define
- // an actual libpod container prune method.
- // force
- // filters
+ utils.WriteResponse(w, http.StatusOK, strconv.Itoa(int(exitCode)))
}
func LogsFromContainer(w http.ResponseWriter, r *http.Request) {