aboutsummaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/images.go
Commit message (Collapse)AuthorAge
* Remove two GetImages functions from APIDaniel J Walsh2022-01-14
| | | | | | | | | [NO NEW TESTS NEEDED] This is just code cleanup. The remote API has three different GetImages functions, which I believe can be handled by just one function. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Don't return a header name from auth.GetCredentialsMiloslav Trmač2021-12-10
| | | | | | | | | | | Almost every caller is using it only to wrap an error in exactly the same way, so move that error context into GetCredentials and simplify the users. (The one other caller, build, was even wrapping the error incorrectly talking about query parameters; so let it use the same text as the others.) Signed-off-by: Miloslav Trmač <mitr@redhat.com>
* compat: images/jsonValentin Rothberg2021-12-02
| | | | | | | Do not list manifest lists. Docker doesn't either. Fixes: #12453 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* compat API: allow enforcing short-names resolution to Docker HubValentin Rothberg2021-11-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Docker-compatible REST API has historically behaved just as the rest of Podman and Buildah (and the atomic Docker in older RHEL/Fedora) where `containers-registries.conf` is centrally controlling which registries a short name may resolve to during pull or local image lookups. Please refer to a blog for more details [1]. Docker, however, is only resolving short names to docker.io which has been reported (see #12320) to break certain clients who rely on this behavior. In order to support this scenario, `containers.conf(5)` received a new option to control whether Podman's compat API resolves to docker.io only or behaves as before. Most endpoints allow for directly normalizing parameters that represent an image. If set in containers.conf, Podman will then normalize the references directly to docker.io. The build endpoint is an outlier since images are also referenced in Dockerfiles. The Buildah API, however, supports specifying a custom `types.SystemContext` in which we can set a field that enforces short-name resolution to docker.io in `c/image/pkg/shortnames`. Notice that this a "hybrid" approach of doing the normalization directly in the compat endpoints *and* in `pkg/shortnames` by passing a system context. Doing such a hybrid approach is neccessary since the compat and the libpod endpoints share the same `libimage.Runtime` which makes a global enforcement via the `libimage.Runtime.systemContext` impossible. Having two separate runtimes for the compat and the libpod endpoints seems risky and not generally applicable to all endpoints. [1] https://www.redhat.com/sysadmin/container-image-short-names Fixes: #12320 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Refacter API server emphasis on loggingJhon Honce2021-09-10
| | | | | | | | | | | | | | | * To aid in debugging log API request and response bodies at trace level. Events can be correlated using the X-Reference-Id. * Server now echos X-Reference-Id from client if set, otherwise generates an unique id. * Move logic for X-Reference-Id into middleware * Change uses of Header.Add() to Set() when setting Content-Type * Log API operations in Apache format using gorilla middleware * Port server code to use BaseContext and ConnContext Fixes #10053 Signed-off-by: Jhon Honce <jhonce@redhat.com>
* compat: image create: handle platform correctlyValentin Rothberg2021-07-20
| | | | | | | | | Handle the platform parameter correctly. The parameter was only parsed in presence of credentials and the code was a bit complex. Also add a regression test. Fixes: #10977 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Image import fromSrc now supports OS/Archcdoern2021-06-14
| | | | | | | | added handling in entities and compat to support passing a specified OS/Arch while importing from SRC. fixes #10566 Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
* Merge pull request #10548 from cdoern/imgFeatureOpenShift Merge Robot2021-06-08
|\ | | | | API images/create added missing parameters platform, message, repo
| * made requested changes, fixed api testscdoern2021-06-04
| | | | | | | | Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
* | Merge pull request #10508 from matejvasek/fix-from-imgOpenShift Merge Robot2021-06-01
|\ \ | | | | | | Better error handing for images/create compat api
| * | Better error handing for images/create compat apiMatej Vasek2021-05-31
| |/ | | | | | | | | | | | | | | | | If server cannot resolve short name due to enforcing policy send non-2xx status code. [NO TESTS NEEDED] Signed-off-by: Matej Vasek <mvasek@redhat.com>
* / Use request context instead of background contextMatej Vasek2021-06-01
|/ | | | | | | | | This fixes a goroutine leak. Previously if request was cancelled the image pulling goroutine kept running regardless. [NO TESTS NEEDED] Signed-off-by: Matej Vasek <mvasek@redhat.com>
* Merge pull request #10265 from matejvasek/fix-get-multiple-imgs-compatOpenShift Merge Robot2021-05-08
|\ | | | | fix: compat API "images/get" for multiple images
| * fix: compat API "images/get" for multiple imagesMatej Vasek2021-05-07
| | | | | | | | Signed-off-by: Matej Vasek <mvasek@redhat.com>
* | Merge pull request #10259 from rhatdan/pullOpenShift Merge Robot2021-05-07
|\ \ | |/ |/| Report Download complete in Compatibility mode
| * Report Download complete in Compatibility modeDaniel J Walsh2021-05-07
| | | | | | | | | | | | | | | | Fixes: https://github.com/containers/podman/issues/10258 [NO TESTS NEEDED] Difficult to create tests for this. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* | fix pre review requestMatej Vasek2021-05-06
| | | | | | | | Signed-off-by: Matej Vasek <mvasek@redhat.com>
* | fix: docker APIv2 `images/get`Matej Vasek2021-05-05
|/ | | | Signed-off-by: Matej Vasek <mvasek@redhat.com>
* migrate Podman to containers/common/libimageValentin Rothberg2021-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate the Podman code base over to `common/libimage` which replaces `libpod/image` and a lot of glue code entirely. Note that I tried to leave bread crumbs for changed tests. Miscellaneous changes: * Some errors yield different messages which required to alter some tests. * I fixed some pre-existing issues in the code. Others were marked as `//TODO`s to prevent the PR from exploding. * The `NamesHistory` of an image is returned as is from the storage. Previously, we did some filtering which I think is undesirable. Instead we should return the data as stored in the storage. * Touched handlers use the ABI interfaces where possible. * Local image resolution: previously Podman would match "foo" on "myfoo". This behaviour has been changed and Podman will now only match on repository boundaries such that "foo" would match "my/foo" but not "myfoo". I consider the old behaviour to be a bug, at the very least an exotic corner case. * Futhermore, "foo:none" does *not* resolve to a local image "foo" without tag anymore. It's a hill I am (almost) willing to die on. * `image prune` prints the IDs of pruned images. Previously, in some cases, the names were printed instead. The API clearly states ID, so we should stick to it. * Compat endpoint image removal with _force_ deletes the entire not only the specified tag. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Correct compat images/create?fromImage responseMilivoje Legenovic2021-02-26
| | | | Signed-off-by: Milivoje Legenovic <m.legenovic@gmail.com>
* bump go module to v3Valentin Rothberg2021-02-22
| | | | | | | | | We missed bumping the go module, so let's do it now :) * Automated go code with github.com/sirkon/go-imports-rename * Manually via `vgrep podman/v2` the rest Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* images/create: always pull imageValentin Rothberg2021-02-16
| | | | | | | | | The `images/create` endpoint should always attempt to pull a newer image. Previously, the local images was used which is not compatible with Docker and caused issues in the Gitlab CI. Fixes: #9232 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Merge pull request #9311 from deadNightTiger/fix-pull-dockerjavaOpenShift Merge Robot2021-02-12
|\ | | | | apiv2: handle docker-java clients pulling
| * apiv2: handle docker-java clients pullingIgor Korolev2021-02-11
| | | | | | | | | | | | | | | | | | When docker-java calls images/create?fromImage=x, it expects two things for a successful response: that both "error" and "errorDetail" are not set, and that the "progress" message contains one of five hard-coded strings ("Download complete" being one of them). Signed-off-by: Igor Korolev <missterr@gmail.com>
* | Enable whitespace linterPaul Holzinger2021-02-11
|/ | | | | | | | Use the whitespace linter and fix the reported problems. [NO TESTS NEEDED] Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
* Restore compatible API for prune endpointsJhon Honce2021-01-07
| | | | | | | | | | | * Restore correct API endpoint payloads including reclaimed space numbers * Include tests for API prune endpoints * Clean up function signatures with unused parameters * Update swagger for /networks/prune Fixes #8891 Signed-off-by: Jhon Honce <jhonce@redhat.com>
* Rework pruning to report reclaimed spaceBaron Lenardson2020-12-30
| | | | | | | | | | | | This change adds code to report the reclaimed space after a prune. Reclaimed space from volumes, images, and containers is recorded during the prune call in a PruneReport struct. These structs are collected into a slice during a system prune and processed afterwards to calculate the total reclaimed space. Closes #8658 Signed-off-by: Baron Lenardson <lenardson.baron@gmail.com>
* Clean up temporary file.Matej Vasek2020-12-15
| | | | Signed-off-by: Matej Vasek <mvasek@redhat.com>
* Do not pass name argument to Load APIQi Wang2020-12-02
| | | | | | | Not pass the name argument to Load API. Specify in the document the usage of the optional argument is tagging an additional image. Close #7337 Signed-off-by: Qi Wang <qiwan@redhat.com>
* save image remove signaturesQi Wang2020-10-21
| | | | | | | remove signatures to podman save since the image formats do not support signatures Close: #7659 Signed-off-by: Qi Wang <qiwan@redhat.com>
* alter compat no such image messagebaude2020-10-13
| | | | | | we need to alter the return error message when a GET (inspect) is performed on an image using the compatibility layer. docker-py bindings look for a initial capped error message. Signed-off-by: baude <bbaude@redhat.com>
* add compatibility endpoint for exporting multiple imagesbaude2020-10-08
| | | | | | | | with the recent inclusion of dealing with multiple images in a tar archive, we can now add a compatibility endpoint that was missing images/get?names=one,two. Fixes: #7950 Signed-off-by: baude <bbaude@redhat.com>
* 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>
* compat: images/create: fix tag parsingValentin Rothberg2020-10-02
| | | | | | | | The `tag` parameter of the compat `images/create` endpoint can be both, a tag and a digest. Fix parsing of the parameter to detect digests and use the appropriate `@` separator. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Add X-Registry-Config supportJhon Honce2020-09-29
| | | | | | | | | | | | * Refactor auth pkg to support X-Registry-Config * Refactor build endpoint to support X-Registry-Config. Supports: * --creds * --authfile * Added X-Reference-Id Header to http.Request to support log event correlation * Log headers from http.Request Signed-off-by: Jhon Honce <jhonce@redhat.com>
* Properly handle podman run --pull commandDaniel J Walsh2020-09-27
| | | | | | | | | | | | | | | | | | Currently the --pull missing|always|never is ignored This PR implements this for local API. For remote we need to default to pullpolicy specified in the containers.conf file. Also fixed an issue when images were matching other images names based on prefix, causing images to always be pulled. I had named an image myfedora and when ever I pulled fedora, the system thought that it there were two images named fedora since it was checking for the name fedora as well as the prefix fedora. I changed it to check for fedora and the prefix /fedora, to prefent failures like I had. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Supports import&run--signature-policyQi Wang2020-09-15
| | | | | | Enables podman create, pull, run, import to use --signature-policy option. Set it as hidden flag to be consistent with other commands. Signed-off-by: Qi Wang <qiwan@redhat.com>
* support multi-image (docker) archivesValentin Rothberg2020-09-08
| | | | | | | | | | | | | Support loading and saving tarballs with more than one image. Add a new `/libpod/images/export` endpoint to the rest API to allow for exporting/saving multiple images into an archive. Note that a non-release version of containers/image is vendored. A release version must be vendored before cutting a new Podman release. We force the containers/image version via a replace in the go.mod file; this way go won't try to match the versions. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Switch all references to github.com/containers/libpod -> podmanDaniel J Walsh2020-07-28
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.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>
* Fix Id->ID where possible for lintDaniel J Walsh2020-06-10
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* compat handlers: add X-Registry-Auth header supportValentin Rothberg2020-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Support the `X-Registry-Auth` http-request header. * The content of the header is a base64 encoded JSON payload which can either be a single auth config or a map of auth configs (user+pw or token) with the corresponding registries being the keys. Vanilla Docker, projectatomic Docker and the bindings are transparantly supported. * Add a hidden `--registries-conf` flag. Buildah exposes the same flag, mostly for testing purposes. * Do all credential parsing in the client (i.e., `cmd/podman`) pass the username and password in the backend instead of unparsed credentials. * Add a `pkg/auth` which handles most of the heavy lifting. * Go through the authentication-handling code of most commands, bindings and endpoints. Migrate them to the new code and fix issues as seen. A final evaluation and more tests is still required *after* this change. * The manifest-push endpoint is missing certain parameters and should use the ABI function instead. Adding auth-support isn't really possible without these parts working. * The container commands and endpoints (i.e., create and run) have not been changed yet. The APIs don't yet account for the authfile. * Add authentication tests to `pkg/bindings`. Fixes: #6384 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Add support for containers.confDaniel J Walsh2020-03-27
| | | | | | | vendor in c/common config pkg for containers.conf Signed-off-by: Qi Wang qiwan@redhat.com Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* V2 podman image pruneJhon Honce2020-03-26
| | | | | | | | | * Fixed header for `podman image ls` * Implemented prune `all` flag, preserved filter method for backwards capability * Updated binding tests Signed-off-by: Jhon Honce <jhonce@redhat.com>
* V2 podman images/image listJhon Honce2020-03-24
| | | | | | | | | | * Updated entities to support flags/options * Updated bindings caused by entities changes * Removed handlers.ImageSummary in favor of entities.ImageSummary * Introduced StringSet() container object to simply error checking Signed-off-by: Jhon Honce <jhonce@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>