Commit Graph

80 Commits

Author SHA1 Message Date
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
Daniel J Walsh 62babae27f Evaluate symbolic links on Add/Copy Commands
Users expect to be able to use Symbolic links in the
ADD and COPY commands in Dockerfiles.  We need to evaluate
these and pull in the correct content.

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

Closes: #1007
Approved by: nalind
2018-09-12 22:00:59 +00:00
Daniel J Walsh e8c123cc03 Change references to projectatomic/libpod to containers/libpod
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #928
Approved by: umohnani8
2018-08-15 20:13:50 +00:00
Nalin Dahyabhai 002c18a3bb Break out SetupIntermediateMountNamespace()
Break runSetupIntermediateMountNamespace() into its own package.
Move stringInSlice(), getHostIDs(), and getHostRootIDs() into the util
subdirectory and export them.

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

Closes: #796
Approved by: rhatdan
2018-06-18 18:38:54 +00:00
Nalin Dahyabhai ae27963cb0 Add(): learn to record hashes of what we add
Add a field to AddOrCopyOptions that can take an io.Writer, more often a
hash.Hash returned by digest.Digester's Hash() method, to calculate a
sum over what we add or copy.

Make the help output summarizing the arguments that "buildah add" and
"buildah copy" accept more closely match their man pages.

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

Closes: #766
Approved by: rhatdan
2018-06-11 12:39:05 +00:00
Nalin Dahyabhai 4874ad3365 Run: set supplemental group IDs
In Run(), when the userspec doesn't specify a group, if the specified
user has supplemental group memberships, pass them along to the runtime.

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

Closes: #700
Approved by: rhatdan
2018-05-24 14:10:01 +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 0afa60eb05 Add CLI options for specifying namespace and cgroup setup
Add options to the CLI that specify which cgroups we execute "run"
commands under, and controlling how we set up namespaces for them.
Pass them down to Builders that we create, and allow them to be
overridden by options passed to Builder.Run().

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

Closes: #700
Approved by: rhatdan
2018-05-24 14:10:01 +00:00
Fabio Bertinatto 61f5319504 Don't overwrite directory permissions on --chown
Signed-off-by: Fabio Bertinatto <fbertina@redhat.com>

Closes: #389
Approved by: rhatdan
2018-01-30 05:09:06 +00:00
Daniel J Walsh 01f8c7afee Remove chrootuser handling and use libpod/pkg
I have made a subpackage of libpod to handle chrootuser,
using the user code from buildah.

This patch removes user handling from buildah and uses
projectatomic/libpod/pkg/chrootuser

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

Closes: #377
Approved by: nalind
2018-01-03 15:36:10 +00:00
Fabio Bertinatto 1fc5a49958 Add --chown option to add/copy commands
Signed-off-by: Fabio Bertinatto <fbertina@redhat.com>

Closes: #336
Approved by: rhatdan
2017-12-07 13:45:12 +00:00
Daniel J Walsh 85476bf093 Buildah bud does not work with SELinux
buildah bud was not setting the mount label on the image
so SELinux in enforcing mode is blocking writing to the image

This patch also fixes a similar problem with the `buildah mount`
command

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

Closes: #332
Approved by: TomSweeneyRedHat
2017-11-22 15:36:51 +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 a6f7d725a0 Add/Copy need to support glob syntax
This patch allows users to do
buildah add $ctr * /dest

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

Closes: #194
Approved by: nalind
2017-07-17 20:11:48 +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
Nalin Dahyabhai 2048c74819 Cleanup: use FileInfo's own IsDir() method
Use os.FileInfo's IsDir() method instead of Mode().IsDir().

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

Closes: #120
Approved by: rhatdan
2017-05-24 19:48:09 +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
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
Nalin Dahyabhai 96d15578e4 Fixup golint warnings
Fix a number of issues flagged by golint.

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

Closes: #62
Approved by: rhatdan
2017-04-12 21:25:35 +00:00
Nalin Dahyabhai 19a7165783 Apply Last-Modified time as mtime when saving URLs
When saving the contents of a URL to a local file, attempt to set mtime
based on the response's Last-Modified header, if there is one.

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

Closes: #58
Approved by: nalind
2017-03-29 19:38:20 +00:00
Nalin Dahyabhai c8032d783b Handle ADD/COPY where the destination ends with /
When the destination for an ADD or COPY operation ends with a path
separator, take that as an indicator that the destination should be a
directory, that we should create it if it doesn't already exist, and
that any files we're copying should be placed in the directory.

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

Closes: #56
Approved by: rhatdan
2017-03-29 07:48:51 +00:00
Nalin Dahyabhai ce254f51fc Tweak ADDing/COPYing directories to copy contents
When copying or adding a source directory, copy the directory's contents
to the destination directory, to better match Dockerfile COPY behavior.

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

Closes: #50
Approved by: rhatdan
2017-03-28 19:42:47 +00:00
Nalin Dahyabhai 737fb9183d Merge pull request #29 from nalind/mount-copy
Mount the container for Copy
2017-03-24 12:14:19 -04:00
Nalin Dahyabhai 5354e9e04f Mount the container for Copy
In Copy(), instead of flagging a container not being mounted as an
error, do what we do in Run(), which is to mount it first and then
unmount when we're done.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-23 17:37:23 -04:00
Nalin Dahyabhai 8bbc3a5a9c Tweak copying behavior so that dest can be a file
Change copy behavior so that the destination can be a file rather than a
directory if we're copying a single item.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-23 17:28:51 -04:00
Nalin Dahyabhai ae1fffb3fd Always make sure the working directory exists
Always make sure the working directory exists before attempting to run
anything inside of it, and before attempting to copy contents into it or
one of its subdirectories.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-23 14:57:00 -04:00
Nalin Dahyabhai 95312390d7 Use chrootarchive to head off tar shenanigans
Use the chrootarchive package instead of the archive package in the
implementation of "add", in an attempt to avoid problems with tarballs
with unusual paths in their headers.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-21 14:26:00 -04:00
Nalin Dahyabhai 3b44a3e3b3 Simplify copy/add logic to better match dockerd's
Simplify our implementation of copy/add to always assume that the
destination location will be a directory.  Trying to be cleverer, like
cp is, would just be confusing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-07 13:26:17 -05:00
Nalin Dahyabhai e467bea0aa Add "add" and "copy" commands
Add "add" and "copy" CLI commands, which end up calling the same buildah
method, differing only in whether or not they tell it to attempt to
extract local sources when those sources appear to be archive files
("add" does, "copy" does not).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-06 15:39:22 -05:00