1
0
mirror of https://github.com/containers/buildah.git synced 2025-04-19 18:02:18 +03:00

84 Commits

Author SHA1 Message Date
Daniel J Walsh
eca0c9cda4
Check earlier for bad image tags name
Fixes: https://github.com/containers/buildah/issues/3134

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-12 17:07:14 -04:00
Valentin Rothberg
fb331c1861 restore push/pull and util API
Restore the push and pull API that commit dcd2a92e5669 removed.
These changes would break vendoring into openshift/builder due
to build errors.

For the same reason, restore `util.FindImage` and `util.AddImageNames`
but deprecate the `findRegistry` argument.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-04-23 12:50:31 +02:00
Valentin Rothberg
dcd2a92e56 use new containers/common/libimage package
Move all code related handling container image over to the new
`libimage` package in containers/common.  The new package is an
attempt to consolidate the code across the containers tools under the
github.com/containers umbrella.

The new `libimage` packages provides functionality to perform all kinds
of operations for managing images such as local lookups, pushing,
pulling, listing, removing, etc.

The following packages have been moved over the containers/common:

`manifests` -> `common/image/manifests`
`pkg/manifests` -> `common/pkg/manifests`
`pkg/supplemented` -> `common/pkg/supplemented`

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-04-22 17:39:00 +02:00
Daniel J Walsh
73f2f84595
Output names of multiple tags in buildah bud
Buildah currently handles multiple tags when building, but does not
report it to the user by default. This reports the tags back to the
user.

Removed some unused code from commit.go, that would blow up if a user
specified AdditionalTags to the commit command, even though this is not
exposed to the user currently.  In a previous try to fix this, the
removed code was causing breakage, and I did not see a real purpose in
the code.

Fixes: https://github.com/containers/buildah/issues/3084

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-21 08:06:53 -04:00
Valentin Rothberg
2301d148da --iidfile: print hash prefix
Prefix the image ID with the hash prefix when using `--iidfile` to be
compatible with Docker.  The absence of the hash can cause
docker-compose to error out.

Reported-in: github.com/containers/podman/issues/9260
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-08 12:24:56 +01:00
Daniel J Walsh
5b350b9a3f
Finish plumbing for buildah bud --manifest
Buildah bud --manifest XYZ was not working.

The manifest was never created. This PR Finishes
the plumbing and allows users to create a manifest
while building an image in one single command.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-05 12:36:48 -05:00
Daniel J Walsh
7acdfe8e8d
Add support for --manifest flags
This patch allows users to build a multi arch image with simple commands
using emulation software.

```
buildah bud --arch arm --manifest myimage /tmp/mysrc
buildah bud --arch amd64 --manifest myimage /tmp/mysrc
buildah bud --arch s390x --manifest myimage /tmp/mysrc
```

And something like this for buildah commit
```
build() {
	ctr=$(./bin/buildah from --arch $1 ubi8)
	./bin/buildah run $ctr dnf install -y iputils
	./bin/buildah commit --manifest ubi8ping $ctr
}
build arm
build amd64
build s390x
```

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-07 14:41:02 -05: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
Qi Wang
2ddc22c2dd Skip tlsVerify insecure BUILD_REGISTRY_SOURCES
If the registry is set to insecure allowd using BUILD_REGISTRY_SOURCES, hardcode to skip the tls verify to avoid the errors.
Returns error if set insecureRegistries but force to use tls-verify.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-10-13 15:57:42 -04:00
bors[bot]
438046e88d
Merge #2573
2573: Heed our retry delay option values when retrying commit/pull/push r=TomSweeneyRedHat a=nalind

#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

Pass in our own API values for retry delays to common's retry package when we use it to handle retrying image pull/commit/push operations.

#### How to verify it

Attempt to pull an image from a registry which can't be reached, which is considered a transient error that we'll retry on:
  `buildah pull --debug 127.0.0.0/bogus`
Our CLI's default is to retry with a fixed delay of 2 seconds after each failed attempt, while the retry package's default behavior is to use progressively longer delays after each attempt, so if each attempt retries after 2 seconds, the change is having the desired effect.

#### Which issue(s) this PR fixes:

None

#### Special notes for your reviewer:

This undoes a behavior change we'd otherwise have made compared to 1.15.x.

#### Does this PR introduce a user-facing change?

```
None
```

Co-authored-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-29 21:33:27 +00:00
Nalin Dahyabhai
ad7cfc3e9b Heed our retry delay option values when retrying commit/pull/push
Pass our own API values for retry delays to common's retry package when
we use it to handle retrying image pull/commit/push operations.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-28 15:20:28 -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
Qi Wang
cea59d97c9 Replace retry functions with common/pkg/retry
Use retry pacakge from containers/common and change the retryDelay to exponential backoff from there.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-08-13 15:28:56 -04:00
Brent Baude
8b360f6e04 remove dependency on openshift struct
use of github.com/openshift/api/config/v1 is costly in size, something around 10MB.  removal of this dependancy and using a locally defined struct took the buildah executable size from around 38MB to around 27MB.  This also hits libpod and allows it also shed that size as well.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-22 14:41:18 -05:00
Brandon Lum
054a14b63d clean up comments
Signed-off-by: Brandon Lum <lumjjb@gmail.com>
2020-05-18 21:27:24 +00:00
Brandon Lum
57706e134d Implement commit for encryption
Signed-off-by: Brandon Lum <lumjjb@gmail.com>
2020-05-18 21:27:24 +00:00
Brandon Lum
37df2b9690 implementation of encrypt/decrypt push/pull/bud/from
Signed-off-by: Brandon Lum <lumjjb@gmail.com>
2020-05-18 21:27:23 +00:00
Nalin Dahyabhai
b72bda2dff pull/from/commit/push: retry on most failures
If PullOptions/BuilderOptions/CommitOptions/PushOptions includes a
MaxRetries value other than 0, retry operations except for (currently)
connection-refused, authentication, and no-such-repository/no-such-tag
errors, at a default-but-configurable interval of 5 seconds.

Set the default for `buildah pull/from/commit/push` to 3 retries at 2
second intervals.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-02-10 14:07:10 -05:00
Sascha Grunert
6417a9a074 Allow users to set OS and architecture on bud
When building images we now allow the architecture and operating system
to be overwritten via the new `--os` and `--arch` flags. This allows the
use case of packing pre-built or cross-compiled binaries into container
images with specifying the correct environment. The `--platform` flag
now takes the `os/arch` format into account as well.

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

Closes: #2097
Approved by: rhatdan
2020-01-21 12:25:09 +00:00
Nalin Dahyabhai
a925f79cc3 add --sign-by to bud/commit/push, --remove-signatures for pull/push
Add the --sign-by option to `buildah build-using-dockerfile`,
`buildah commit`, `buildah push`, and `buildah manifest push`.  Add the
`--remove-signatures` option to `buildah pull`, `buildah push`, and
`buildah manifest push`.  We just pass them to the image library, which
does all of the heavy lifting.

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

Closes: #2085
Approved by: rhatdan
2020-01-17 18:22:34 +00:00
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