summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorSteve Taylor <steven@taylormuff.co.uk>2020-03-05 22:53:50 +0000
committerSteve Taylor <steven@taylormuff.co.uk>2020-03-05 22:53:50 +0000
commitda15f2f8817a432bce7e578de23554e5ed854f13 (patch)
tree2870d30e2d6c482d11c70c209d8dac6add6a2de8 /pkg
parent1ef96364fe2a665ef6867adc3f9953b50232601c (diff)
downloadpodman-da15f2f8817a432bce7e578de23554e5ed854f13.tar.gz
podman-da15f2f8817a432bce7e578de23554e5ed854f13.tar.bz2
podman-da15f2f8817a432bce7e578de23554e5ed854f13.zip
Implement size parameter on ListContainers
Signed-off-by: Steve Taylor <steven@taylormuff.co.uk>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/generic/containers.go6
-rw-r--r--pkg/api/handlers/types.go17
2 files changed, 16 insertions, 7 deletions
diff --git a/pkg/api/handlers/generic/containers.go b/pkg/api/handlers/generic/containers.go
index ab587ded4..5b52cdfa9 100644
--- a/pkg/api/handlers/generic/containers.go
+++ b/pkg/api/handlers/generic/containers.go
@@ -57,6 +57,10 @@ func ListContainers(w http.ResponseWriter, r *http.Request) {
}{
// override any golang type defaults
}
+
+ // Default Size to false
+ query.Size = false
+
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String()))
return
@@ -85,7 +89,7 @@ func ListContainers(w http.ResponseWriter, r *http.Request) {
var list = make([]*handlers.Container, len(containers))
for i, ctnr := range containers {
- api, err := handlers.LibpodToContainer(ctnr, infoData)
+ api, err := handlers.LibpodToContainer(ctnr, infoData, query.Size)
if err != nil {
utils.InternalServerError(w, err)
return
diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go
index 0c3548370..ada249e56 100644
--- a/pkg/api/handlers/types.go
+++ b/pkg/api/handlers/types.go
@@ -347,7 +347,7 @@ func ImageDataToImageInspect(ctx context.Context, l *libpodImage.Image) (*ImageI
}
-func LibpodToContainer(l *libpod.Container, infoData []define.InfoData) (*Container, error) {
+func LibpodToContainer(l *libpod.Container, infoData []define.InfoData, sz bool) (*Container, error) {
imageId, imageName := l.Image()
var (
@@ -366,11 +366,16 @@ func LibpodToContainer(l *libpod.Container, infoData []define.InfoData) (*Contai
stateStr = "created"
}
- if sizeRW, err = l.RWSize(); err != nil {
- return nil, err
- }
- if sizeRootFs, err = l.RootFsSize(); err != nil {
- return nil, err
+ if sz {
+ if sizeRW, err = l.RWSize(); err != nil {
+ return nil, err
+ }
+ if sizeRootFs, err = l.RootFsSize(); err != nil {
+ return nil, err
+ }
+ } else {
+ sizeRW = 0
+ sizeRootFs = 0
}
return &Container{docker.Container{