Commit Graph

170 Commits

Author SHA1 Message Date
Nalin Dahyabhai bb149ea686 Use errors.Is() instead of os.Is{Not,}Exist
If errors for which os.IsExist() or os.IsNotExist() would have returned
true have been wrapped using fmt.Errorf()'s "%w" verb, os.IsExist() and
os.IsNotExist(), not having been retrofitted to use errors.Is(), will
return false.

Use errors.Is() to check if an error is an os.ErrExist or os.ErrNotExist
error instead of calling os.IsExist() or os.IsNotExist().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-07-26 15:36:58 -04:00
Sascha Grunert ce384684c0
Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 11:41:47 +02:00
Nalin Dahyabhai dc5c30c289 buildah.BuilderOptions.DefaultEnv is ignored, so mark it as deprecated
Any `buildah.BuilderOptions.DefaultEnv` values have been ignored since
the libary was changed to read them from the server-side configuration,
for the sake of podman remote builds.  Update its godoc to note that and
stop setting it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-05-03 16:11:26 -04:00
Aditya Rajan 40b4d937ce
executor: Share selinux label of first stage with other stages in a build
Buildah `builds` are composed of various `stages`. That is each `stage` in a build is a `container`.

As of now buildah does not provides any `processLabel` and `mountLabel` to the stage containers which
results in `c/storage` assigning random generated `selinux` labels to each stage.

If each stage has its own unqiue `processLabel` and `mountLabel` stages cannot be mounted across each other
in the same build as `selinux` prevents that.

We get the `processLabel` and `mountLabel` of the first stage created by the executor ( label assigned by `c/stoage` )
and share it with all the other subsequent stages of the same build.

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2022-01-09 20:49:05 +05:30
Paul Holzinger f9cff07b81
use libnetwork from c/common for networking
Podman uses the new netavark network stack. Buildah should be able to do
the same. Both projects should use the same networking code which was
move to c/common/libnetwork. The new network interface can use either
CNI or netvavark. Using the same code for podman and buildah is
important to ensure that both use the same backend. Mixing CNI and
netavark is not supported.

This also fixes some outstanding CNI issues, e.g. buildah trying to
connect all cni networks.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-07 18:10:26 +01:00
Daniel J Walsh a73e108bd0
Allow callers to replace the ContainerSuffix
This idea of this PR is to allow Podman to add a Podman
prefix to containers. This would allow it to keep track
of containers created by Podman and make it easier to remove
them when it wants to remove all.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-19 06:15:35 -05:00
Daniel J Walsh 5b1b0d27ca
Wire logger through to config
Currently we are only wiring the logger into run_linux.go
Not into the Config section.

This PR is needed in order to update vendor in Podman.
https://github.com/containers/podman/pull/12375

[NO NEW TESTS NEEDED] Tests will be done in Podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-03 09:27:55 -05:00
Kirill Shirinkin 2d822034f8 Rename bud to build, while keeping an alias for to bud.
Signed-off-by: Kirill Shirinkin <kirill@hey.com>
2021-08-25 17:56:58 +02:00
Nalin Dahyabhai ae08e01e49 bud: teach --platform to take a list
Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.

Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.

Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.

In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).

In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it.  In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on.  Two processes could still try to create the same list
twice, but it's an incremental improvement.

Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-08-04 15:23:10 -04:00
Daniel J Walsh d7d078561c
Send logrus messages back to caller when building
We want Info, Warning and Debug logrus messages to be writen to the
buildah stderr. this way when podman-remote is using build, it will
get the messages back on the client side.

[NO TESTS NEEDED] Since this will be tested in Podman.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-15 03:55:05 -04:00
Nalin Dahyabhai dfe404f3de CLI add/copy: add a --from option
Add a --from option to `buildah add` and `buildah copy`, mirroring the
option for the Dockerfile instruction.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-08 13:21:26 -04: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
TomSweeneyRedHat 2efb6cc555 Reset upstream branch to dev version
Reset back to v1.20.0-dev for the upstream branch.
Any 1.19.* releases should come out of that release branch.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2021-01-16 12:11:39 -05:00
Daniel J Walsh aba61cdec4
Fix version of release to v1.19.1
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-14 16:47:41 -05:00
TomSweeneyRedHat 4f7c609f67 Bump to v1.20.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2021-01-08 14:35:43 -05:00
TomSweeneyRedHat 474febf0dc Bump to v1.19.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2021-01-08 14:30:59 -05:00
TomSweeneyRedHat a65e628f2c Bump to v1.19.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-11-16 09:45:35 -05:00
TomSweeneyRedHat d3a01d0041 Bump to v1.18.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-11-16 09:25:22 -05:00
TomSweeneyRedHat 7098e0e21f Bump to v1.18.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-10-29 18:36:52 -04:00
TomSweeneyRedHat 8891d05dba Bump to v1.17.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-10-29 18:33:13 -04: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
baude 681e3eff98 refactor pullpolicy to avoid deps
refeactor the pullpollicy to its own package so that it can be imported on its own without deps like containers/storage, etc. this will help consuming podman's go bindings.

