Commit Graph

79 Commits

Author SHA1 Message Date
Chris Evich fbe36445c7
Adjust conformance-test error-message regex
Sometime around `docker.io 20.10.2-0ubuntu1~20.04.2` several error
message strings were updated from `file not found` to `file does not
exist`.  This breaks conformance testing.  Fix this by adding in
the new error message.

Signed-off-by: Chris Evich <cevich@redhat.com>
2021-07-01 09:56:17 -04:00
Nalin Dahyabhai 6b63a73aea conformance: use :Z with transient mounts when SELinux is enabled
When SELinux is enabled, add the :Z mount flag to transient mounts that
we use in the tests that use transient mounts.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-27 16:54:30 -04:00
Daniel J Walsh 37e9d254cc
Fix copier when using globs
In Docker if you are copying more then one object, and
one of them is successful, then the command is successful. Currently in
buildah each glob has to be successful. This PR matches Buildah to
Docker.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-22 10:39:23 -04:00
Nalin Dahyabhai 5f1066b674 Add conformance tests for COPY /...
Add conformance tests that ensure that when we COPY a subdirectory
that's specified as an absolute path, that we don't regress on treating
the absolute path as still being relative to the build context's
location.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-01 17:26:29 -04:00
Nalin Dahyabhai 21a8912ef3 Add a conformance test for COPY --from $symlink
Check that COPY --from doesn't do something different when given a
symbolic link as its source than it would without the --from.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-01 15:29:38 -04:00
Nalin Dahyabhai 052eef0035 Add conformance tests for COPY ""
Add a couple of conformance tests exercising "" as a source name for
COPY instructions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-01 15:29:38 -04:00
Nalin Dahyabhai 0b4d973238 COPY --chown: expand the conformance test
Expand conformance test coverage for COPY --chown, and correct our
behavior when the argument is a single number: instead of assuming the
number is the UID and GID = 0, the GID should be the same as the UID.

This means that we can't quite use the same function for parsing the
arguments for COPY --chown and USER, as they evidently have different
defaults for the case where the argument is a single number.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-03-22 16:37:12 -04:00
Nalin Dahyabhai ba11a4ceeb imagebuildah: use overlay for volumes when using overlay
When we're using the overlay driver (which means we know overlay is
available), use it to make volumes appear to be writeable during RUN
instructions instead of saving/restoring their contents.

This avoids having to copy the contents of the volume directory before
each RUN instruction, and having to remove and extract the contents
after each RUN instruction, which should be faster, particularly if the
amount of content in that volume location is large.

For empty directories, it will at least avoid adding an "opaque"
notation for the directory in a layer that might otherwise be empty.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-03-05 15:57:55 -05:00
Daniel J Walsh 514a3f1a91
Shrink the vendoring size of pkc/cli
This PR removes the pkg/auth which brings in docker/docker
since it really is not needed, and was only there to help users
discover the settings of where the authfile was, when the environment
variables were set.  Would almost never be of any value.

Move imagebuildah.BuildOptions to define.BuildOptions

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-03 14:18:35 -05:00
Nalin Dahyabhai effb375b5a ADD/COPY: create the destination directory first, chroot to it
Always create the destination directory first when ADDing or COPYing
content into a container, then extract contents into it using the
destination directory as the chroot instead of the container's root
directory.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-03-02 16:29:43 -05:00
Daniel J Walsh 4704e6cb3f
Eliminate the use of containers/building import in pkg subdirs
We want to shrink the size of the import when importing pkg from
buildah. This should help us shrink the size of the golang bindings
in podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-12 12:43:08 -05:00
Daniel J Walsh 8f70dd9d5b
Stop testing directory permissions with latest docker
Current version of Docker, has a bug we believe, that is
creating top level directories when using ADD and COPY of
tar balls. Basically the directories end up with a 777
permissions, Buildah creates these with 755, which we
believe is correct, and matches older versions of Docker.

We need to revert this patch once we have a version of Docker
that creates these direcories with the corret permissions.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-05 10:25:24 -05:00
Chris Evich 024d0091db
Fix conformance test false-failures
Prior to Docker 20.10, failed COPY/ADD instructions result in error
messages containing the string `no such file or directory`.  This was
changed in docker to a string containing `file not found`.  Since
the conformance tests potentially need to work with multiple docker
versions, they need to be sensitive to both errors.

Signed-off-by: Chris Evich <cevich@redhat.com>
2021-01-12 16:26:43 -05:00
Josh Soref c7963db369 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-21 16:47:18 -05:00
Nalin Dahyabhai 26b50dc1eb copier: handle replacing directories with not-directories
Improve handling of cases where extracting an archive requires us to
replace a directory with something that is not a directory, or vice-
versa:
* when replacing a directory with something that isn't a directory,
  remove the directory even if it has contents
