202 Commits

Author SHA1 Message Date
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
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
ef240f4cd0 Merge pull request #4512 from kunalkushwaha/prune-filter
image prune command fixed as per docker image prune.
2019-11-22 21:56:12 +01:00
5082496cc0 filter added to image pruge command.
filter option accepts two filters.
- label
- until
label supports "label=value" or "label=key=value" format
until supports all golang compatible time/duration formats.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
2019-11-22 17:36:27 +09:00
741b90c2b9 Merge pull request #4502 from vrothberg/fix-3359
history: rewrite mappings
2019-11-18 15:10:09 +01:00
bf62f9a5cf history: rewrite mappings
Rewrite the backend for displaying the history of an image to simplify
the code and be closer to docker's behaviour.  Instead of driving
index-based heuristics, create a reverse mapping from top-layers to the
corresponding image IDs and lookup the layers on-demand.  Also use the
uncompressed layer size to be closer to Docker's behaviour.

Note that intermediate images from local builds are not considered for
the ID lookups anymore.

Fixes: #3359
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-11-12 17:29:30 -05:00
8d928d525f codespell: spelling corrections
Signed-off-by: Dmitry Smirnov <onlyjob@member.fsf.org>
2019-11-13 08:15:00 +11:00
274fe57d3e pulling unqualified reference: make sure it's a docker reference
When pulling an unqualified reference (e.g., `fedora`) make sure that
the reference is not using a non-docker transport to avoid iterating
over the search registries and trying to pull from them.

Fixes: #4434
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-11-05 12:16:43 +01:00
248bb61b14 images: distinguish between tags and digests
Generate an image's RepoDigests list using all applicable digests, and
refrain from outputting a digest in the tag column of the "images"
output.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
07195ff09f API: report multiple digests for images
Be prepared to report multiple image digests for images which contain
multiple manifests but, because they continue to have the same set of
layers and the same configuration, are considered to be the same image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
b9313d355e pull/create: add --override-arch/--override-os flags
Add --override-arch and --override-os as hidden flags, in line with the
global flag names that skopeo uses, so that we can test behavior around
manifest lists without having to conditionalize more of it by arch.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
803357334c image: don't get confused by lists
When an image can be opened as an ImageSource but not an Image, handle
the case where it's an image list all by itself, the case where it's an
image for a different architecture/OS combination, or the case where
it's both.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
a4a70b4506 bump containers/image to v5.0.0, buildah to v1.11.4
Move to containers/image v5 and containers/buildah to v1.11.4.

Replace an equality check with a type assertion when checking for a
docker.ErrUnauthorizedForCredentials in `podman login`.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:18 -04:00
d3f59bedb3 Update c/image to v4.0.1 and buildah to 1.11.3
This requires updating all import paths throughout, and a matching
buildah update to interoperate.

I can't figure out the reason for go.mod tracking
	github.com/containers/image v3.0.2+incompatible // indirect
((go mod graph) lists it as a direct dependency of libpod, but
(go list -json -m all) lists it as an indirect dependency),
but at least looking at the vendor subdirectory, it doesn't seem
to be actually used in the built binaries.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2019-10-04 20:18:23 +02:00
65b20bd521 Correct use of reexec.Init()
A true result from reexec.Init() isn't an error, but it indicates that
main() should exit with a success exit status.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-09-26 18:19:07 -04:00
3e92bcbf71 Do not prune images being used by a container
Podman is not the only user of containers/storage, and as such we
cannot rely on our database as the sole source of truth when
pruning images. If images do not show as in use from Podman's
perspective, but subsequently fail to remove because they are
being used by a container, they're probably being used by Buildah
or another c/storage client.

Since the images in question are in use, we shouldn't error on
failure to prune them - we weren't supposed to prune them in the
first place.

Fixes: #3983

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-10 13:30:50 -04:00
90cddf36bd image: remove unused Decompose method
Decompose() returns an error defined in CNI which has been removed
upstream because it had no in-tree (eg in CNI) users.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2019-08-28 08:59:33 -05:00
9ced2488c9 Add --digestfile option to push
Add the digestfile option to the push command so the digest can
be stored away in a file when requested by the user.  Also have added
a debug statement to show the completion of the push.

