Commit Graph

7 Commits

Author SHA1 Message Date
Kir Kolyshkin 27bf522212 .golanci-lint: enable gofumpt
gofumpt is more opinionated version of gofmt. One can use it from their
$EDITOR, or IDE, or gopls to better format the source code.

Previously, commit b951b72412 already formatted all the code with
gofumpt, but since then a couple of things crept in.

Fix these (with gofumpt v0.3.1) and enable the gofumpt linter.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-05-16 20:01:08 -07:00
Daniel J Walsh aec9f8f79b libimage should be using containers.conf for tmpdir
if image_copy_tmp_dir is set in containers.conf it needs to be used in
the systemcontext for BigFilesTemporaryDir value.

Fixes: https://github.com/containers/podman/issues/14091

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-05-04 16:55:25 -04:00
Kir Kolyshkin 4393468343 *_test.go: fix or suppress errcheck warnings
Where we can check the error, do it. Where we can not, ignore it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 15:18:22 -07:00
Valentin Rothberg e369277804 libimage: refine pull-policy enforcement for custom platforms
When pulling down an image with a user-specified custom platform, we
try to make sure that user gets what they are asking for.  An inherent
issue with multi-arch images is that there are many images in the wild
which do not get the platform right (see containers/podman/issues/10682).
That means we need to pessimistically assume that the local image is
wrong and pull the "correct" one down from the registry; in the worst case
that is redundant work but we have a guarantee of correctness.

Motivated by containers/podman/issues/12707 I had another look at the
code and found some space for optimizations.  Previously, we enforced
the pull policy to "always" but that may be too aggressive since we may
be running in an airgapped environment and the local image is correct.

With this change, we enforce the pull policy to "newer" which makes
errors non-fatal in case a local image has been found; this seems like a
good middleground between making sure we are serving the "correct" image
and user friendliness.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-10 16:27:10 +01:00
Valentin Rothberg fa1504c98a libimage: `(*Runtime).SystemContext()`
Add a method to the libimage runtime to access (a copy of) its
types.SystemContext.  That can be helpful for callers which may need to
access the system context.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-06-24 10:41:25 +02:00
Daniel J Walsh e2264b5823 Set BigFilesTemporaryDir to GetEnv(TMPDIR) if set or /var/tmp
Currently if the caller does not specify the BigFilesTemporaryDir,
Podman and Buildah users expect this to default TMPDIR environment
variable or /var/tmp if not set.

Moving to libimage caused a regression in this functionality.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-16 10:53:59 -04:00
Valentin Rothberg 3b721f41df libimage: add unit tests
This adds tests pulling and a framwork that can be used to add more
tests in the future.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-06 15:41:33 +02:00