1
0
mirror of https://github.com/containers/buildah.git synced 2025-04-25 14:42:29 +03:00

64 Commits

Author SHA1 Message Date
caiges
9ff68b3cde Add builder identity annotations.
Use io.podman.version and fix inspect tests

Signed-off-by: caiges <caigesn@gmail.com>

Closes: #1917
Approved by: TomSweeneyRedHat
2019-11-16 19:27:47 +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
Nalin Dahyabhai
441f2b825e Commit: check for storage.ErrImageUnknown using errors.Cause()
The storage library can return its errors wrapped in additional context,
so to do a direct comparison we need to dig down to the root cause.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-10 19:15:53 -04: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
0bb4f3112c pull/commit/push: pay attention to $BUILD_REGISTRY_SOURCES
If $BUILD_REGISTRY_SOURCES is set, expect it to be a valid
github.com/openshift/api/config/v1.Image, and parse its
AllowedRegistries and BlockedRegistries lists when, pulling, committing,
or pushing images.

Override the local signature policy when committing or pushing an image
to ensure that local storage is always allowed.

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

Closes: #1787
Approved by: rhatdan
2019-08-29 18:42:16 +00:00
Sascha Grunert
8e58ba3cdb
Add unconvert linter and apply fixes
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-07-18 10:37:38 +02:00
Sascha Grunert
16e301031e Add unparam linter and apply fixes
This commit enabled the `unparam` linter and applies all reported issues.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>

Closes: #1719
Approved by: rhatdan
2019-07-16 21:21:32 +00:00
Nalin Dahyabhai
3bf8547fe7 Avoid fmt.Printf() in the library
Avoid calling fmt.Printf() to print things in library logic, which can't
be controlled or suppressed by callers.  Prefer returning values and
printing them in our CLI wrapper, as callers would.

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

Closes: #1596
Approved by: rhatdan
2019-05-16 23:19:49 +00:00
Nalin Dahyabhai
c654b18cad commit/push: use an everything-allowed policy
Ignore the global signature policy, which is used to control whether or
not we can trust an image, when we're attempting to commit an image from
a container, or pushing an image.

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

Closes: #1579
Approved by: rhatdan
2019-05-10 18:09:37 +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
6306386e07 CommitOptions: drop the unused OnBuild field
We don't read the contents of the OnBuild field in CommitOptions, so
drop it from the structure definition.

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
610eb7a0b2 commit: make target image names optional
Make the name of the image to create an optional parameter.  If none is
specified, use a temporary mostly-random name that can't be interpreted
as an ID, so that the image copying logic will compute the correct ID to
assign to the new image, and remove the temporary name before returning.

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

Closes: #1486
Approved by: rhatdan
2019-04-08 21:21:09 +00:00
Nalin Dahyabhai
8d772ab21c CommitOptions: drop the redundant Store field
The Builder object already keeps a pointer to the Store that holds its
container, so a second value that could be different is just confusing.

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

Closes: #1444
Approved by: TomSweeneyRedHat
2019-03-27 08:27:43 +00:00
Douglas Schilling Landgraf
be0c8d263b golint: make golint happy
should omit type ... from declaration of var ...; it will be
inferred from the right-hand side

Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>

Closes: #1426
Approved by: nalind
2019-03-20 20:49:33 +00:00
Daniel J Walsh
1ba9201f38 Remove mistaken code that got merged in other PR
Miloslav had some good comments on a previous commit.

https://github.com/containers/buildah/pull/1411

These changes address his issues by removing them.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1412
Approved by: mtrmac
2019-03-18 21:14:30 +00:00
Daniel J Walsh
939de6f4d9 Allow rootless users to use the cache directory in homedir
Currently rootless podman attempts to write to /var/lib/containers/cache
and fails. This causes us to repeatedly push images that have already been
pushed.  This cache directory should be relative to the location of containers/storage
and not always stored in the same directory.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1411
Approved by: TomSweeneyRedHat
2019-03-14 14:25:09 +00:00
TomSweeneyRedHat
f1cec509e0 Add Quiet to PullOptions and PushOptions
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Add Quiet to the PullOptions and PushOptions structures.
If set to true output will be in 'quiet' mode.  This
will primarily be used by callers such as OpenShift.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1302
Approved by: rhatdan
2019-01-23 20:40:14 +00: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
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
Nalin Dahyabhai
4243d7b8ba Add --disable-compression to 'build-using-dockerfile'
Add a --disable-compression flag to the 'build-using-dockerfile'
command, and set OCIAcceptUncompressedLayers and DirForceCompress in the
SystemContext during Commit() and Push() based on whether or not the
flag is set.