Emulates Buildah's https://github.com/containers/buildah/pull/1799/files

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2019-08-21 10:11:52 -04:00
22f55ce406 Fix directory pull image name for OCI images
This is a breaking change and modifies the resulting image name when
pulling from an directory via `oci:...`.

Without this patch, the image names pulled via a local directory got
processed incorrectly, like this:

```
> podman pull oci:alpine
> podman images
REPOSITORY      TAG      IMAGE ID       CREATED       SIZE
localhost/oci   alpine   4fa153a82426   5 weeks ago   5.85 MB
```

We now use the same approach as in the corresponding [buildah fix][1] to
adapt the behavior for correct `localhost/` prefixing.

[1]: https://github.com/containers/buildah/pull/1800

After applying the patch the same OCI image pull looks like this:

```
> ./bin/podman pull oci:alpine
> podman images
REPOSITORY         TAG      IMAGE ID       CREATED       SIZE
localhost/alpine   latest   4fa153a82426   5 weeks ago   5.85 MB
```

End-to-end tests have been adapted as well to cover the added scenario.

Relates to: https://github.com/containers/buildah/issues/1797

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-08-19 12:49:59 +02:00
76f327f73f Merge pull request #3617 from QiWang19/create_pull
add --pull flag for podman create&run
2019-08-17 14:55:14 +02:00
e7fdaf48db image: add user agent to Docker registry options
Set the string to "libpod/VERSION" so that we don't use the unspecific
default of "Go-http-client/xxx".

Fixes #3788

Signed-off-by: Stefan Becker <chemobejk@gmail.com>
2019-08-12 18:28:36 +03:00
decfea65be add --pull flag for podman create&run
Requirement from https://github.com/containers/libpod/issues/3575#issuecomment-512238393

Added --pull for podman create and pull to match the newly added flag in docker CLI.
`missing`: default value, podman will pull the image if it does not exist in the local.
`always`: podman will always pull the image.
`never`: podman will never pull the image.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-08-09 15:21:34 -04:00
619a39f7bb fix search output limit
close https://bugzilla.redhat.com/show_bug.cgi?id=1732280
From the bug Podman search returns 25 results even when limit option `--limit` is larger than 25(maxQueries). They want Podman to return `--limit` results.

This PR fixes the number of output result.
if --limit not set, return MIN(maxQueries, len(res))
if --limit is set, return MIN(option, len(res))

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-08-01 16:15:15 -04:00
7630f1b52e Fix possible runtime panic if image history len is zero
We now return an empty string for the `Comment` field if an OCI v1 image
contains no history.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-07-25 12:45:08 +02:00
0c3038d4b5 golangci-lint phase 4
clean up some final linter issues and add a make target for
golangci-lint. in addition, begin running the tests are part of the
gating tasks in cirrus ci.

we cannot fully shift over to the new linter until we fix the image on
the openshift side.  for short term, we will use both

Signed-off-by: baude <bbaude@redhat.com>
2019-07-22 15:44:04 -05:00
db826d5d75 golangci-lint round #3
this is the third round of preparing to use the golangci-lint on our
code base.

Signed-off-by: baude <bbaude@redhat.com>
2019-07-21 14:22:39 -05:00
20302cb65d Cleanup Pull Message
Currently the pull message on failure is UGLY.  This patch removes a lot of the noice
when pulling an image from multiple registries to make the user experience better.

Our current messages are way too verbose and need to be dampened down.  Still has
verbose mode if you turn on log-level=debug.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-20 06:08:22 -04:00
8ae97b2f57 Add support for listing read/only and read/write images
When removing --all images prune images only attempt to remove read/write images,
ignore read/only images

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-19 06:59:49 -04:00
ee76ba5e68 Improves STD output/readability in combination
with debug output.

Added \n char to specific standard output

Signed-off-by: dom finn <dom.finn00@gmail.com>
2019-07-14 16:03:49 +10:00
a78c885397 golangci-lint pass number 2
clean up and prepare to migrate to the golangci-linter

Signed-off-by: baude <bbaude@redhat.com>
2019-07-11 09:13:06 -05:00
e053e0e05e first pass of corrections for golangci-lint
Signed-off-by: baude <bbaude@redhat.com>
2019-07-10 15:52:17 -05:00
fec1de6ef4 trivial cleanups from golang
the results of a code cleanup performed by the goland IDE.

