mirror of
https://github.com/containers/skopeo.git
synced 2025-09-06 09:12:25 +00:00
Bump github.com/containers/common from 0.18.0 to 0.20.2
Bumps [github.com/containers/common](https://github.com/containers/common) from 0.18.0 to 0.20.2. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.18.0...v0.20.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
committed by
Daniel J Walsh
parent
ea10e61f7d
commit
b05933fbc4
68
vendor/github.com/containers/storage/utils.go
generated
vendored
68
vendor/github.com/containers/storage/utils.go
generated
vendored
@@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -233,8 +232,9 @@ func DefaultStoreOptionsAutoDetectUID() (StoreOptions, error) {
|
||||
return DefaultStoreOptions(uid != 0, uid)
|
||||
}
|
||||
|
||||
// DefaultStoreOptions returns the default storage ops for containers
|
||||
func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error) {
|
||||
// defaultStoreOptionsIsolated is an internal implementation detail of DefaultStoreOptions to allow testing.
|
||||
// Everyone but the tests this is intended for should only call DefaultStoreOptions, never this function.
|
||||
func defaultStoreOptionsIsolated(rootless bool, rootlessUID int, storageConf string) (StoreOptions, error) {
|
||||
var (
|
||||
defaultRootlessRunRoot string
|
||||
defaultRootlessGraphRoot string
|
||||
@@ -247,11 +247,6 @@ func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error) {
|
||||
return storageOpts, err
|
||||
}
|
||||
}
|
||||
|
||||
storageConf, err := DefaultConfigFile(rootless && rootlessUID != 0)
|
||||
if err != nil {
|
||||
return storageOpts, err
|
||||
}
|
||||
_, err = os.Stat(storageConf)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return storageOpts, errors.Wrapf(err, "cannot stat %s", storageConf)
|
||||
@@ -262,6 +257,20 @@ func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error) {
|
||||
storageOpts = StoreOptions{}
|
||||
reloadConfigurationFileIfNeeded(storageConf, &storageOpts)
|
||||
}
|
||||
if storageOpts.RunRoot != "" {
|
||||
runRoot, err := expandEnvPath(storageOpts.RunRoot, rootlessUID)
|
||||
if err != nil {
|
||||
return storageOpts, err
|
||||
}
|
||||
storageOpts.RunRoot = runRoot
|
||||
}
|
||||
if storageOpts.GraphRoot != "" {
|
||||
graphRoot, err := expandEnvPath(storageOpts.GraphRoot, rootlessUID)
|
||||
if err != nil {
|
||||
return storageOpts, err
|
||||
}
|
||||
storageOpts.GraphRoot = graphRoot
|
||||
}
|
||||
|
||||
if rootless && rootlessUID != 0 {
|
||||
if err == nil {
|
||||
@@ -270,21 +279,9 @@ func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error) {
|
||||
// directories
|
||||
if storageOpts.RunRoot == "" {
|
||||
storageOpts.RunRoot = defaultRootlessRunRoot
|
||||
} else {
|
||||
rootlessRunRoot, err := expandEnvPath(storageOpts.RunRoot, rootlessUID)
|
||||
if err != nil {
|
||||
return storageOpts, err
|
||||
}
|
||||
storageOpts.RunRoot = rootlessRunRoot
|
||||
}
|
||||
if storageOpts.GraphRoot == "" {
|
||||
storageOpts.GraphRoot = defaultRootlessGraphRoot
|
||||
} else {
|
||||
rootlessGraphRoot, err := expandEnvPath(storageOpts.GraphRoot, rootlessUID)
|
||||
if err != nil {
|
||||
return storageOpts, err
|
||||
}
|
||||
storageOpts.GraphRoot = rootlessGraphRoot
|
||||
}
|
||||
if storageOpts.RootlessStoragePath != "" {
|
||||
rootlessStoragePath, err := expandEnvPath(storageOpts.RootlessStoragePath, rootlessUID)
|
||||
@@ -297,33 +294,22 @@ func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error) {
|
||||
}
|
||||
return storageOpts, nil
|
||||
}
|
||||
func expandEnvPath(path string, rootlessUID int) (string, error) {
|
||||
if err := validEnvPathFormat(path); err != nil {
|
||||
return path, err
|
||||
|
||||
// DefaultStoreOptions returns the default storage ops for containers
|
||||
func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error) {
|
||||
storageConf, err := DefaultConfigFile(rootless && rootlessUID != 0)
|
||||
if err != nil {
|
||||
return defaultStoreOptions, err
|
||||
}
|
||||
return defaultStoreOptionsIsolated(rootless, rootlessUID, storageConf)
|
||||
}
|
||||
|
||||
func expandEnvPath(path string, rootlessUID int) (string, error) {
|
||||
path = strings.Replace(path, "$UID", strconv.Itoa(rootlessUID), -1)
|
||||
path = os.ExpandEnv(path)
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// validEnvPathFormat checks if the environments contained in the path are accepted
|
||||
func validEnvPathFormat(path string) error {
|
||||
if !strings.Contains(path, "$") {
|
||||
return nil
|
||||
}
|
||||
|
||||
splitPaths := strings.SplitAfter(path, "$")
|
||||
validEnv := regexp.MustCompile(`^(HOME|USER|UID)([^a-zA-Z]|$)`).MatchString
|
||||
if len(splitPaths) > 1 {
|
||||
for _, p := range splitPaths[1:] {
|
||||
if !validEnv(p) {
|
||||
return errors.Errorf("Unrecognized environment variable")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateMountOptions(mountOptions []string) error {
|
||||
var Empty struct{}
|
||||
// Add invalid options for ImageMount() here.
|
||||
|
Reference in New Issue
Block a user