249 Commits

Author SHA1 Message Date
fb4148bc41 Fix podman-remote images
Looks like we went too far with the linters.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-16 12:29:25 -04:00
200cfa41a4 Turn on More linters
- misspell
    - prealloc
    - unparam
    - nakedret

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-15 07:05:56 -04:00
4bb43b898d Fixup issues found by golint
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-10 05:49:41 -04:00
dc80267b59 compat handlers: add X-Registry-Auth header support
* 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>
2020-05-29 15:39:37 +02:00
a4c8198afd Fix remote handling of podman images calls
Enable three more tests
Fix handling of image filters

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-21 09:28:42 -04:00
1090d4d5d9 manifest annotate
Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-05-05 15:01:32 -04:00
38eb9f4a3d Fixes podman save fails when specifying an image using a digest #5234
Adds check to parse normalized name and create docker archive dst reference
for tagged untagged image. Relevant test case added.

Signed-off-by: Sujil02 <sushah@redhat.com>
2020-04-28 16:16:30 -04:00
2f3734b143 Add --os to manifest add
Add --os to manifest add for overriding the os field.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-04-24 14:57:56 -04:00
26081e79c1 remove blank line
Signed-off-by: Les Aker <me@lesaker.org>
2020-04-23 16:25:02 -04:00
2c328f94b6 set bigfilestemporarydir for pull
Signed-off-by: Les Aker <me@lesaker.org>
2020-04-23 16:15:55 -04:00
e66346c7b0 Stop wrapping pull messages
The length and size of our error messages on failure to pull
is huge.  This patch at least eliminates some of the wrapping.
But I think eventually we need to look at containers/image
and see if we can modify the error messages to something a little
more human friendly.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-23 05:31:36 -04:00
a2ad5bb9e1 Add functions to return image informations
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 15:50:46 -04:00
9dc9f5cf4c image prune skips images with child images.
While image build process, intermediate images are created.
These images are also used as cache images, used in rebuilding
same images. This fix the deletion of cache images.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
2020-04-15 02:49:47 +00:00
8500ce6b9a podmanv2 load
enable podman load for v2

add reexec into main

add systemd build flag to v2 makefile

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-01 14:10:57 -05:00
abbbeacd68 apiv2 addition of manifests
add endpoints for create, add, remove, inspect, and push.  this allows manifests to be managed through the restful interfaces.

also added go-bindings and tests

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-03-16 10:03:55 -05:00
235f367861 Merge pull request #5469 from giuseppe/no-size-create-container
create: do not calculate image size
2020-03-12 10:20:02 -04:00
8741eb8a92 create: do not calculate image size
calculating the image size can be an expensive operation.  Avoid doing
it when creating a new container since the size is not needed.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-03-12 09:51:17 +01:00
593eb7625a golangci: enable goimports
Enable the goimports linter and fix reports.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-03-05 20:03:44 +01:00
a554e97adc Merge pull request #5236 from marusak/filter_by_id
apiv2: Image filtering and fixup docs
2020-02-21 12:17:38 -05:00
29930fae70 podman images: add --filter=since=XX
Looks like a bit of a misunderstanding from early on.

Docker implements --filter=since=IMAGE. Podman implements 'after'
instead of 'since'. Add an equivalent case statement to handle
both, keeping 'after' because we have no way of knowing if it
is used in the field.

Update documentation ... and fix what looks like a complete
misinterpretation of what the code actually does: the man page
claimed that these were time fields, but I don't see any
possible incantation in which a time value works or could
work. Updated docs to reflect IMAGE usage. Also changed
nonworking '==' to single '='.

Added tests. [UPDATE: skip with broken podman-remote]

Fixes: #5040

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-20 07:55:29 -07:00
d08e0c728f apiv2: Enable filtering images by ID
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>
2020-02-17 18:44:46 +01:00
93358ef915 Refactor image tree for API usage
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-02-17 11:12:35 +01:00
2aacfade75 use quay.io/libpod/fedora-minimal for reliability
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-12 16:45:03 -06:00
dafd212870 Modify Runtime.getImage to return a storage.Image
... because both callers only care about that aspect of the
return value.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
5b5bacbd95 Document an aspect of newFromStorage behavior
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
972df82632 Introduce a Runtime.newImage constructor
... so that _all_ Image objects are created in a single place
that is easy to update.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
933edf4a37 Move Image.getLocalImage to Runtime.getLocalImage
Instead of the function updating image.InputName (the only reason for it
to need an image), have it return the updated value separately.

This will allow simplifying the constructors of Image further.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
1ab4038807 Remove the getLocalImage() call from Image.Size
All ways to create an Image{} have a non-nil .image field, and it
is never set to nil, so this is dead code.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
ede412f40f Use Runtime.NewFromLocal instead of open-coded copies
All code creating an Image by looking up a name now uses
Runtime.NewFromLocal.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
a433b858d2 Trivial simplification
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
d9bfaf5197 Create two separate newImage instances in Runtime.New
This is not _trivially_ safe because newImage.getLocalImage()
modifies newImage.ImageName, but we overwrite that value anyway.

