-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APIv2: compatible api fixes #5410
Conversation
Signed-off-by: Steve Taylor <[email protected]>
Signed-off-by: Steve Taylor <[email protected]>
Signed-off-by: Steve Taylor <[email protected]>
Signed-off-by: Steve Taylor <[email protected]>
Signed-off-by: Steve Taylor <[email protected]>
@mheon did consider the swagger definition and i don't think it needs to change, the uris defined in swagger don't include the version information in the path, only taking about the docker compatible endpoints here and not the libpod ones |
pkg/api/handlers/generic/images.go
Outdated
@@ -305,7 +305,8 @@ func GetImages(w http.ResponseWriter, r *http.Request) { | |||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Failed get images")) | |||
return | |||
} | |||
var summaries = make([]*handlers.ImageSummary, len(images)+1) | |||
// +1 removed from len(images) as this leaves a null entry at the end of the image array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this comment. It will mean nothing in the future. Please remove the comment and just ad it to the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed comment
pkg/api/handlers/types.go
Outdated
imageId, imageName := l.Image() | ||
|
||
var ( | ||
err error | ||
sizeRootFs int64 | ||
sizeRW int64 | ||
state define.ContainerStatus | ||
stateStr string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't define it here. Just use stateStr=state.String()
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/api/handlers/types.go
Outdated
return nil, err | ||
} | ||
} else { | ||
sizeRW = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are defaults so no reason for this code block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/api/handlers/types.go
Outdated
if sizeRootFs, err = l.RootFsSize(); err != nil { | ||
return nil, err | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for else block, These are defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire if sz block was wrong, have removed and changed the call to inspect to pass sz rather than it being hard coded to true, which seemed a better thing to do
removed defaulting of query.Size amended types.LibpodToContainer, removed hard coded true from inspect call Signed-off-by: Steve Taylor <[email protected]>
…ation Signed-off-by: Steve Taylor <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Just need to restore one item.
@@ -305,7 +305,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) { | |||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Failed get images")) | |||
return | |||
} | |||
var summaries = make([]*handlers.ImageSummary, len(images)+1) | |||
var summaries = make([]*handlers.ImageSummary, len(images)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The +1 ensures we don't return an empty body (clients hate that :) ), when no images are found. So we either need to restore that, or handle that corner case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just spun up an f31 vm with moby-engine, with no images pulled down a curl to /images/json returns and empty array "[]", on podman in the same state if i put the +1 back in the a curl to /images/json returns "[null]" which is causing consuming code to fail. without the +1 podman produced the same as docker "[]".
without the +1 podman mimics the behavior of docker on this call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@st1971 Okay, something must have changed in the response writer. Sorry for the noise, thanks for checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jwhonce, mheon, st1971 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Added addition API handler registration without the need for a API version number, this mimics the structure of the docker API..
Updated GetImages handler to remove null entry at the end of the images array.
Change GetContainers to map status of configured to created.
Implemented size parameter with default of false on ListContainers handler.
Implemented size parameter on GetContainer.