summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-04-10 08:07:16 -0700
committerGitHub <noreply@github.com>2019-04-10 08:07:16 -0700
commit1701707dad4e4dba9d4331bd8917be28d138254d (patch)
tree0926c17d1e6ee013af00a153364e2a7941da074d /libpod
parent2f2c7660c3a30d4c28c03eeeba8edc39f7864c7a (diff)
parente2f0a785a4ff03a59b3ca30725ed3ecce1fe4bc5 (diff)
downloadpodman-1701707dad4e4dba9d4331bd8917be28d138254d.tar.gz
podman-1701707dad4e4dba9d4331bd8917be28d138254d.tar.bz2
podman-1701707dad4e4dba9d4331bd8917be28d138254d.zip
Merge pull request #2880 from mheon/update_allowed_regex_error
Update invalid name errors to report the correct regex
Diffstat (limited to 'libpod')
-rw-r--r--libpod/options.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 9326e54e4..8038f1935 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -17,7 +17,8 @@ import (
)
var (
- nameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
+ nameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
+ regexError = errors.Wrapf(ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")
)
// Runtime Creation Options
@@ -593,7 +594,7 @@ func WithName(name string) CtrCreateOption {
// Check the name against a regex
if !nameRegex.MatchString(name) {
- return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+")
+ return regexError
}
ctr.config.Name = name
@@ -1276,7 +1277,7 @@ func WithVolumeName(name string) VolumeCreateOption {
// Check the name against a regex
if !nameRegex.MatchString(name) {
- return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+")
+ return regexError
}
volume.config.Name = name
@@ -1382,7 +1383,7 @@ func WithPodName(name string) PodCreateOption {
// Check the name against a regex
if !nameRegex.MatchString(name) {
- return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+")
+ return regexError
}
pod.config.Name = name