So, this should not change behavior, and it will make future refactoring
easier to verify.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:01 +01:00
0f0bac4ab3 Call NewImageRuntimeFromStore from NewImageRuntimeFromOptions
... so that there ultimately is only one constructor.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2020-02-07 23:36:00 +01:00
03faf97aa0 Close tarSource when finished using it
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1797599

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-04 13:12:06 -05:00
b8a2818e70 Wrap error for failing ImageSize calls
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-02-04 14:21:59 +01:00
c9fb6d1668 history: fix size computing
Get the layer's size whether it relates to the first history entry or
not.  This fixes issues where the first entry would always be shown
to be of size 0.

Fixes: #4916
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-29 14:54:24 +01:00
31a1f44fe6 honor pull policy in play kube
When a container specification has a pull policy, we should honor it when recreating the pods/containers from yaml.  furthermore, ini kube, if a tag is :latest, then the always pull policy is automatically instituted.

Fixes: #4880

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-01-28 13:36:10 -06:00
6181faa90d inspect image healthchecks
when a docker image has a defined healthcheck, it should be displayed with inspect.  this is only valid for docker images as oci images are not aware of healthchecks.

Fixes: #4799
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-01-27 08:36:25 -06:00
cf1f3191d2 make lint: include unit tests
Include the unit tests (i.e., _test.go files) for linting to make the
tests more robust and enforce the linters' coding styles etc.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-14 10:51:59 +01:00
796ae87b1a Merge pull request #4850 from vrothberg/fix-linting
Fix linting
2020-01-13 21:03:21 +01:00
e83a1b87da Merge pull request #4817 from rhatdan/codespell
Add codespell to validate spelling mistakes in code.
2020-01-13 17:59:58 +01:00
67165b7675 make lint: enable gocritic
`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>
2020-01-13 14:27:02 +01:00
9e2e4d7615 Merge pull request #4694 from openSUSE/history-names-in-inspect
Add history names to image inspect data
2020-01-13 08:52:13 +01:00
4093b2c011 Add codespell to validate spelling mistakes in code.
Fix all errors found by codespell

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-11 06:32:19 -05:00
986feef2e8 fix e2e test failure
it is possible for layers.names to be nil and we must account for that.

Signed-off-by: baude <bbaude@redhat.com>
2020-01-10 13:06:26 -06:00
d924494f56 Initial commit on compatible API
Signed-off-by: Jhon Honce <jhonce@redhat.com>

Create service command

Use cd cmd/service && go build .

$ systemd-socket-activate -l 8081 cmd/service/service &
$ curl http://localhost:8081/v1.24/images/json

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Correct Makefile

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Two more stragglers

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Report errors back as http headers

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Split out handlers, updated output

Output aligned to docker structures

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Refactored routing, added more endpoints and types

* Encapsulated all the routing information in the handler_* files.
* Added more serviceapi/types, including podman additions. See Info

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Cleaned up code, implemented info content

* Move Content-Type check into serviceHandler
* Custom 404 handler showing the url, mostly for debugging
* Refactored images: better method names and explicit http codes
* Added content to /info
* Added podman fields to Info struct
* Added Container struct

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Add a bunch of endpoints

containers: stop, pause, unpause, wait, rm
images: tag, rmi, create (pull only)

Signed-off-by: baude <bbaude@redhat.com>

Add even more handlers

* Add serviceapi/Error() to improve error handling
* Better support for API return payloads
* Renamed unimplemented to unsupported these are generic endpoints
  we don't intend to ever support.  Swarm broken out since it uses
  different HTTP codes to signal that the node is not in a swarm.
* Added more types
* API Version broken out so it can be validated in the future

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Refactor to introduce ServiceWriter

Signed-off-by: Jhon Honce <jhonce@redhat.com>

populate pods endpoints

/libpod/pods/..

exists, kill, pause, prune, restart, remove, start, stop, unpause

Signed-off-by: baude <bbaude@redhat.com>

Add components to Version, fix Error body

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Add images pull output, fix swarm routes

* docker-py tests/integration/api_client_test.py pass 100%
* docker-py tests/integration/api_image_test.py pass 4/16
+ Test failures include services podman does not support

Signed-off-by: Jhon Honce <jhonce@redhat.com>

pods endpoint submission 2

add create and others; only top and stats is left.

Signed-off-by: baude <bbaude@redhat.com>

Update pull image to work from empty registry

Signed-off-by: Jhon Honce <jhonce@redhat.com>

pod create and container create

first pass at pod and container create.  the container create does not
quite work yet but it is very close.  pod create needs a partial
rewrite.  also broken off the DELETE (rm/rmi) to specific handler funcs.

Signed-off-by: baude <bbaude@redhat.com>

Add docker-py demos, GET .../containers/json

* Update serviceapi/types to reflect libpod not podman
* Refactored removeImage() to provide non-streaming return

Signed-off-by: Jhon Honce <jhonce@redhat.com>

create container part2

finished minimal config needed for create container.  started demo.py
for upcoming talk

Signed-off-by: baude <bbaude@redhat.com>

Stop server after honoring request

* Remove casting for method calls
* Improve WriteResponse()
* Update Container API type to match docker API

Signed-off-by: Jhon Honce <jhonce@redhat.com>

fix namespace assumptions

cleaned up namespace issues with libpod.

Signed-off-by: baude <bbaude@redhat.com>

wip

Signed-off-by: baude <bbaude@redhat.com>

Add sliding window when shutting down server

* Added a Timeout rather than closing down service on each call
* Added gorilla/schema dependency for Decode'ing query parameters
* Improved error handling
* Container logs returned and multiplexed for stdout and stderr
  * .../containers/{name}/logs?stdout=True&stderr=True
* Container stats
  * .../containers/{name}/stats

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Improve error handling

* Add check for at least one std stream required for /containers/{id}/logs
* Add check for state in /containers/{id}/top
* Fill in more fields for /info
* Fixed error checking in service start code

Signed-off-by: Jhon Honce <jhonce@redhat.com>

get rest  of image tests for pass

Signed-off-by: baude <bbaude@redhat.com>

linting our content

Signed-off-by: baude <bbaude@redhat.com>

more linting

Signed-off-by: baude <bbaude@redhat.com>

more linting

Signed-off-by: baude <bbaude@redhat.com>

pruning

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]apiv2 pods

migrate from using args in the url to using a json struct in body for
pod create.

Signed-off-by: baude <bbaude@redhat.com>

fix handler_images prune

prune's api changed slightly to deal with filters.

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]enabled base container create tests

enabling the base container create tests which allow us to get more into
the stop, kill, etc tests. many new tests now pass.

Signed-off-by: baude <bbaude@redhat.com>

serviceapi errors: append error message to API message

I dearly hope this is not breaking any other tests but debugging
"Internal Server Error" is not helpful to any user.  In case, it
breaks tests, we can rever the commit - that's why it's a small one.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

serviceAPI: add containers/prune endpoint

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

add `service` make target

Also remove the non-functional sub-Makefile.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

add make targets for testing the service

 * `sudo make run-service` for running the service.

 * `DOCKERPY_TEST="tests/integration/api_container_test.py::ListContainersTest" \
 	make run-docker-py-tests`
   for running a specific tests.  Run all tests by leaving the env
   variable empty.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Split handlers and server packages

The files were split to help contain bloat. The api/server package will
contain all code related to the functioning of the server while
api/handlers will have all the code related to implementing the end
points.

api/server/register_* will contain the methods for registering
endpoints.  Additionally, they will have the comments for generating the
swagger spec file.

See api/handlers/version.go for a small example handler,
api/handlers/containers.go contains much more complex handlers.

Signed-off-by: Jhon Honce <jhonce@redhat.com>

[CI:DOCS]enabled more tests

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]libpod endpoints

small refactor for libpod inclusion and began adding endpoints.

Signed-off-by: baude <bbaude@redhat.com>

Implement /build and /events

* Include crypto libraries for future ssh work

Signed-off-by: Jhon Honce <jhonce@redhat.com>

[CI:DOCS]more image implementations

convert from using for to query structs among other changes including
new endpoints.

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]add bindings for golang

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]add volume endpoints for libpod

create, inspect, ls, prune, and rm

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]apiv2 healthcheck enablement

wire up container healthchecks for the api.

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]Add mount endpoints

via the api, allow ability to mount a container and list container
mounts.

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]Add search endpoint

add search endpoint with golang bindings

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]more apiv2 development

misc population of methods, etc

Signed-off-by: baude <bbaude@redhat.com>

rebase cleanup and epoch reset

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]add more network endpoints

also, add some initial error handling and convenience functions for
standard endpoints.

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]use helper funcs for bindings

use the methods developed to make writing bindings less duplicative and
easier to use.

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]add return info for prereview

begin to add return info and status codes for errors so that we can
review the apiv2

Signed-off-by: baude <bbaude@redhat.com>

[CI:DOCS]first pass at adding swagger docs for api

Signed-off-by: baude <bbaude@redhat.com>
2020-01-10 09:41:39 -06:00
583ff5320f fix lint - ignore image.ImageDeleteResponse definition
Golint claims that image.Image stutters but renaming the type would be a
breaking change which isn't worth the consequences.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-08 15:44:30 +01:00
4f09cfdacc add struct response for removal of images
when removing an image from storage, we should return a struct that
details what was untagged vs deleted.  this replaces the simple
println's used previously and assists in API development.

Signed-off-by: baude <bbaude@redhat.com>
2019-12-23 10:02:14 -06:00
1cdaf45d05 Add history names to image inspect data
During writing the tests I found it would be probably useful to have the
tag history part of the inspect data.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-12-13 13:53:30 +01:00
8be7b466d8 move image filters under libpod/images
to make things more effecient for the api work we are doing, we should
process image filters internally (as opposed to in main).  this allows
for better api responses and more closely affiliated functions.

Signed-off-by: baude <bbaude@redhat.com>
2019-12-10 13:05:18 -06:00
63e46cc85c Add support for image name history
We leverage the containers/storage image history tracking feature to
show the previously used image names when running:
`podman images --history`

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-11-27 13:42:06 +01:00