For other transports, we still end up going with the receiver's
preference, so update the man page to mention that this controls a
default.

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

Closes: #1149
Approved by: rhatdan
2018-12-04 18:53:15 +00:00
Nalin Dahyabhai
189ebeccd7 Update for changes in the containers/image API
Copying an image now returns the manifest of the written image.  Return
the digest of that manifest, and a canonical reference, from our Commit
and Push APIs.

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

Closes: #1097
Approved by: rhatdan
2018-10-15 21:27:07 +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
318fc8940f Enforce "blocked" for registries for the "docker" transport
Check if reading and writing from the registry named by an image is
allowed when the transport is "docker".

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

Closes: #1056
Approved by: rhatdan
2018-10-05 15:30:11 +00:00
Nalin Dahyabhai
62c01da3e4 Correctly set DockerInsecureSkipTLSVerify when pulling images
The image library's copy routine doesn't itself consult the registries
configuration in order to decide whether or not to disable TLS
verification when communicating with a registry, so it's on us to use
the name of a source or destination image to decide whether to set the
flag for that behavior.

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

Closes: #1056
Approved by: rhatdan
2018-10-05 15:30:11 +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
Zhou Hao
8ff6c26495 push: show image digest after push succeed
After change :

```
➜  buildah git:(push-fix) ✗ sudo ./buildah push 71c dir:/home/zhouhao/test/buildah
Getting image source signatures
Copying blob sha256:cdb3f9544e4c61d45da1ea44f7d92386639a052c620d1550376f22f5b46981af
 55.73 MiB / 55.73 MiB [====================================================] 1s
Copying blob sha256:7f2cffb520ed710c0871cd07f4fd8041d67fb9b4a74e03d036db55c23a085840
 51.81 MiB / 51.81 MiB [====================================================] 0s
Copying blob sha256:64ef7c2d456f323178e92fd11fd6819c4b913ffedf3d27f8bf12702e6f953d36
 3.50 KiB / 3.50 KiB [======================================================] 0s
Copying config sha256:71c43202b8ac897ff4d048d3b37bdf4eb543ec5c03fd017c3e12c616c6792206
 5.88 KiB / 5.88 KiB [======================================================] 0s
Writing manifest to image destination
Storing signatures
Succefully pushed /home/zhouhao/test/buildah@d963acde7543161ad481fa33d4d03dcbd826826385c8155a5d6b3c89cb297fbb
```

Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>

Closes: #992
Approved by: rhatdan
2018-09-10 14:22:57 +00:00
Nalin Dahyabhai
b533b5bb0e commit: recognize committing to second storage locations
Recognize cases when we're committing to local storage, but in a
location other than where the working container is, by checking if the
base image (by ID, in case it's tagged and the tag points to a different
image with different layers) is present in the destination's store.

In those cases, we can't just assume that we can skip exporting the base
image's layers.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-06-25 16:46:41 -04: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
Daniel J Walsh
b66e853145 Add OnBuild support for Dockerfiles
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #722
Approved by: mheon
2018-05-31 13:30:29 +00:00
Nalin Dahyabhai
71f0f9d063 build-using-dockerfile: add --annotation
Add an --annotation flag to "buildah build-using-dockerfile".

Refactor the logic for --label handling to use SetLabel() to set them in
the image configuration in Executor.Commit(), instead of passing them as
a field in CommitOptions for Builder.Commit() and expecting it to do so.

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

