mirror of
https://github.com/containers/podman.git
synced 2025-09-27 16:54:42 +08:00
[NO TESTS NEEDED] Vendor in containers/buildah v1.20.0
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
62
vendor/github.com/containers/buildah/pkg/parse/parse.go
generated
vendored
62
vendor/github.com/containers/buildah/pkg/parse/parse.go
generated
vendored
@ -14,7 +14,7 @@ import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/containers/buildah"
|
||||
"github.com/containers/buildah/define"
|
||||
"github.com/containers/image/v5/types"
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
"github.com/containers/storage/pkg/unshare"
|
||||
@ -45,7 +45,7 @@ var (
|
||||
)
|
||||
|
||||
// CommonBuildOptions parses the build options from the bud cli
|
||||
func CommonBuildOptions(c *cobra.Command) (*buildah.CommonBuildOptions, error) {
|
||||
func CommonBuildOptions(c *cobra.Command) (*define.CommonBuildOptions, error) {
|
||||
var (
|
||||
memoryLimit int64
|
||||
memorySwap int64
|
||||
@ -125,7 +125,7 @@ func CommonBuildOptions(c *cobra.Command) (*buildah.CommonBuildOptions, error) {
|
||||
ulimit, _ = c.Flags().GetStringSlice("ulimit")
|
||||
}
|
||||
|
||||
commonOpts := &buildah.CommonBuildOptions{
|
||||
commonOpts := &define.CommonBuildOptions{
|
||||
AddHost: addHost,
|
||||
CPUPeriod: cpuPeriod,
|
||||
CPUQuota: cpuQuota,
|
||||
@ -150,7 +150,7 @@ func CommonBuildOptions(c *cobra.Command) (*buildah.CommonBuildOptions, error) {
|
||||
return commonOpts, nil
|
||||
}
|
||||
|
||||
func parseSecurityOpts(securityOpts []string, commonOpts *buildah.CommonBuildOptions) error {
|
||||
func parseSecurityOpts(securityOpts []string, commonOpts *define.CommonBuildOptions) error {
|
||||
for _, opt := range securityOpts {
|
||||
if opt == "no-new-privileges" {
|
||||
return errors.Errorf("no-new-privileges is not supported")
|
||||
@ -611,7 +611,7 @@ func SystemContextFromOptions(c *cobra.Command) (*types.SystemContext, error) {
|
||||
if err == nil && c.Flag("registries-conf-dir").Changed {
|
||||
ctx.RegistriesDirPath = regConfDir
|
||||
}
|
||||
ctx.DockerRegistryUserAgent = fmt.Sprintf("Buildah/%s", buildah.Version)
|
||||
ctx.DockerRegistryUserAgent = fmt.Sprintf("Buildah/%s", define.Version)
|
||||
if c.Flag("os") != nil && c.Flag("os").Changed {
|
||||
if os, err := c.Flags().GetString("os"); err == nil {
|
||||
ctx.OSChoice = os
|
||||
@ -740,7 +740,7 @@ func getDockerAuth(creds string) (*types.DockerAuthConfig, error) {
|
||||
}
|
||||
|
||||
// IDMappingOptions parses the build options related to user namespaces and ID mapping.
|
||||
func IDMappingOptions(c *cobra.Command, isolation buildah.Isolation) (usernsOptions buildah.NamespaceOptions, idmapOptions *buildah.IDMappingOptions, err error) {
|
||||
func IDMappingOptions(c *cobra.Command, isolation define.Isolation) (usernsOptions define.NamespaceOptions, idmapOptions *define.IDMappingOptions, err error) {
|
||||
user := c.Flag("userns-uid-map-user").Value.String()
|
||||
group := c.Flag("userns-gid-map-group").Value.String()
|
||||
// If only the user or group was specified, use the same value for the
|
||||
@ -815,7 +815,7 @@ func IDMappingOptions(c *cobra.Command, isolation buildah.Isolation) (usernsOpti
|
||||
|
||||
// By default, having mappings configured means we use a user
|
||||
// namespace. Otherwise, we don't.
|
||||
usernsOption := buildah.NamespaceOption{
|
||||
usernsOption := define.NamespaceOption{
|
||||
Name: string(specs.UserNamespace),
|
||||
Host: len(uidmap) == 0 && len(gidmap) == 0,
|
||||
}
|
||||
@ -837,11 +837,11 @@ func IDMappingOptions(c *cobra.Command, isolation buildah.Isolation) (usernsOpti
|
||||
usernsOption.Path = how
|
||||
}
|
||||
}
|
||||
usernsOptions = buildah.NamespaceOptions{usernsOption}
|
||||
usernsOptions = define.NamespaceOptions{usernsOption}
|
||||
|
||||
usernetwork := c.Flags().Lookup("network")
|
||||
if usernetwork != nil && !usernetwork.Changed {
|
||||
usernsOptions = append(usernsOptions, buildah.NamespaceOption{
|
||||
usernsOptions = append(usernsOptions, define.NamespaceOption{
|
||||
Name: string(specs.NetworkNamespace),
|
||||
Host: usernsOption.Host,
|
||||
})
|
||||
@ -851,7 +851,7 @@ func IDMappingOptions(c *cobra.Command, isolation buildah.Isolation) (usernsOpti
|
||||
if (len(uidmap) != 0 || len(gidmap) != 0) && usernsOption.Host {
|
||||
return nil, nil, errors.Errorf("can not specify ID mappings while using host's user namespace")
|
||||
}
|
||||
return usernsOptions, &buildah.IDMappingOptions{
|
||||
return usernsOptions, &define.IDMappingOptions{
|
||||
HostUIDMapping: usernsOption.Host,
|
||||
HostGIDMapping: usernsOption.Host,
|
||||
UIDMap: uidmap,
|
||||
@ -886,9 +886,9 @@ func parseIDMap(spec []string) (m [][3]uint32, err error) {
|
||||
}
|
||||
|
||||
// NamespaceOptions parses the build options for all namespaces except for user namespace.
|
||||
func NamespaceOptions(c *cobra.Command) (namespaceOptions buildah.NamespaceOptions, networkPolicy buildah.NetworkConfigurationPolicy, err error) {
|
||||
options := make(buildah.NamespaceOptions, 0, 7)
|
||||
policy := buildah.NetworkDefault
|
||||
func NamespaceOptions(c *cobra.Command) (namespaceOptions define.NamespaceOptions, networkPolicy define.NetworkConfigurationPolicy, err error) {
|
||||
options := make(define.NamespaceOptions, 0, 7)
|
||||
policy := define.NetworkDefault
|
||||
for _, what := range []string{string(specs.IPCNamespace), "network", string(specs.PIDNamespace), string(specs.UTSNamespace)} {
|
||||
if c.Flags().Lookup(what) != nil && c.Flag(what).Changed {
|
||||
how := c.Flag(what).Value.String()
|
||||
@ -899,33 +899,33 @@ func NamespaceOptions(c *cobra.Command) (namespaceOptions buildah.NamespaceOptio
|
||||
switch how {
|
||||
case "", "container", "private":
|
||||
logrus.Debugf("setting %q namespace to %q", what, "")
|
||||
options.AddOrReplace(buildah.NamespaceOption{
|
||||
options.AddOrReplace(define.NamespaceOption{
|
||||
Name: what,
|
||||
})
|
||||
case "host":
|
||||
logrus.Debugf("setting %q namespace to host", what)
|
||||
options.AddOrReplace(buildah.NamespaceOption{
|
||||
options.AddOrReplace(define.NamespaceOption{
|
||||
Name: what,
|
||||
Host: true,
|
||||
})
|
||||
default:
|
||||
if what == string(specs.NetworkNamespace) {
|
||||
if how == "none" {
|
||||
options.AddOrReplace(buildah.NamespaceOption{
|
||||
options.AddOrReplace(define.NamespaceOption{
|
||||
Name: what,
|
||||
})
|
||||
policy = buildah.NetworkDisabled
|
||||
policy = define.NetworkDisabled
|
||||
logrus.Debugf("setting network to disabled")
|
||||
break
|
||||
}
|
||||
}
|
||||
how = strings.TrimPrefix(how, "ns:")
|
||||
if _, err := os.Stat(how); err != nil {
|
||||
return nil, buildah.NetworkDefault, errors.Wrapf(err, "error checking for %s namespace", what)
|
||||
return nil, define.NetworkDefault, errors.Wrapf(err, "error checking for %s namespace", what)
|
||||
}
|
||||
policy = buildah.NetworkEnabled
|
||||
policy = define.NetworkEnabled
|
||||
logrus.Debugf("setting %q namespace to %q", what, how)
|
||||
options.AddOrReplace(buildah.NamespaceOption{
|
||||
options.AddOrReplace(define.NamespaceOption{
|
||||
Name: what,
|
||||
Path: how,
|
||||
})
|
||||
@ -935,36 +935,36 @@ func NamespaceOptions(c *cobra.Command) (namespaceOptions buildah.NamespaceOptio
|
||||
return options, policy, nil
|
||||
}
|
||||
|
||||
func defaultIsolation() (buildah.Isolation, error) {
|
||||
func defaultIsolation() (define.Isolation, error) {
|
||||
isolation, isSet := os.LookupEnv("BUILDAH_ISOLATION")
|
||||
if isSet {
|
||||
switch strings.ToLower(isolation) {
|
||||
case "oci":
|
||||
return buildah.IsolationOCI, nil
|
||||
return define.IsolationOCI, nil
|
||||
case "rootless":
|
||||
return buildah.IsolationOCIRootless, nil
|
||||
return define.IsolationOCIRootless, nil
|
||||
case "chroot":
|
||||
return buildah.IsolationChroot, nil
|
||||
return define.IsolationChroot, nil
|
||||
default:
|
||||
return 0, errors.Errorf("unrecognized $BUILDAH_ISOLATION value %q", isolation)
|
||||
}
|
||||
}
|
||||
if unshare.IsRootless() {
|
||||
return buildah.IsolationOCIRootless, nil
|
||||
return define.IsolationOCIRootless, nil
|
||||
}
|
||||
return buildah.IsolationDefault, nil
|
||||
return define.IsolationDefault, nil
|
||||
}
|
||||
|
||||
// IsolationOption parses the --isolation flag.
|
||||
func IsolationOption(isolation string) (buildah.Isolation, error) {
|
||||
func IsolationOption(isolation string) (define.Isolation, error) {
|
||||
if isolation != "" {
|
||||
switch strings.ToLower(isolation) {
|
||||
case "oci":
|
||||
return buildah.IsolationOCI, nil
|
||||
case "oci", "default":
|
||||
return define.IsolationOCI, nil
|
||||
case "rootless":
|
||||
return buildah.IsolationOCIRootless, nil
|
||||
return define.IsolationOCIRootless, nil
|
||||
case "chroot":
|
||||
return buildah.IsolationChroot, nil
|
||||
return define.IsolationChroot, nil
|
||||
default:
|
||||
return 0, errors.Errorf("unrecognized isolation type %q", isolation)
|
||||
}
|
||||
|
8
vendor/github.com/containers/buildah/pkg/parse/parse_unix.go
generated
vendored
8
vendor/github.com/containers/buildah/pkg/parse/parse_unix.go
generated
vendored
@ -6,14 +6,14 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/containers/buildah/define"
|
||||
"github.com/containers/storage/pkg/unshare"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
"github.com/opencontainers/runc/libcontainer/devices"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func DeviceFromPath(device string) ([]configs.Device, error) {
|
||||
var devs []configs.Device
|
||||
func DeviceFromPath(device string) (define.ContainerDevices, error) {
|
||||
var devs define.ContainerDevices
|
||||
src, dst, permissions, err := Device(device)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -44,7 +44,7 @@ func DeviceFromPath(device string) ([]configs.Device, error) {
|
||||
}
|
||||
for _, d := range srcDevices {
|
||||
d.Path = filepath.Join(dst, filepath.Base(d.Path))
|
||||
d.Permissions = configs.DevicePermissions(permissions)
|
||||
d.Permissions = devices.Permissions(permissions)
|
||||
devs = append(devs, *d)
|
||||
}
|
||||
return devs, nil
|
||||
|
6
vendor/github.com/containers/buildah/pkg/parse/parse_unsupported.go
generated
vendored
6
vendor/github.com/containers/buildah/pkg/parse/parse_unsupported.go
generated
vendored
@ -3,7 +3,7 @@
|
||||
package parse
|
||||
|
||||
import (
|
||||
"github.com/containers/buildah"
|
||||
"github.com/containers/buildah/define"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -11,6 +11,6 @@ func getDefaultProcessLimits() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func DeviceFromPath(device string) (buildah.ContainerDevices, error) {
|
||||
return buildah.ContainerDevices{}, errors.Errorf("devices not supported")
|
||||
func DeviceFromPath(device string) (define.ContainerDevices, error) {
|
||||
return nil, errors.Errorf("devices not supported")
|
||||
}
|
||||
|
Reference in New Issue
Block a user