Signed-off-by: baude <bbaude@redhat.com>
2020-10-12 13:17:31 -05:00
Nalin Dahyabhai bf41a3d707 Makefile: tweak the cross-compile target
What `go tool dist list` says the toolchain supports changes, so this
change removes these attempted cross-compile build targets.
* GOOS=darwin, GOARCH unspecified
* GOOS=darwin, GOARCH=386

Replace our use of slices of
github.com/opencontainers/runc/libcontainer/configs.Device structures
with a locally-defined type alias so that we can avoid importing the
package on non-Unixy systems.  The result is not going to be a very
useful binary on non-Linux systems, but it helps ensure that our
subpackages won't break compilation for other projects who consume us as
a library.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-09-24 12:09:48 -04:00
Daniel J Walsh 87f3fa59d8
Timestamp gets updated everytime you inspect an image
I don't see a purpose of this field in the History log, removing.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-08 16:33:43 -04:00
TomSweeneyRedHat 785a750886 Bump to v1.17.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-09-03 17:19:05 -04:00
TomSweeneyRedHat 295b825cdc Bump to v1.16.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-09-03 17:19:05 -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
TomSweeneyRedHat 038a24b6a3 Bump to v1.16.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-06-17 13:20:13 -04:00
TomSweeneyRedHat 368c41b8ed Bump to v1.15.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-06-17 13:20:13 -04: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
TomSweeneyRedHat fbab7d4705 Bump to v1.15.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-02-06 19:22:39 -05:00
TomSweeneyRedHat 5965d9acff Bump to v1.14.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-02-06 19:22:39 -05:00
TomSweeneyRedHat 3177db512b Bump back to v1.14.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2122
Approved by: rhatdan
2020-01-31 00:45:10 +00:00
TomSweeneyRedHat b8a8a01c6c Bump to v1.13.2
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2122
Approved by: rhatdan
2020-01-31 00:45:10 +00:00
Daniel J Walsh 09d1c24e3d Add support for containers.conf
This is a rework of Qi Wang's patches.
Import package pkg/config from containers/common to read containers.conf
This patch allows users to specify default values stored in containers.conf
that will modify the behaviour of buildah tool.

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

Closes: #2011
Approved by: TomSweeneyRedHat
2020-01-15 17:24:36 +00:00
TomSweeneyRedHat bf14e6ca2d Bump back to v1.14.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2081
Approved by: rhatdan
2020-01-14 17:27:04 +00:00
TomSweeneyRedHat e8c07c6eac Bump to v1.13.1
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2081
Approved by: rhatdan
2020-01-14 17:27:04 +00:00
TomSweeneyRedHat 4b5437a981 Bump to v1.14.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2053
Approved by: rhatdan
2019-12-28 11:28:25 +00:00
TomSweeneyRedHat 57bd81884c Bump to v1.13.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2053
Approved by: rhatdan
2019-12-28 11:28:25 +00:00
TomSweeneyRedHat de31778eec Bump to v1.13.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2019-12-13 11:42:33 -05:00
TomSweeneyRedHat 6cc46567d1 Bump to v1.12.0
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2019-12-13 11:39:25 -05:00
Daniel J Walsh cd88667465 Ran buildah through codespell
Thanks to Dmitry Smirnov @onlyjob for suggesting this tool.

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

Closes: #1985
Approved by: TomSweeneyRedHat
2019-11-20 17:38:41 +00:00
TomSweeneyRedHat 85ab067e58 Bump back to v1.12.0-dev
Closes: #1978
Approved by: rhatdan
2019-11-12 04:31:12 +00:00
TomSweeneyRedHat 7c97335f2c Bump to v1.11.5
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1978
Approved by: rhatdan
2019-11-12 04:31:12 +00:00
TomSweeneyRedHat 89bc2a6a6a Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)

Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.

To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.

In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.

Changes both the from and bud commands.

Addresses: #1675

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

Closes: #1959
Approved by: rhatdan
2019-11-06 22:20:24 +00:00
TomSweeneyRedHat c2dc46a478 Bump back to v1.12.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1946
Approved by: rhatdan
2019-10-28 17:37:31 +00:00
TomSweeneyRedHat 21b4778b35 Bump to v1.11.4
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1946
Approved by: rhatdan
2019-10-28 17:37:31 +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
TomSweeneyRedHat 7a7e1f07ee Bump back to v1.12.0-dev
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1896
Approved by: rhatdan
2019-10-04 17:45:51 +00:00