summaryrefslogtreecommitdiff
path: root/pkg/api/handlers
Commit message (Collapse)AuthorAge
* Merge pull request #5190 from baude/apiv2cockpit3OpenShift Merge Robot2020-02-14
|\ | | | | filtering behavior correction
| * filtering behavior correctionBrent Baude2020-02-12
| | | | | | | | | | | | when filtering containers, if a status= is provided as an input filter, then we should override the all to always be true. Signed-off-by: Brent Baude <bbaude@redhat.com>
* | Merge pull request #5172 from giuseppe/api-fix-cpu-statsOpenShift Merge Robot2020-02-13
|\ \ | |/ |/| api: fix the CPU stats reported
| * stats: add SystemUsageGiuseppe Scrivano2020-02-12
| | | | | | | | Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
| * api: fix the CPU stats reportedGiuseppe Scrivano2020-02-11
| | | | | | | | Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* | Merge pull request #5171 from baude/apiv2cockpit2OpenShift Merge Robot2020-02-12
|\ \ | | | | | | Fix container filters
| * | Fix container filtersBrent Baude2020-02-11
| | | | | | | | | | | | | | | | | | container filters were being double encoded (maybe triple) which resulted in the wrong encoding representation of filters being sent by the go-bindings. Also, on the server side, Filter needed to be changed to Filter to decode properly. Finally, due to the changed return type of List Containers, the go bindings return values needed to be changed. Signed-off-by: Brent Baude <bbaude@redhat.com>
* | | api: pull: fix reference parsingValentin Rothberg2020-02-12
| | | | | | | | | | | | Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* | | Merge pull request #5175 from baude/apiv2eventsOpenShift Merge Robot2020-02-12
|\ \ \ | | | | | | | | apiv2 stream events
| * | | apiv2 stream eventsBrent Baude2020-02-11
| |/ / | | | | | | | | | | | | | | | the events endpoint should be stream-based. it also needed to be registered to answer and not produce 404s. Signed-off-by: Brent Baude <bbaude@redhat.com>
* | / HTTP 304 (NotModified) is not an error!Ed Santiago2020-02-11
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Even after #5169, my test logs kept showing: ERRO[0004] unable to write json: "http: request method or response status code does not allow body" Cause: overly-helpful code trying to treat condition as an error and include a diagnostic message. This is forbidden per rfc2616. This PR fixes the faulty response, as well as three others found via: $ ack 'Error.*NotMod' (4 hits total) $ ack 'Error.*NoCont' (no hits) Signed-off-by: Ed Santiago <santiago@redhat.com>
* | Merge pull request #5169 from edsantiago/apiv2_pod_status_codesOpenShift Merge Robot2020-02-11
|\ \ | | | | | | API v2: pods: fix two incorrect return codes
| * | 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>
* | Merge pull request #5083 from vrothberg/v2-libpod-image-endpointsOpenShift Merge Robot2020-02-11
|\ \ | |/ |/| v2 api: /libpod/images/{import,load,pull}
| * v2 api: /libpod/images/importValentin Rothberg2020-02-10
| | | | | | | | | | | | | | | | | | Implement the /libpod/images/import endpoint Tested manually with curl: curl -X POST --data-binary "@image.tar" --header "Content-Type: application/x-tar" Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
| * v2 api: /libpod/images/loadValentin Rothberg2020-02-10
| | | | | | | | | | | | | | | | | | Implement the /libpod/images/load endpoint. Tested manually with curl: curl -X POST --data-binary "@image.tar" --header "Content-Type: application/x-tar" Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
| * v2 api: /libpod/images/pullValentin Rothberg2020-02-10
| | | | | | | | | | | | | | | | | | | | Implement the /libpod/images/pull endpoint and correct the swagger docs. The reference parameter is mandatory and must either be a c/image/docker/reference or a reference to the "docker://" transport as the pull endpoint is meant to only support pulling images from a registry. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* | Rewire ListContainers for APIv2 libpodBrent Baude2020-02-11
|/ | | | | | | | | | consumers of the api remarked how they would prefer a more strongly typed data structure from list containers oon the libpod side of things. for example, events should be consumable and consistent timestamps. also, for the sake of compatibility, it is helpful to have the json named atttributes for Id to not be ID. listcontainers on the libpod side no longer strongly uses the the ps cli to obtain information but we do benefit from turning on the ability to list the last X containers, something CLI does not have yet. we also flipped the bit on defaulting to truncated output in the return. thanks to the efforts of the cockpit team to help us here. Signed-off-by: Brent Baude <bbaude@redhat.com>
* swagger: v2: libpod/images/{import,load,pull}Valentin Rothberg2020-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: this commit is merely adding swagger documentation and the golang stubs and types for the proposed endpoints. The implementation will follow in separate individual changes in the future. The ultimate goal is to prevent the libpod API from exposing the rather complex /images/create endpoint from Docker and split it into easier to implement, use and comprehend endpoints with a more narrow focus. # Import Add the v2 swagger documentation for the libpod/images/import endpoint. Note that we have intend to have separate backend and not mix it up with load since import allows for specifying a URL instead of a local tarball. # Load Complete the v2 swagger documentation for the libpod/images/load endpoint. Note that we are accounting for future plans to be able to load multiple images from one oci/docker archive by returning an array of image-load responses. Also move the (incomplete) implementation of the generic endpoint to the corresponding package and create a stub for the libpod handler, which will be implemented once there's an agreement on the proposed API. # Pull Add the v2 swagger documentation for the libpod/images/pull endpoint. Similar to the load endpoint, we return an array since more than one image can be pulled when the `all-tags` parameter is set. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Merge pull request #5061 from baude/apiv2swaggerexecOpenShift Merge Robot2020-02-04
|\ | | | | [CI:DOCS]add apiv2 endpoints for exec
| * [CI:DOCS]add apiv2 endpoints for execBrent Baude2020-02-03
| | | | | | | | | | | | | | | | add the openapi/swagger documentation for exec. The subcommands added are create, inspect, resize, and start. at the time of this writing, no structure is declared for the inspect response. once the libpod work for this is complete, we can inherit and swaggerize it. Signed-off-by: Brent Baude <bbaude@redhat.com>
* | Update /_ping supportJhon Honce2020-02-03
|/ | | | | | | | | | | | | | | | | | | | | * Add swagger support and documentation * Promote handler as there can only ever be one * Update swagger tags Between verbs and paths there are four endpoints for /_ping. I've attempted to document them well without four copies of the details. Time will tell. Clients will use the headers `Libpod-API-Version` and `Libpod-Buildha-Version` to determine if they are connecting to a Podman service or some other compatible engine. Client calls GET(/_ping): * VARLINK engines will fail with error message * Compatible engines will return 200 without Libpod headers * Podman engines will return 200 and Libpod headers Signed-off-by: Jhon Honce <jhonce@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>
* compat container names begin with /Brent Baude2020-01-30
| | | | | | when using the apiv2, containers names are preceeded with a /. fixing this for inspect and listcontainers. 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>
* Merge pull request #4965 from baude/reviewcorrections3OpenShift Merge Robot2020-01-25
|\ | | | | APIv2 review corrections #3
| * APIv2 review corrections #3Brent Baude2020-01-25
| | | | | | | | | | | | The third pass of corrections for the APIv2. Signed-off-by: Brent Baude <bbaude@redhat.com>
* | Refactor time parsing to be more liberal in accepted valuesJhon Honce2020-01-24
|/ | | | | | * Added helper function to allow parsing from filters Signed-off-by: Jhon Honce <jhonce@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>
* Merge pull request #4912 from jwhonce/wip/swaggerOpenShift Merge Robot2020-01-22
|\ | | | | [CI:DOCS] Update build images
| * Update build imagesJhon Honce2020-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | * Add swagger annotations for all the query and response parameters for buildimages * Improve populating the BuildOptions struct * Improve swagger.json generation, removing tags.xml and move tag definiation into the swagger:meta block * Update Makefile to be more robust, added target for validation * TODO once validation passes add that step to the generation step 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>
* Add an API for Attach over HTTP APIMatthew Heon2020-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | The new APIv2 branch provides an HTTP-based remote API to Podman. The requirements of this are, unfortunately, incompatible with the existing Attach API. For non-terminal attach, we need append a header to what was copied from the container, to multiplex STDOUT and STDERR; to do this with the old API, we'd need to copy into an intermediate buffer first, to handle the headers. To avoid this, provide a new API to handle all aspects of terminal and non-terminal attach, including closing the hijacked HTTP connection. This might be a bit too specific, but for now, it seems to be the simplest approach. At the same time, add a Resize endpoint. This needs to be a separate endpoint, so our existing channel approach does not work here. I wanted to rework the rest of attach at the same time (some parts of it, particularly how we start the Attach session and how we do resizing, are (in my opinion) handled much better here. That may still be on the table, but I wanted to avoid breaking existing APIs in this already massive change. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Merge pull request #4860 from vrothberg/v2-topOpenShift Merge Robot2020-01-15
|\ | | | | v2 api: top improvements
| * api: stats: fix typoValentin Rothberg2020-01-15
| | | | | | | | Signed-off-by: Valentin Rothberg <rothberg@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>
| * refactor top codeValentin Rothberg2020-01-15
| | | | | | | | | | | | | | | | Move the top logic from pkg/adapter into the (*libpod.Container).Top(). This way, we drop the dependency from pkg/api on pkg/adapters and have a clearer separation of concerns. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
| * v2 api: top improvementsValentin Rothberg2020-01-15
| | | | | | | | | | | | | | | | * Use `pkg/adapter` to increase code reuse and reduce code redundancy. * Extend swagger docs to mention AIX descriptors. * Document the libpod endpoint which shares the same handler. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* | [CI:DOCS]swagger cleanup and left-hand navbaude2020-01-15
| | | | | | | | | | | | | | | | add a static tags file so we can dictate the left-hand navigation. in doing so we now override the tag in the swagger:operation. we now have images and images (compat) as a way to differentiate. Signed-off-by: baude <bbaude@redhat.com>
* | Merge pull request #4868 from jwhonce/wip/sshdOpenShift Merge Robot2020-01-15
|\ \ | |/ |/| [CI:DOCS] Add APIv2 CLI example POC
| * Add APIv2 CLI example POCJhon Honce2020-01-15
| | | | | | | | | | | | | | * Add ReadMe, CLI and unit files to support socket activation, both for system and rootless Signed-off-by: Jhon Honce <jhonce@redhat.com>
* | v2: stats: drop redundant sleep when streamingValentin Rothberg2020-01-15
| | | | | | | | | | | | Also remove the redundant stats handler in libpod. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* | v2: stats: rigorous error checksValentin Rothberg2020-01-15
| | | | | | | | | | | | Also expect the container to be running. 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>
* | v2: stats: do not ignore errorsValentin Rothberg2020-01-15
| | | | | | | | | | | | | | We must check all errors and handle them properly. Otherwise, we can run into nil dereferences ultimately killing the service. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* | v2: stats: remove windows-specific fieldsValentin Rothberg2020-01-15
|/ | | | | | | `NumProcs` and `StorageStats` are windows specific and are not popoulated on Linux. Hence, we can safely remove them. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* [CI:DOCS]swagger correctionsbaude2020-01-14
| | | | Signed-off-by: baude <bbaude@redhat.com>