Commit Graph

65 Commits

Author SHA1 Message Date
Nalin Dahyabhai 75bdc649be containerImageRef(): squashed images have no parent images
Remove the parent image's ID from the config blob when we're squashing
the image, since after squashing, we share no layers or history with
what was once our base image, and leaving it set triggers verification
errors in registries that expect consistency between parent IDs and
perhaps layers and history.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-05-21 17:13:38 -04:00
Daniel J Walsh 08201577e5
Remove some stuttering on returns errors
Golangs os.* functions return the name of the file/directory they
fail to use.  We should not wrap these errors with the file/directory
to use names, causes stuttering when the user sees the errors, and looks
bad having huge error messages.

Since this is just code cleanup, existing tests should handle the
changes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-03 06:03:13 -04:00
Giuseppe Scrivano 25a0e2c754
image: propagate errors from extractRootfs
every error from copier.Get was previously lost and not propagated
back.  That caused the caller to believe the operation was successful
and lead to incomplete images on errors.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-12 14:29:03 +01: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
Ashley 021ae2f64a
Merge branch 'master' into history 2021-02-16 16:02:40 -05:00
Diego b870be611d Add base image name to comment
Add the name of the base image being used by the build
in the comments of the first layer created.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2021-02-15 16:31:41 -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
Hironori Shiina 073f90bd83 Compute diffID for mapped-layer at creating image source
If UID and GID mappings are specified, the container has a
mapped-layer, whose diffID is not computed when created.
Committing the image fails due to lack of diffID. This fix
computes diffID at creating an image source if a layer
doesn't have a diffID (UncompressedDigest).

This fix also tests if a container with UID and GID mappings
can be committed.

Signed-off-by: Hironori Shiina <shiina.hironori@fujitsu.com>
2020-11-17 13:58:51 +09:00
Daniel J Walsh 39f4cfb79d
Stop excessive wrapping
Golang built in functions like os.Create and others print the name of
the file system object when they fail.  Wrapping them a second time
with the file system object, makes the error message look like crap
when reported to the user.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-15 14:03:13 -04:00
Nalin Dahyabhai 27bed70688 containerImageRef.NewImageSource(): don't always force timestamps
Avoid forcing the timestamps on content in new layers to the current
time when a timestamp is not specified.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-31 17:09:10 -04:00
Daniel J Walsh b715fb86ee
Use --timestamp rather then --omit-timestamp
We recieved feedback on the --omit-timestamp that
users would rather specify the timestamp seconds
rather then just use EPOCH.

This PR removes --omit-timestamp from buildah bud
since this has never been released.

We also hide --omit-timestamp from buildah commit
and allow users to continue to use it, but it conflicts
with --timestamp.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-28 05:23:41 -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
Daniel J Walsh 8bb100be2a
Add --omit-timestamp flag to buildah bud
Currently you can only do deterministic builds with commit command
this change will cause the metadata in the container image to be
epoch 0.

Next step is to save the data in the tar balls as 0.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-11 05:28:41 -04:00
zvier 9be668b2dd
fix error info about get signatures for containerImageSource
Remove these error checks since the instanceDigest is not used
and can just be ignored.