Signed-off-by: baude <bbaude@redhat.com>
2019-07-03 15:41:33 -05:00
1ebb84b58e Handle images which contain no layers
This fixes some of our handling of images which have no layers, i.e.,
those whose TopLayer is set to an empty value.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-06-26 10:43:04 -04:00
6ee0f3e99f Merge pull request #3257 from weirdwiz/load
Add warning while untagging an image podman-load
2019-06-17 22:14:26 +02:00
ef1a025356 Add warning while untagging an image podman-load
Signed-off-by: Divyansh Kamboj <kambojdivyansh2000@gmail.com>
2019-06-04 17:54:07 +05:30
1be345bd9d Begin to break up pkg/inspect
Let's put inspect structs where they're actually being used. We
originally made pkg/inspect to solve circular import issues.
There are no more circular import issues.

Image structs remain for now, I'm focusing on container inspect.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-06-03 15:54:53 -04:00
d1a7378aa0 change from sysregistries to sysregistriesv2
We want to start supporting the registries.conf format.
Also start showing blocked registries in podman info
Fix sorting so all registries are listed together in podman info.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-05-03 10:38:51 -04:00
01e79477ca Merge pull request #2850 from baude/eventsjournald
journald event logging
2019-04-25 12:20:39 -07:00
4daac4736e image: rework parent/child/history matching
Rework our expectations of how images that are derived from each other
look, so that we don't assume that an image that's derived from a base
image always adds layers relative to that base image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-04-25 08:57:58 -04:00
5c81a117f1 images: add context to GetParent/IsParent/Remove/Prune...
Add a context.Context parameter to Image.GetParent(), Image.IsParent(),
Image.GetChildren(), Image.Remove(), and Runtime.PruneImages().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-04-25 08:57:58 -04:00
7bf7c177ab journald event logging
add the ability for podman to read and write events to journald instead
of just a logfile.  This can be controlled in libpod.conf with the
`events_logger` attribute of `journald` or `file`.  The default will be
set to `journald`.

Signed-off-by: baude <bbaude@redhat.com>
2019-04-24 16:00:04 -05:00
35e46d8d6b add image rmi event
when deleting a commited image, the path for deletion has an early exit
and the image remove event was not being triggered.

Signed-off-by: baude <bbaude@redhat.com>
2019-04-08 08:36:40 -05:00
dc94dbd3c1 podman-remote image tree
add the ability for the podman-remote client to be able to print an
image tree.

Signed-off-by: baude <bbaude@redhat.com>
2019-04-04 14:41:50 -05:00
c6255537d9 Fix a potential segfault in podman search
When generating headers for search, we unconditionally
access element 0 of an array, and I saw this segfault in our CI.
There's no reason we have to do this, we're just going through it
to get field names with reflect, so just make a new copy of the
struct in question.

Also, move this code, which is only for CLI display, into
cmd/podman from libpod/image.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-04-03 15:11:08 -04:00
c37589f503 Set blob cache directory based on GraphDriver
Currently in rootless containers, we end up not using the blob cache.
We also don't store the blob cache based on the users specified graph
storage.  This change will cause the cache directory to be stored with
the rest of the containe images.

While doing this patch, I found that we had duplicated GetSystemContext in
two places in libpod. I cleaned this up.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-03-29 08:27:33 -04:00
a6af746a94 fix Bug 1688041-podman image save removes existing image
Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-03-20 22:37:58 -04:00
a4b3b9ffbb Tree implementation for podman images
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2019-03-14 11:22:06 +09:00
ca1e76ff63 Add event logging to libpod, even display to podman
In lipod, we now log major events that occurr.  These events
can be displayed using the `podman events` command. Each
event contains:

* Type (container, image, volume, pod...)
* Status (create, rm, stop, kill, ....)
* Timestamp in RFC3339Nano format
* Name (if applicable)
* Image (if applicable)

The format of the event and the varlink endpoint are to not
be considered stable until cockpit has done its enablement.

Signed-off-by: baude <bbaude@redhat.com>
2019-03-11 15:08:59 -05:00
ddcdc0c172 pull: promote debug statement to error
print an error if there is any failure pulling an image.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-11 09:25:40 +01:00