* don't fail when replacing something that isn't a directory with a
  directory

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-12-16 18:00:45 -05:00
Nalin Dahyabhai 2a94354288 copier: put: ignore Typeflag="g"
Ignore PAX global headers when extracting archives, like the archive
package does, instead of erroring out.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-10-23 12:57:27 -04:00
Nalin Dahyabhai 9c6969a79e ADD and COPY: descend into excluded directories, sometimes
When a directly-named (or globbed) source directory for ADD or COPY is
marked for exclusion by .dockerignore, check if its name is a prefix for
any exceptions in the .dockerignore file, and if it is, check the
directory for things we need to include anyway.

This will miss exceptions where the pattern uses a wildcard for anything
but the final component.

When adding items, count items that are actually passed over the tar
pipe, rather than items scanned, so that we can correctly diagnose not
having found anything that we needed to copy under a directory that
would otherwise have been excluded.

In copierHandlerGet(), just don't discount any globbed directories that
are excluded.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-10-09 11:45:39 -04:00
OpenShift Merge Robot 2c83535a5d
Merge pull request #2667 from nalind/no-extract-directory-items
ADD: only expand archives at the right time
2020-10-01 17:14:10 -04:00
Nalin Dahyabhai d595739e05 ADD: only expand archives at the right time
When ADD was used to ADD a directory, the contents of archives that we
found inside of it were incorrectly being expanded at the destination
for the ADD.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-10-01 13:58:33 -04:00
Nalin Dahyabhai 09b787a0a3 CI: re-enable several linters
When we carried over the linting configuration from podman, we carried
over the list of checkers that were disabled for podman's sake, even
ones that don't complain about the code in this repository.

Make trivial changes to make gosimple happy.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-09-30 13:00:17 -04:00
Nalin Dahyabhai c1a1805ee8 add: preserve ownerships and permissions on ADDed archives
When extracting archives that are added using ADD, don't override
permissions and ownership information.  We regressed on this when we
switched to using the copier package to handle them.

Add a conformance test to prevent regressions on this.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-09-29 16:25:31 -04:00
Daniel J Walsh 2cf9c8f2b8
Fix up code based on codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-15 16:49:18 -04:00
Nalin Dahyabhai 02921ee3ab Fix ownership of content copied using COPY --from
COPY --from was incorrectly discarding ownership information on files
copied from other layers, which unlike content copied from the build
context, should not default to being owned by 0:0.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-22 13:22:48 -04:00
Nalin Dahyabhai 3835460c3b Use pipes for copying
Use the copier package to rework how we handle ADD and COPY.

When evaluating cache for content that's being copied/added in, switch
from (digest the data, check for a cache entry, then maybe copy the data
and create the new layer) to (copy the data and create the new layer,
digesting as we go, check for a cache entry, either commit or discard
the new layer).

Use the copier package for ADD, COPY, and for ensuring that a specified
directory exists in the working container's rootfs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-21 12:34:00 -04:00
Sebastian Reuße 09138e29bc imagebuildah: don’t blank out destination names when COPYing
When ADDing an archive file, the destination file-name is blanked out to ensure
that archive contents are extracted in-place. However, when COPYing an
archive-file, we don’t want to blank out the destination filename.

Fixes: #2549

Signed-off-by: Sebastian Reuße <seb@wirrsal.net>
2020-08-16 12:39:18 +02:00
Nalin Dahyabhai 7f6ddecfdf conformance testing: ignore buildah.BuilderIdentityAnnotation labels
Ignore the buildah.BuilderIdentityAnnotation label when comparing images
that we build with images built using other tools, which of course don't
automatically set that label.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-12 11:25:52 -04:00
Nalin Dahyabhai 9fc9a222e7 conformance: add a test for COPY from subdirectory
Make sure we test copying from a subdirectory of the build context to a
new directory.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-06 13:18:17 -04:00
Nalin Dahyabhai e92358c8dc copier: split StripSetidBits into StripSetuidBit/StripSetgidBit/StripStickyBit
For the sake of conformance tests, callers need to be able to strip
setuid and setgid bits from contents being copied from the build context
while leaving the sticky bit intact.  Split the StripSetidBits option
for copier.Get() into three separate flags (StripSetuidBit /
StripSetgidBit / StripStickyBit).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-07-29 02:11:11 -04:00
Nalin Dahyabhai 92e0c3fdcf Rework conformance testing
Move the conformance tests from ginkgo to using the default testing
package and github.com/stretchr/testify/require, preserving the existing
tests and adding more.

Add conformance tests to our Cirrus configuration, currently marked as
an allowed failure.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-07-23 15:30:58 -04:00