Closes: #716
Approved by: rhatdan
2018-05-22 19:27:45 +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
Daniel J Walsh
02cc30ba17 Add support for buildah bud --label
We want to be able to add labels when building a container image.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #698
Approved by: umohnani8
2018-05-18 14:03:35 +00:00
Matthew Heon
a4f5707eeb Do not print directly to stdout in Commit()
Buildah is being used as a library in Podman, and as such should
avoid printing directly to standard streams. Instead, return an
image ID which can be printed by the caller (if desired)

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #647
Approved by: rhatdan
2018-05-02 21:03:39 +00:00
Nalin Dahyabhai
44468f811c Force "localhost" as a default registry
Extend util.ResolveName() to prepend "localhost" to the list of
registries, and teach util.FindImage(), util.ExpandNames(), and
util.AddImageNames() to use util.ResolveName().

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

Closes: #648
Approved by: rhatdan
2018-05-02 19:52:53 +00:00
Daniel J Walsh
3088277ee8 Add support for --iidfile to bud and commit
Add support for an --iidfile which specifies the file to write the
image id, when committing a new image.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #636
Approved by: TomSweeneyRedHat
2018-04-26 12:19:43 +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
TomSweeneyRedHat
b81af1e212 Display imageId after commit
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #566
Approved by: rhatdan
2018-04-12 12:15:33 +00:00
Nalin Dahyabhai
12114812da Remove shallowCopy(), which shouldn't be saving us time any more
Remove shallowCopy(), which shouldn't be saving us time any more since
containers/image's storage transport's HasBlob() implementation was last
updated.

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

Closes: #508
Approved by: rhatdan
2018-03-06 01:38:00 +00:00
Nalin Dahyabhai
9ff37b0cf0 shallowCopy: avoid a second read of the container's layer
Avoid reading the container's layer a second time in shallowCopy (after
the first time it's read, in NewImageSource()).

Our second copy of the diff isn't going to match the first one if it's
of any serious size, because when NaiveDiff is used to generate the
diff, whiteout entries have their times set to "now", rather than a
fixed value, which causes both the uncompressed and compressed digests
to differ from what NewImageSource() records in the manifest.

Instead, use the generic manifest-reading API that the image library
now provides to read the layer info list and the config blob info, and
use their values to PutBlob() them to the destination image.

We can probably drop shallowCopy() completely, since the newer version
of the image library has a more reliable HasBlob(), which should save us
the time that shallowCopy() was originally meant to save, but we should
probably consider the use of compression for this code path as part of
that, too.

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

Closes: #506
Approved by: rhatdan
2018-03-04 15:26:24 +00:00
Nalin Dahyabhai
47ac96155f Use configured registries to resolve image names
When locating an image for pulling, inspection, or pushing, if we're
given an image name that doesn't include a domain/registry, try building
a set of candidate names using the configured registries as domains, and
then pull/inspect/push using the first of those names that works.

If a name that we're given corresponds to a prefix of the ID of a local
image, skip completion and use the ID directly instead.

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

Closes: #360
Approved by: rhatdan
2017-12-14 22:21:16 +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
TomSweeneyRedHat
15792b227a Allow push to use the image id
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #341
Approved by: nalind
2017-11-30 23:47:13 +00:00
Urvashi Mohnani
4419612150 Add manifest type conversion to buildah push
buildah push supports manifest type conversion when pushing using the 'dir' transport
Manifest types include oci, v2s1, and v2s2
e.g buildah push --format v2s2 alpine dir:my-directory

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

Closes: #321
Approved by: rhatdan
2017-11-15 13:38:28 +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
Daniel J Walsh
f6c2a1e24e Make sure pushing ends up with CLI on a fresh new line
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #275
Approved by: rhatdan
2017-09-29 15:58:39 +00:00
TomSweeneyRedHat
c9c735e20d Add authentication to commit and push
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #250
Approved by: rhatdan
2017-08-29 15:20:19 +00:00
TomSweeneyRedHat
498f0ae9d7 Add credentials to buildah from
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Add credentials to buildah from

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #204
Approved by: nalind
2017-08-22 18:55:38 +00:00
Nalin Dahyabhai
265d2da6cf Always free signature.PolicyContexts
Whenever we create a containers/image/signature.PolicyContext, make sure
we don't forget to destroy it.

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

Closes: #231
Approved by: rhatdan
2017-08-14 12:02:07 +00:00