summaryrefslogtreecommitdiff
path: root/vendor/github.com/projectatomic/buildah/new.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/projectatomic/buildah/new.go')
-rw-r--r--vendor/github.com/projectatomic/buildah/new.go35
1 files changed, 33 insertions, 2 deletions
diff --git a/vendor/github.com/projectatomic/buildah/new.go b/vendor/github.com/projectatomic/buildah/new.go
index 82de524c0..edc1b898e 100644
--- a/vendor/github.com/projectatomic/buildah/new.go
+++ b/vendor/github.com/projectatomic/buildah/new.go
@@ -54,7 +54,7 @@ func reserveSELinuxLabels(store storage.Store, id string) error {
}
return err
}
- // Prevent containers from using same MCS Label
+ // Prevent different containers from using same MCS label
if err := label.ReserveLabel(b.ProcessLabel); err != nil {
return err
}
@@ -133,6 +133,22 @@ func imageManifestAndConfig(ctx context.Context, ref types.ImageReference, syste
return nil, nil, nil
}
+func newContainerIDMappingOptions(idmapOptions *IDMappingOptions) storage.IDMappingOptions {
+ var options storage.IDMappingOptions
+ if idmapOptions != nil {
+ options.HostUIDMapping = idmapOptions.HostUIDMapping
+ options.HostGIDMapping = idmapOptions.HostGIDMapping
+ uidmap, gidmap := convertRuntimeIDMaps(idmapOptions.UIDMap, idmapOptions.GIDMap)
+ if len(uidmap) > 0 && len(gidmap) > 0 {
+ options.UIDMap = uidmap
+ options.GIDMap = gidmap
+ } else {
+ options.HostUIDMapping = true
+ options.HostGIDMapping = true
+ }
+ }
+ return options
+}
func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions) (*Builder, error) {
var ref types.ImageReference
var img *storage.Image
@@ -258,6 +274,8 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
}
coptions := storage.ContainerOptions{}
+ coptions.IDMappingOptions = newContainerIDMappingOptions(options.IDMappingOptions)
+
container, err := store.CreateContainer("", []string{name}, imageID, "", "", &coptions)
if err != nil {
return nil, errors.Wrapf(err, "error creating container")
@@ -278,6 +296,9 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
if err != nil {
return nil, err
}
+ uidmap, gidmap := convertStorageIDMaps(container.UIDMap, container.GIDMap)
+ namespaceOptions := DefaultNamespaceOptions()
+ namespaceOptions.AddOrReplace(options.NamespaceOptions...)
builder := &Builder{
store: store,
@@ -293,7 +314,17 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
ProcessLabel: processLabel,
MountLabel: mountLabel,
DefaultMountsFilePath: options.DefaultMountsFilePath,
- CommonBuildOpts: options.CommonBuildOpts,
+ NamespaceOptions: namespaceOptions,
+ ConfigureNetwork: options.ConfigureNetwork,
+ CNIPluginPath: options.CNIPluginPath,
+ CNIConfigDir: options.CNIConfigDir,
+ IDMappingOptions: IDMappingOptions{
+ HostUIDMapping: len(uidmap) == 0,
+ HostGIDMapping: len(uidmap) == 0,
+ UIDMap: uidmap,
+ GIDMap: gidmap,
+ },
+ CommonBuildOpts: options.CommonBuildOpts,
}
if options.Mount {