mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
Merge pull request #2880 from mheon/update_allowed_regex_error
Update invalid name errors to report the correct regex
This commit is contained in:
@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
var (
|
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
|
// Runtime Creation Options
|
||||||
@ -593,7 +594,7 @@ func WithName(name string) CtrCreateOption {
|
|||||||
|
|
||||||
// Check the name against a regex
|
// Check the name against a regex
|
||||||
if !nameRegex.MatchString(name) {
|
if !nameRegex.MatchString(name) {
|
||||||
return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+")
|
return regexError
|
||||||
}
|
}
|
||||||
|
|
||||||
ctr.config.Name = name
|
ctr.config.Name = name
|
||||||
@ -1276,7 +1277,7 @@ func WithVolumeName(name string) VolumeCreateOption {
|
|||||||
|
|
||||||
// Check the name against a regex
|
// Check the name against a regex
|
||||||
if !nameRegex.MatchString(name) {
|
if !nameRegex.MatchString(name) {
|
||||||
return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+")
|
return regexError
|
||||||
}
|
}
|
||||||
volume.config.Name = name
|
volume.config.Name = name
|
||||||
|
|
||||||
@ -1382,7 +1383,7 @@ func WithPodName(name string) PodCreateOption {
|
|||||||
|
|
||||||
// Check the name against a regex
|
// Check the name against a regex
|
||||||
if !nameRegex.MatchString(name) {
|
if !nameRegex.MatchString(name) {
|
||||||
return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+")
|
return regexError
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.config.Name = name
|
pod.config.Name = name
|
||||||
|
Reference in New Issue
Block a user