mirror of
https://github.com/containers/podman.git
synced 2025-05-22 09:36:57 +08:00
Vendor in containers/(storage,image, common, buildah)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
36
vendor/github.com/containers/common/pkg/parse/parse.go
generated
vendored
36
vendor/github.com/containers/common/pkg/parse/parse.go
generated
vendored
@ -4,12 +4,12 @@ package parse
|
||||
// user input and is shared either amongst container engine subcommands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ValidateVolumeOpts validates a volume's options
|
||||
@ -21,7 +21,7 @@ func ValidateVolumeOpts(options []string) ([]string, error) {
|
||||
if strings.Contains(opt, "upperdir") {
|
||||
foundUpperDir++
|
||||
if foundUpperDir > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 upperdir per overlay", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 upperdir per overlay", strings.Join(options, ", "))
|
||||
}
|
||||
finalOpts = append(finalOpts, opt)
|
||||
continue
|
||||
@ -29,7 +29,7 @@ func ValidateVolumeOpts(options []string) ([]string, error) {
|
||||
if strings.Contains(opt, "workdir") {
|
||||
foundWorkDir++
|
||||
if foundWorkDir > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 workdir per overlay", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 workdir per overlay", strings.Join(options, ", "))
|
||||
}
|
||||
finalOpts = append(finalOpts, opt)
|
||||
continue
|
||||
@ -43,42 +43,42 @@ func ValidateVolumeOpts(options []string) ([]string, error) {
|
||||
case "noexec", "exec":
|
||||
foundExec++
|
||||
if foundExec > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 'noexec' or 'exec' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 'noexec' or 'exec' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "nodev", "dev":
|
||||
foundDev++
|
||||
if foundDev > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 'nodev' or 'dev' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 'nodev' or 'dev' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "nosuid", "suid":
|
||||
foundSuid++
|
||||
if foundSuid > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 'nosuid' or 'suid' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 'nosuid' or 'suid' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "rw", "ro":
|
||||
foundRWRO++
|
||||
if foundRWRO > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 'rw' or 'ro' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 'rw' or 'ro' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "z", "Z", "O":
|
||||
foundLabelChange++
|
||||
if foundLabelChange > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 'z', 'Z', or 'O' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 'z', 'Z', or 'O' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "U":
|
||||
foundChown++
|
||||
if foundChown > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 'U' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 'U' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "private", "rprivate", "shared", "rshared", "slave", "rslave", "unbindable", "runbindable":
|
||||
foundRootPropagation++
|
||||
if foundRootPropagation > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 '[r]shared', '[r]private', '[r]slave' or '[r]unbindable' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 '[r]shared', '[r]private', '[r]slave' or '[r]unbindable' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "bind", "rbind":
|
||||
bindType++
|
||||
if bindType > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 '[r]bind' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 '[r]bind' option", strings.Join(options, ", "))
|
||||
}
|
||||
case "cached", "delegated":
|
||||
// The discarded ops are OS X specific volume options
|
||||
@ -91,10 +91,10 @@ func ValidateVolumeOpts(options []string) ([]string, error) {
|
||||
case "copy", "nocopy":
|
||||
foundCopy++
|
||||
if foundCopy > 1 {
|
||||
return nil, errors.Errorf("invalid options %q, can only specify 1 'copy' or 'nocopy' option", strings.Join(options, ", "))
|
||||
return nil, fmt.Errorf("invalid options %q, can only specify 1 'copy' or 'nocopy' option", strings.Join(options, ", "))
|
||||
}
|
||||
default:
|
||||
return nil, errors.Errorf("invalid option type %q", opt)
|
||||
return nil, fmt.Errorf("invalid option type %q", opt)
|
||||
}
|
||||
finalOpts = append(finalOpts, opt)
|
||||
}
|
||||
@ -113,7 +113,7 @@ func Device(device string) (src, dest, permissions string, err error) {
|
||||
switch len(arr) {
|
||||
case 3:
|
||||
if !isValidDeviceMode(arr[2]) {
|
||||
return "", "", "", errors.Errorf("invalid device mode: %s", arr[2])
|
||||
return "", "", "", fmt.Errorf("invalid device mode: %s", arr[2])
|
||||
}
|
||||
permissions = arr[2]
|
||||
fallthrough
|
||||
@ -122,7 +122,7 @@ func Device(device string) (src, dest, permissions string, err error) {
|
||||
permissions = arr[1]
|
||||
} else {
|
||||
if arr[1] == "" || arr[1][0] != '/' {
|
||||
return "", "", "", errors.Errorf("invalid device mode: %s", arr[1])
|
||||
return "", "", "", fmt.Errorf("invalid device mode: %s", arr[1])
|
||||
}
|
||||
dest = arr[1]
|
||||
}
|
||||
@ -134,7 +134,7 @@ func Device(device string) (src, dest, permissions string, err error) {
|
||||
}
|
||||
fallthrough
|
||||
default:
|
||||
return "", "", "", errors.Errorf("invalid device specification: %s", device)
|
||||
return "", "", "", fmt.Errorf("invalid device specification: %s", device)
|
||||
}
|
||||
|
||||
if dest == "" {
|
||||
@ -184,7 +184,7 @@ func ValidateVolumeCtrDir(ctrDir string) error {
|
||||
return errors.New("container directory cannot be empty")
|
||||
}
|
||||
if !path.IsAbs(ctrDir) {
|
||||
return errors.Errorf("invalid container path %q, must be an absolute path", ctrDir)
|
||||
return fmt.Errorf("invalid container path %q, must be an absolute path", ctrDir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user