Skip to content

Commit

Permalink
Removed the unnecessary code
Browse files Browse the repository at this point in the history
removed defaulting of  query.Size
amended types.LibpodToContainer, removed hard coded true from inspect call

Signed-off-by: Steve Taylor <[email protected]>
  • Loading branch information
st1971 committed Mar 6, 2020
1 parent 83e52cf commit 920d09c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
6 changes: 0 additions & 6 deletions pkg/api/handlers/generic/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ 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
Expand Down Expand Up @@ -108,9 +105,6 @@ func GetContainer(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
Expand Down
23 changes: 3 additions & 20 deletions pkg/api/handlers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,8 @@ func LibpodToContainer(l *libpod.Container, infoData []define.InfoData, sz bool)
}

func LibpodToContainerJSON(l *libpod.Container, sz bool) (*docker.ContainerJSON, error) {
var (
sizeRootFs int64
sizeRW int64
)

_, imageName := l.Image()
inspect, err := l.Inspect(true)
inspect, err := l.Inspect(sz)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -444,18 +439,6 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*docker.ContainerJSON,
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
}

cb := docker.ContainerJSONBase{
ID: l.ID(),
Created: l.CreatedTime().String(),
Expand All @@ -478,8 +461,8 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*docker.ContainerJSON,
ExecIDs: inspect.ExecIDs,
HostConfig: &hc,
GraphDriver: graphDriver,
SizeRw: &sizeRW,
SizeRootFs: &sizeRootFs,
SizeRw: inspect.SizeRw,
SizeRootFs: &inspect.SizeRootFs,
}

stopTimeout := int(l.StopTimeout())
Expand Down

0 comments on commit 920d09c

Please sign in to comment.