Commit Graph

39 Commits

Author SHA1 Message Date
Giuseppe Scrivano c174e91624
vendor: update c/{common,image,storage}
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-21 14:29:05 +01:00
Nalin Dahyabhai e3cd4d7904 Clear CommonBuildOpts when loading Builder status
When creating or loading a builder, ensure that its CommonBuildOpts
struct is not nil, to comply with an assumption that we keep making.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-08-16 14:46:39 -04:00
Daniel J Walsh 8d5d763213
Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

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

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-19 07:11:44 -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
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
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
Valentin Rothberg fb331c1861 restore push/pull and util API
Restore the push and pull API that commit dcd2a92e56 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 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 f280cd0285
Add --policy flag to buildah pull
This allows the user to specify the pull policy for pulling images.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-13 03:38:27 -05:00
Nalin Dahyabhai fba62fd0a2 Handle configuration blobs for manifest lists
When the base image or an image that we're inspecting is a reference to
a manifest list, resolve it to a runnable image instance, then try to
read the configuration blob from the runnable image.

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

Closes: #1960
Approved by: TomSweeneyRedHat
2019-11-05 14:38:30 +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 d7dec37df7 from/import: record the base image's digest, if it has one
Record the digest of the base image's manifest, if there is a base
image.

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

Closes: #1724
Approved by: rhatdan
2019-07-19 07:36:17 +00:00
Daniel J Walsh 3d74031301 Move pkg/chrootuser from libpod to buildah.
We don't want to vendor anything from libpod into Buildah.
We want to switch this around.  Moving pkg content from libpod
to Buildah allows us to fix this.

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

Closes: #1400
Approved by: giuseppe
2019-03-26 15:45:33 +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
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
baude b599244cd1 vendor in latest runtime-tools
The latest runtime-tools is aware of other OS's than Linux.  Libpod needs the newer
version to compile on darwin.  Unfortunately, the API for generator.New() changed
and requires a string representation of the OS; furthermore, it also returns a
a generator and an error so code had to be adjusted for this too.

Signed-off-by: baude <bbaude@redhat.com>
2018-06-26 15:49:39 -05:00
Miloslav Trmač 6cb7048d90 Consolidate loading manifest and config in initConfig
Both callers of initConfig contain exactly the same code
to load the manifest and config; move it inside initConfig
now that initConfig has the necessary types.Image available.

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

Closes: #776
Approved by: rhatdan
2018-06-17 12:37:24 +00:00
Miloslav Trmač 2283f62a38 Pass a types.Image to Builder.initConfig
Both callers of initConfig use a types.Image to get a manifest and
config; so, preserve the types.Image and pass it to Builder.initConfig.

This does not change behavior (except for making the lifetime of
a types.Image a bit longer in one case), but it will allow moving the
manifest/config load into Builder.initConfig in the future.

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

Closes: #776
Approved by: rhatdan
2018-06-17 12:37:24 +00:00
Miloslav Trmač 64df2d7bce Require an image ID in importBuilderDataFromImage
Both callers currently specify a non-empty image ID (because
all images have an ID, and all containers are created from
an image which has an ID); so, instead of "supporting" import
from non-images, fail.

This does not change behavior, but it will make future restructuring
easier.

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

Closes: #776
Approved by: rhatdan
2018-06-17 12:37:24 +00:00
Miloslav Trmač 35f6558e84 Do not ignore any parsing errors in initConfig
Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #776
Approved by: rhatdan
2018-06-17 12:37:24 +00:00
Nalin Dahyabhai 1395e1805a Read UID/GID mapping information from containers and images
Read UID/GID mapping information when creating or importing containers,
and if there is mapping information, use it when building runtime
configurations.

Mounting sysfs in a user namespace requires that we also have our own
network namespace, so default to creating one for that case.

Switch permissions on files that we bind in so that they're writable
from inside of the container.

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

Closes: #700
Approved by: rhatdan
2018-05-24 14:10:00 +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
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
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 7b5fed15ae Don't overwrite parent information when reading
Don't overwrite an image configuration's information about the source
image unless we're intending to create a new working container.

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

Closes: #141
Approved by: rhatdan
2017-06-13 21:50:42 +00:00
Nalin Dahyabhai c11936323a Fix inspect/tag-by-truncated-image-ID
Teach inspect and tag about image IDs, truncated and otherwise.

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

Closes: #138
Approved by: rhatdan
2017-06-08 18:31:31 +00:00
Nalin Dahyabhai 45d3e7953b Use errors.Errorf() instead of fmt.Errorf()
Use Errorf() from 'errors' rather than 'fmt' to help with stack traces.

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

Closes: #130
Approved by: rhatdan
2017-06-02 16:26:46 +00:00
Dan Walsh 8ced1276e5 Change functions that use a fmt.Errorf to wrap an err to error.Wrapf
Impove error reporting by wrapping all returned err functions with
error.Wrapf

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

Closes: #124
Approved by: nalind

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

Closes: #125
Approved by: nalind
2017-06-02 14:17:04 +00:00
Dan Walsh 59dfec35c3 buildah mount command should list mounts when no arguments are given.
buildah mount should work like the mount command and list all mount points
when no options are specified.

Need buildah umount to remove mount point from the database when a mount point
is umounted.

Also remove Mounts field from the builder object.  We only support a single mount
point so no reason for this field any longer.

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

Closes: #124
Approved by: nalind
2017-06-01 18:37:40 +00:00
Nalin Dahyabhai 9865ea3660 Add ImportBuilderFromImage()
Add a function for returning a Builder initialized from an image's
metadata, but which isn't tied to a container, so it can't be saved.

This refactored the existing importBuilder() implementation to split the
bits which locate the image based on the information it's given about a
container from the bits which build the structure using information read
from the image.

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

Closes: #109
Approved by: rhatdan
2017-05-19 11:29:12 +00:00
Nalin Dahyabhai fc880bcc86 Maintain multiple working container configs
Maintain the container configuration in multiple formats in the Buildah
object, initializing one based on the other, depending on which format
the source image used for its configuration.

Replace directly manipulated fields in the Buildah object (Annotations,
CreatedBy, OS, Architecture, Maintainer, User, Workdir, Env, Cmd,
Entrypoint, Expose, Labels, and Volumes) with accessor functions which
update both configurations and which read from whichever one we consider
to be authoritative.  Drop Args because we weren't using them.

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

Closes: #102
Approved by: rhatdan
2017-05-18 18:28:44 +00:00
Dan Walsh 95c2a2d99c Vendor in containers/storage and containers/image
Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Closes: #103
Approved by: nalind
2017-05-17 21:19:24 +00:00
Nalin Dahyabhai b7a598ca21 Fixup metalinter errors
Fix a number of issues flagged by gometalinter.

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

Closes: #62
Approved by: rhatdan
2017-04-12 21:25:35 +00:00
Daniel J Walsh 80f73013cd Remove link from CLI
We have decided not to support using the --link param in the CLI.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-03-23 14:59:20 -04:00
Nalin Dahyabhai a64f7d1187 Better distinguish between image names and IDs
When recording the origins of working containers, take better care to
distinguish between image names and IDs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-15 17:29:18 -04:00
Nalin Dahyabhai a0d394af74 Try to import containers that we didn't create
When we're given the name of a container on the command line, make every
command that attempts to open an in-progress build container fall back
to creating a new build configuration file for the specified container
if the container exists but wasn't originally created for a build.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-02-24 15:18:35 -05:00