summaryrefslogtreecommitdiff
path: root/pkg/api/server
Commit message (Collapse)AuthorAge
* add default network for apiv2 createBrent Baude2020-03-06
| | | | | | | | | | | | | during container creation, if no network is provided, we need to add a default value so the container can be later started. use apiv2 container creation for RunTopContainer instead of an exec to the system podman. RunTopContainer now also returns the container id and an error. added a libpod commit endpoint. also, changed the use of the connections and bindings slightly to make it more convenient to write tests. Fixes: 5366 Signed-off-by: Brent Baude <bbaude@redhat.com>
* Merge pull request #5371 from edsantiago/apiv2_fixesOpenShift Merge Robot2020-03-02
|\ | | | | more swagger fixes
| * more swagger fixesEd Santiago2020-03-02
| | | | | | | | Signed-off-by: Ed Santiago <santiago@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>
* binding tests for volumesBrent Baude2020-02-27
| | | | | | | | add binding tests for volumes: inspect(get), create, remove, prune, and list implement filters ability for volumes Signed-off-by: Brent Baude <bbaude@redhat.com>
* Remove 1 sec delayJhon Honce2020-02-25
| | | | | | | | | * Stop closing net.Listener() twice on interrupt * Do not report error if closing server twice Fixes #5311 Signed-off-by: Jhon Honce <jhonce@redhat.com>
* Merge pull request #5236 from marusak/filter_by_idOpenShift Merge Robot2020-02-21
|\ | | | | apiv2: Image filtering and fixup docs
| * apiv2: Fixup /containers/json filters documentationMatej Marusak2020-02-17
| | | | | | | | | | | | | | Mention what is the input format plus put literals into quotation marks for better readability (plus it seems that some tags were not rendered). Signed-off-by: Matej Marusak <mmarusak@redhat.com>
| * apiv2: Enable filtering images by IDMatej Marusak2020-02-17
| | | | | | | | | | | | | | It is more practical for API usage and also it is more in sync how filtering of containers works. Signed-off-by: Matej Marusak <mmarusak@redhat.com>
* | Swagger: yet more fixesEd Santiago2020-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | PR #5204 added /libpod/containers/create but with the wrong swagger comment. Fix that. Also fix some other inconsistencies: missing 'libpod' prefix, missing 'Container' suffix, and change 'ContainerCreate' to 'CreateContainer'; all of these changes preserve consistency with both the invoked function as well as the overall naming conventions used in this module. Signed-off-by: Ed Santiago <santiago@redhat.com>
* | Swagger: fix one incorrect commentEd Santiago2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR #5235 updated a bunch of entrypoints from {name} to {name:.*}, requiring matching changes to swagger comments. Looks like one got missed due to the manual nature of this work. Have I mentioned lately that manual maintenance of duplicate information is not a great idea? Discrepancy caught by my script, which I would really like to look into getting into CI, but is gating on #5238. (I would actually not like to get this script into CI, I would prefer to have the duplicate information be autogenerated from the function calls themselves, but I seem to have lost that battle) Signed-off-by: Ed Santiago <santiago@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>
* | Swagger: fix inconsistencies (try #2)Ed Santiago2020-02-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As I've mentioned once or twice, hand-maintained swagger docs are evil. This commit attempts to fix: * Inconsistent methods (swagger says POST but code signature says GET) * Inconsistent capitalization * Typos ("Mounter", "pood") * Completely wrong paths (/inspect vs /json) * Missing .Method() registrations * Missing /libpod in some /volumes paths * Incorrect method declaration: /libpod/containers/.../kill was correct (POST) in swagger but wrong in the code itself (http.MethodGet). Correct the latter to MethodPost This is two hours' work, even with a script I have that tries to cross-check everything. Swagger docs should not be human-maintained. Signed-off-by: Ed Santiago <santiago@redhat.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>
* | Fix handler and systemd activation errorsJhon Honce2020-02-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On panic from handler: log warning and stack trace, report InternalServerError to client When using `podman system service` make determining the listening endpoint deterministic. // When determining _*THE*_ listening endpoint -- // 1) User input wins always // 2) systemd socket activation // 3) rootless honors XDG_RUNTIME_DIR // 4) if varlink -- adapter.DefaultVarlinkAddress // 5) lastly adapter.DefaultAPIAddress Fixes #5150 Fixes #5151 Signed-off-by: Jhon Honce <jhonce@redhat.com>
* | Refactor image tree for API usageSascha Grunert2020-02-17
|/ | | | Signed-off-by: Sascha Grunert <sgrunert@suse.com>
* apiv2 libpod container logsBrent Baude2020-02-14
| | | | | | wire up containers logs for libpod side of the house, same as compat. Signed-off-by: Brent Baude <bbaude@redhat.com>
* Merge pull request #5074 from jwhonce/wip/swagger_endpointOpenShift Merge Robot2020-02-14
|\ | | | | Add /swagger/ endpoint to serve swagger yaml to clients
| * Add /swagger/ endpoint to serve swagger yaml to clientsJhon Honce2020-02-04
| | | | | | | | | | | | The provided yaml file will describe the current Podman REST API. Signed-off-by: Jhon Honce <jhonce@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>
* | | 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}
| * | swagger: fix /libpod/images/{import,load,pull}Valentin Rothberg2020-02-11
| | | | | | | | | | | | Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
| * | 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>
* / fix swagger docs and make sure docs validation runsBrent Baude2020-02-05
|/ | | | 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>
* [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>
* 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>
* | Add service endpointbaude2020-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add service endpoint for the new API. Also supports the varlink implementation. Signed-off-by: baude <bbaude@redhat.com> Refactor to allow developer more control of API server * Add api.NewServerWithSettings() to create an API server with custom settings * Add api.ListenUnix() to create a UDS net.Listener and setup UDS Signed-off-by: Jhon Honce <jhonce@redhat.com> Signed-off-by: baude <bbaude@redhat.com> More service completion Add podman service command that allows users to run either a RESTful or varlink protocol API service. Addition of docs and RESTful listening. Signed-off-by: baude <bbaude@redhat.com> Signed-off-by: Brent Baude <bbaude@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>
* [CI:DOCS] Add logo and dev statementBrent Baude2020-01-20
| | | | | | Add statement to the info section stating this is experimental only for now. Also add the podman logo to the right-hand navigation. Signed-off-by: Brent Baude <bbaude@redhat.com>
* post-process swagger yaml for publishbaude2020-01-17
| | | | | Signed-off-by: baude <bbaude@redhat.com> Signed-off-by: Chris Evich <cevich@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>
* make binaries: include serviceValentin Rothberg2020-01-16
| | | | | | | Include the service into make binaries such that we're it's being build in the CI. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* service: don't block sigtermValentin Rothberg2020-01-16
| | | | Signed-off-by: Valentin Rothberg <rothberg@redhat.com>