Signed-off-by: zvier <liuzekun0524@163.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-08 08:58:10 -04:00
Daniel J Walsh 8bcc55a5ee
Fix FORWARD_NULL errors found by Coverity
Error: FORWARD_NULL (CWE-476): [#def50]

These errors could lead to crashes in the code.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-10 10:16:14 -04:00
Nalin Dahyabhai 1e6a70c1c2 commit(docker): always set ContainerID and ContainerConfig
For the sake of the Docker output format, always set the ContainerID
field, and if we have a non-nil Config, set ContainerConfig to the same
values.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1989
Approved by: rhatdan
2019-11-20 14:27:55 +00:00
Nalin Dahyabhai 0817460525 Update for manifest-lists API changes in containers/image
Update the blobcache implementation to match API changes to the image
library.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1902
Approved by: rhatdan
2019-10-28 15:15:34 +00:00
Nalin Dahyabhai f0cf07bb60 Move to containers/image v5.0.0
Bump to containers/image's 5.0 release.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1902
Approved by: rhatdan
2019-10-28 15:15:34 +00:00
Miloslav Trmač 797e618cbe Update c/image to v4.0.1
This requires updating all import paths throughout.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1891
Approved by: vrothberg
2019-10-04 07:34:03 +00:00
Nalin Dahyabhai cc80ccc252 makeImageRef: ignore EmptyLayer if Squash is set
If Squash is set, then we're only committing one layer, so if EmptyLayer
is set, which would normally tell us to skip committing the final layer,
we should ignore the EmptyLayer flag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1839
Approved by: TomSweeneyRedHat
2019-09-04 23:00:41 +00:00
Sascha Grunert 7eb4e5972d
Add goimports linter and apply fixes
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-07-18 10:42:46 +02:00
Nalin Dahyabhai 4ae0e14ea8 image: make sure we don't try to use zstd compression
Don't try to use zstd to compress layers until we know what MIME type to
use to describe layers that are compressed with zstd.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1723
Approved by: TomSweeneyRedHat
2019-07-18 01:55:56 +00:00
Nalin Dahyabhai 3bdc9edd67 imagebuildah: handle ID mappings for COPY --from
Fix handling of ID mapping for COPY: when copying from other containers,
use their mappings, and when copying from the host, use host mappings.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1630
Approved by: TomSweeneyRedHat
2019-06-06 13:11:25 +00:00
Nalin Dahyabhai bc53b5d980 commit: commit on every instruction, but not always with layers
When building an image with multiple layers, go back to committing
images for instructions for which we previously wouldn't bother
committing an image, but create them without adding a new layer.

This violates some assumptions that we currently make elsewhere, as it's
possible for an image that's derived from a base image to add no layers
relative to the base image, when previously it was always the case that
we'd add at least one whenever we committed it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1539
Approved by: rhatdan
2019-04-25 19:11:26 +00:00
Nalin Dahyabhai 5c068beb85 makeImageRef: pass in the whole CommitOptions structure
Instead of passing in an increasing number of the fields of
CommitOptions to makeImageRef(), just pass the whole thing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1539
Approved by: rhatdan
2019-04-25 19:11:26 +00:00
Nalin Dahyabhai 810efa340a commit: always set a parent ID
Always set a parent ID when we go to commit an image, whether it's as
part of build-using-dockerfile or our "commit" CLI.  Coerce the parent
image's ID directly into the value that we use instead of digesting it
again.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1538
Approved by: vrothberg
2019-04-23 08:25:37 +00:00
Nalin Dahyabhai d6340f18c1 commit: set created-by to the shell if it isn't set
Set the CreatedBy field of the new image's new history item to the shell
if we don't have a different value to set.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-04-03 15:16:36 -04:00
Johannes Brüderl 4bcddb7cbe cmd/commit: add flag omit-timestamp to allow for deterministic builds
By default, a field called "createdAt" is written into the image manifest.
However, even if my image build process is perfectly deterministic, the image
sha256 hash will be different every time, even if my sources are exactly the
same. In many cases it is desirable that the same input results in the exactly
same output.
This commit introduces the flag --omit-timestamp to the commit command. If set to
true, the timestamp is set to epoch 0, instead of the current timestamp (which
causes different results every time commit is invoked).

Signed-off-by: Johannes Brüderl <johannes.bruederl@gmail.com>

Closes: #1294
Approved by: nalind
2019-01-21 19:54:07 +00:00
Nalin Dahyabhai 23ed59594b Add options for empty-layer history entries
Add configuration methods for adding entries which will show up in a
committed image's history, both before and after the new layer that we
add while committing the image.  Expose them from the CLI in the form of
a new --add-history option for the "add", "config", "copy", and "run"
commands.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1300
Approved by: rhatdan
2019-01-21 19:11:21 +00:00
Valentin Rothberg 08e942383b vendor parallel-copy from containers/image
Parallel copying of layers is currently supported when pulling from
a registry to the storage.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-01-04 17:23:09 +01:00
Miloslav Trmač b77856eae3 Update for API changes
NOTE: This is a very minimal update; blobinfocache.go should be
substantially reworked to benefit from the cache instead of decompressing
layers to get the DiffID values.

Also removes some HasBlob checks in the blobinfocache test suite which don't have
a direct equivalent in the new API, and makes the test suite independent
of host's signature policy.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1218
Approved by: rhatdan
2018-12-07 15:11:36 +00:00
Nalin Dahyabhai 65707368d8 Use a blob cache when we're asked to use one
Add API hooks for designating locations to be used as blob caches when
pulling and pushing images.  When we commit read-only copies of
container layers for use in images, if we're using blob caching, store a
copy of the layer in the blob cache directory so that it can be found.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1149
Approved by: rhatdan
2018-12-04 18:53:15 +00:00
TomSweeneyRedHat 1e4d1eb31e Remove no longer valid todo
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1115
Approved by: rhatdan
2018-10-19 21:29:49 +00:00
Nalin Dahyabhai bc2ea08003 Make sure we log or return every error
Make sure that when attempting to diagnose an error, if we encounter an
error during the diagnostic attempt, we return the original error rather
than the error encountered in trying to diagnose it.  Log that one.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1072
Approved by: rhatdan
2018-10-07 12:07:09 +00:00
Nalin Dahyabhai 7ce41914c9 NewImageSource(): only create one Diff() at a time
Update github.com/containers/storage and github.com/containers/image,
and modify containerImageRef.NewImageSource() to account for the change
that the ReadCloser that store.Diff() returns now holds a lock until
it's closed, and because that's the same lock that store.PutLayer()
takes, we can't read more than one layer's contents at a time.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1024
Approved by: nalind
2018-09-27 13:32:50 +00:00
Daniel J Walsh ba012ddec6
Move buildah from projecatatomic/buildah to containers/buildah
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-09-18 08:06:11 -04:00
TomSweeneyRedHat 9af14c4540 Use manifest from container/image
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #870
Approved by: rhatdan
2018-07-19 15:42:01 +00:00
Daniel J Walsh a2c8358455 Vendor in latest containers/image and containers/storage
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #869
Approved by: rhatdan
2018-07-19 15:12:57 +00:00
umohnani8 6c4bef7f2e Add --layers and --no-cache to buildah bud
This patch adds in the caching feature to buildah bud.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #784
Approved by: rhatdan
2018-06-12 20:20:39 +00:00
Nalin Dahyabhai aa5cf3115e add/secrets/commit: Use mappings when setting permissions on added content
Use ID mapping information when setting permissions on content that we
add to the container, and on secrets that we copy in, on pipes that we
use for stdio, and when extracting the whole filesystem as a "layer".

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #700
Approved by: rhatdan
2018-05-24 14:10:01 +00:00
Nalin Dahyabhai c806e6e065 Implement --squash for build-using-dockerfile and commit
Handle a Squash option when committing images, and make it available as
a flag for "buildah commit" and "buildah build-using-dockerfile".

Breaks up containerImageRef.NewImageSource to keep the complexity more
manageable.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #714
Approved by: rhatdan
2018-05-22 16:43:58 +00:00
Nalin Dahyabhai 42d866f88a containerImageSource: return more-correct errors
Return errors indicating that a containerImageSource doesn't support
manifest lists when methods that take an instance digest are given
non-nil values, instead of the catch-all TODO errors that they used to
return.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #705
Approved by: rhatdan
2018-05-18 17:25:07 +00:00
Nalin Dahyabhai 523b1095d8 Add config --comment/--domainname/--history-comment/--hostname
Add options to "buildah config" for setting comment, domainname, and
hostname configuration bits, and the comment in history items which
describe layers that we add, and tests for them.  Add a test for the
--shell option while we're at it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #641
Approved by: rhatdan
2018-04-27 16:33:13 +00:00
umohnani8 9ffd47edca Vendor in latest containers/image and containers/storage
Changes to paramters in functions.
Change to the error returned by the oci and oci-archive transport.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #578
Approved by: rhatdan
2018-04-13 16:56:21 +00:00
umohnani8 669ffddd99 Vendor in latest containers/image
Fixes the naming issue of blobs and config for the dir transport
by removing the .tar extension

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #489
Approved by: rhatdan
2018-02-22 18:57:31 +00:00
Nalin Dahyabhai 86fa0803e8 Sanity check the history/diffid list sizes
When building an image's config blob, add a sanity check that the number
of diffIDs that we're including matches the number of entries in the
history which don't claim to be empty layers.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #383
Approved by: rhatdan
2018-01-08 21:06:35 +00:00
Nalin Dahyabhai 8b2b56d9b8 Update to work with newer image library
Update shallowCopy() to work with the newer version of image.
Remove things from Push() that we don't need to do any more.
Preserve digests in image names, make sure we update creation times, and
add a test to ensure that we can pull, commit, and push using such names
as sources.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #187
Approved by: rhatdan
2017-12-14 20:57:13 +00:00
Daniel J Walsh 8ecefa978c Vendor in changes to support sirupsen/logrus
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-10-10 17:30:11 +00:00
Nalin Dahyabhai 12a3abf6fa Update to match newer storage and image-spec APIs
Update to adjust to new types and method signatures in just-updated
vendored code.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #174
Approved by: rhatdan
2017-06-28 21:05:58 +00:00
Nalin Dahyabhai 4a05d8643d Add an option to specify a Create date for images
Add CommitOption option that to allow a caller to specify a creation
timestamp to use in images.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #141
Approved by: rhatdan
2017-06-13 21:50:42 +00:00