aboutsummaryrefslogtreecommitdiff
path: root/pkg/api/handlers/utils
Commit message (Collapse)AuthorAge
* Remove varlink support from PodmanDaniel J Walsh2020-11-26
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Align the podman pod ps --filter behavior with podman psPaul Holzinger2020-11-18
| | | | | | | | | Filters with the same key work inclusive with the only exception being `label` which is exclusive. Filters with different keys always work exclusive. Also update the documentation with the new behavior. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
* Lowercase some errorsKir Kolyshkin2020-10-05
| | | | | | | | | | | | | | | | | | | | | This commit is courtesy of ``` for f in $(git ls-files *.go | grep -v ^vendor/); do \ sed -i 's/\(errors\..*\)"Error /\1"error /' $f; done for f in $(git ls-files *.go | grep -v ^vendor/); do \ sed -i 's/\(errors\..*\)"Failed to /\1"failed to /' $f; done ``` etc. Self-reviewed using `git diff --word-diff`, found no issues. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
* Refactor API version valuesJhon Honce2020-09-15
| | | | | | | | | | | | | | | | * API-Version header now Major.Minor to support tools parsing this header * Libpod Version updated to 2.0.0 to reflect changes in API field values * API-Version and Libpod-API-Version headers are now included in all results Fixes #7327 * Header support tested against goland 2020.2 and https://www.jetbrains.com/help/idea/docker.html plugin Signed-off-by: Jhon Honce <jhonce@redhat.com>
* fix /libpod/pods/json returns null when there are no podszhangguanzhang2020-08-21
| | | | Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
* image list: speed upValentin Rothberg2020-08-07
| | | | | | | | | | | | | | | | | | | | | | | Listing images has shown increasing performance penalties with an increasing number of images. Unless `--all` is specified, Podman will filter intermediate images. Determining intermediate images has been done by finding (and comparing!) parent images which is expensive. We had to query the storage many times which turned it into a bottleneck. Instead, create a layer tree and assign one or more images to nodes that match the images' top layer. Determining the children of an image is now exponentially faster as we already know the child images from the layer graph and the images using the same top layer, which may also be considered child images based on their history. On my system with 510 images, a rootful image list drops from 6 secs down to 0.3 secs. Also use the tree to compute parent nodes, and to filter intermediate images for pruning. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* API returns 500 in case network is not found instead of 404zhangguanzhang2020-08-02
| | | | Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
* Switch all references to github.com/containers/libpod -> podmanDaniel J Walsh2020-07-28
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Add support for Filter query parameter to list images apiKorhonen Sami (Samlink)2020-07-07
| | | | | | | | | | | | Docker api version 1.24 uses a query parameter named Filter for filtering images by names. In more recent versions of api name filter is in filters query parameter with other filters This patch adds a mapping that translates Filter query parameter to Filters={"reference": [""]} Signed-off-by: Sami Korhonen <skorhone@gmail.com>
* move go module to v2Valentin Rothberg2020-07-06
| | | | | | | | | | | | | | | With the advent of Podman 2.0.0 we crossed the magical barrier of go modules. While we were able to continue importing all packages inside of the project, the project could not be vendored anymore from the outside. Move the go module to new major version and change all imports to `github.com/containers/libpod/v2`. The renaming of the imports was done via `gomove` [1]. [1] https://github.com/KSubedi/gomove Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Merge pull request #6557 from rhatdan/lintOpenShift Merge Robot2020-06-15
|\ | | | | Turn on More linters
| * Turn on More lintersDaniel J Walsh2020-06-15
| | | | | | | | | | | | | | | | | | - misspell - prealloc - unparam - nakedret Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* | Reassemble filters on the server sideDaniel J Walsh2020-06-12
|/ | | | | | | | | --filter label=foo=bar, was been translated on the server side to --filter label=foo --filter=bar This PR fixes this back to what the user specified. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Fix Id->ID where possible for lintDaniel J Walsh2020-06-10
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Fixup issues found by golintDaniel J Walsh2020-06-10
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Add support for format {{.Label}}Brent Baude2020-06-01
| | | | | | | | the pod ps man page says .Label is valid go template format. i dont think the function was actually ever implemented. Fixes #6448 Signed-off-by: Brent Baude <bbaude@redhat.com>
* Fix remote handling of podman images callsDaniel J Walsh2020-05-21
| | | | | | | Enable three more tests Fix handling of image filters Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* V2 API Version SupportJhon Honce2020-05-20
| | | | | | | | | | | | | | | | | * Update blang/semver to allow ParseTolerant() support * Provide helper functions for API handlers to obtain client's 'version' path variable focused on API endpoint tree: libpod vs. compat * Introduce new errors: * version not given in path, endpoints may determine if this is a hard error (ErrVersionNotGiven) * given version not supported (ErrVersionNotSupported), only a soft error if the handler is going to hijack the connection * Added unit tests for version parsing * bindings check version on connect: * client <= Server API version connection is continued * client >= Server API version connection fails Signed-off-by: Jhon Honce <jhonce@redhat.com>
* V2 Implement terminal handling in bindings attachJhon Honce2020-05-18
| | | | | | | | | * Add support for /exec/{id}/resize * Add support for ErrSessionNotFound * Resize container TTY as stdin changes size * Refactor all resize functions into one handler Signed-off-by: Jhon Honce <jhonce@redhat.com>
* implement pod statsValentin Rothberg2020-04-27
| | | | | | | Implement pod stats for the local and remote client. Both code paths end up in infra/abi to allow for code share. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Podman V2 birthBrent Baude2020-04-16
| | | | | | remote podman v1 and replace with podman v2. Signed-off-by: Brent Baude <bbaude@redhat.com>
* podman v2 remove bloat v2Brent Baude2020-04-16
| | | | | | rid ourseleves of libpod references in v2 client Signed-off-by: Brent Baude <bbaude@redhat.com>
* v2 bloat pruning phase 2Brent Baude2020-04-15
| | | | | | this is second phase of removing unneeded bloat in the remote client. this is important to be able to reduce the client size as well as possible native compilation for windows/mac. Signed-off-by: Brent Baude <bbaude@redhat.com>
* podmanv2 save imageBrent Baude2020-04-03
| | | | | | add ability to save an image for podman v2 Signed-off-by: Brent Baude <bbaude@redhat.com>
* podmanV2: implement pushValentin Rothberg2020-04-02
| | | | | | | | | | | | | | | | | * Implement `podman-push` and `podman-image-push` for the podmanV2 client. * Tests for `pkg/bindings` are not possible at the time of writing as we don't have a local registry running. * Implement `/images/{name}/push` compat endpoint. Tests are not implemented for this v2 endpoint. It has been tested manually. General note: The auth config extraction from the http header is not implement for push. Since it's not yet supported for other endpoints either, I deferred it to future work. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* podmanv2 pod psBrent Baude2020-03-31
| | | | | | add the ability to list pods in podmanv2 Signed-off-by: Brent Baude <bbaude@redhat.com>
* podmanv2 pod subcommandsBrent Baude2020-03-26
| | | | | | add pod kill, pause, restart, rm, start, stop, and unpause Signed-off-by: Brent Baude <bbaude@redhat.com>
* Merge pull request #5554 from baude/compatfixOpenShift Merge Robot2020-03-19
|\ | | | | fix reported compat issues
| * fix reported compat issuesBrent Baude2020-03-19
| | | | | | | | | | | | | | | | | | | | honor -1 in in list containers for compatibility mode. it is commonly used to indicate no limit. change the json id parameter to Id in container create. Fixes: #5553 Signed-off-by: Brent Baude <bbaude@redhat.com>
* | Filter pods through pod list apiSujil022020-03-17
|/ | | | | | | Refactored current filter pods flow through the shared pod functions so filter pod functionalities can be shared between api and cmd. Signed-off-by: Sujil02 <sushah@redhat.com>
* Refactor handler packagesJhon Honce2020-03-10
| | | | | | | To help with packaging, the handlers in pkg/api/handlers are now found in pkg/api/handler/compat. Signed-off-by: Jhon Honce <jhonce@redhat.com>
* golangci: enable goimportsValentin Rothberg2020-03-05
| | | | | | Enable the goimports linter and fix reports. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* rework apiv2 wait endpoint|bindingBrent Baude2020-02-28
| | | | | | | | added the ability to wait on a condition (stopped, running, paused...) for a container. if a condition is not provided, wait will default to the stopped condition which uses the original wait code paths. if the condition is stopped, the container exit code will be returned. also, correct a mux issue we discovered. Signed-off-by: Brent Baude <bbaude@redhat.com>
* apiv2 container create using specgenBrent Baude2020-02-19
| | | | | | this uses the specgen structure to create containers rather than the outdated createconfig. right now, only the apiv2 create is wired up. eventually the cli will also have to be done. Signed-off-by: Brent Baude <bbaude@redhat.com>
* Fixed typo in KillContainerAndreas Schubert2020-02-19
| | | | Signed-off-by: Andreas Schubert <schubter@gmail.com>
* Update mux rules to allow slashes in image namesJhon Honce2020-02-18
| | | | | | | | | %2F escaping is also supported. Return better response on bad search terms Fixes #5229 Signed-off-by: Jhon Honce <jhonce@redhat.com>
* add caching for binding testsBrent Baude2020-02-14
| | | | | | | | add the ability to cache images instead of pull them. makes tests faster and less network use when we flip on CI. Also added list images with filter test Signed-off-by: Brent Baude <bbaude@redhat.com>
* API v2: pods: fix two incorrect return codesEd Santiago2020-02-11
| | | | | | | | | | | | | | 1) /pods/<X>/exists - is documented to return 204, and that's the correct value, but until now it has been returning 200. 2) /pods/create - return 409 (conflict), not 500, when pod already exists Also: in WriteResponse(), if code is 204 (No Content) or 304 (Not Modified), emit the status code only but no content-type headers nor content. Signed-off-by: Ed Santiago <santiago@redhat.com>
* fix longname handling for bindingsBrent Baude2020-01-31
| | | | | | the api needs to account for image input where the image is encoded as a fqd image name. Signed-off-by: Brent Baude <bbaude@redhat.com>
* [CI:DOCS]Binding overhaulsBrent Baude2020-01-28
| | | | | | | | | | Add binding for networks and begin documentation for binding methods for godoc. Also, add major functions to their own subpackages so reduce the amount of of method confusion. So instead of: bindings.ListImages(), we now do a [bindings].images.List(). Also, the connection is passed to each binding method via a context to allow for future growth. Lastly, add first set of tests. There are a couple of things to work out for rootless tests yet. Signed-off-by: Brent Baude <bbaude@redhat.com>
* APIv2 review corrections #3Brent Baude2020-01-25
| | | | | | The third pass of corrections for the APIv2. Signed-off-by: Brent Baude <bbaude@redhat.com>
* Merge pull request #4958 from jwhonce/wip/filtersOpenShift Merge Robot2020-01-24
|\ | | | | [CI:DOCS] Add query parameter converters for complex types
| * Add query parameter converters for complex typesJhon Honce2020-01-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add converter for URL query parameters of type map[string][]string * Add converter for URL query parameters of type time.Time * Added function to allocate and configure schema.Decoder for API use * Updated API handlers to leverage new converters, and correct handler code for filter type An encoding example for a client using filters: v := map[string][]string{ "dangling": {"true"}, } payload, err := jsoniter.MarshalToString(v) if err != nil { panic(err) } payload = "?filters=" + url.QueryEscape(payload) Signed-off-by: Jhon Honce <jhonce@redhat.com>
* | Review corrections pass #2Brent Baude2020-01-23
|/ | | | | | Add API review comments to correct documentation and endpoints. Also, add a libpode prune method to reduce code duplication. Only used right now for the API but when the remote client is wired, we will switch over there too. Signed-off-by: Brent Baude <bbaude@redhat.com>
* Enable swagger validation for each PRJhon Honce2020-01-22
| | | | | | | | | * Update swagger:operation's to pass validation * 'name' path parameter now used throughout API * Added #/response/ok for 200 returns, TBD values have been replaced with legal values. Signed-off-by: Jhon Honce <jhonce@redhat.com>
* [CI:DOCS]First pass at review commentsbaude2020-01-21
| | | | | | | Tackling the first comments in the review pass. More to come. Signed-off-by: baude <bbaude@redhat.com> Signed-off-by: Brent Baude <bbaude@redhat.com>
* api: utils: add an `IsLibpodRequest` handlerValentin Rothberg2020-01-15
| | | | | | | | | Add a hanlder to figure out if the specified http request came through a libpod endpoint. A first user is the top endpoint which has a different default value for `ps_args` depending if the request came through the docker or libpod endpoint. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* v2: stats: fix errorsValentin Rothberg2020-01-15
| | | | | | Also add some comments. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* make lint: enable gocriticValentin Rothberg2020-01-13
| | | | | | | `gocritic` is a powerful linter that helps in preventing certain kinds of errors as well as enforcing a coding style. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* [CI:DOCS]update apiv2 documentation with swagger goodsbaude2020-01-10
| | | | Signed-off-by: baude <bbaude@redhat.com>