mirror of
https://github.com/rancher/norman.git
synced 2025-09-18 08:14:56 +00:00
Add hostname tag and fix dnsLabel validation issue
This commit is contained in:
@@ -261,6 +261,18 @@ func (b *Builder) convert(fieldType string, value interface{}, op Operation) (in
|
||||
case "string":
|
||||
return convert.ToString(value), nil
|
||||
case "dnsLabel":
|
||||
str := convert.ToString(value)
|
||||
if str == "" {
|
||||
return "", nil
|
||||
}
|
||||
if op == Create || op == Update {
|
||||
if errs := validation.IsDNS1123Label(str); len(errs) != 0 {
|
||||
return value, httperror.NewAPIError(httperror.InvalidFormat, fmt.Sprintf("invalid value %s: %s", value,
|
||||
strings.Join(errs, ",")))
|
||||
}
|
||||
}
|
||||
return str, nil
|
||||
case "hostname":
|
||||
str := convert.ToString(value)
|
||||
if str == "" {
|
||||
return "", nil
|
||||
|
Reference in New Issue
Block a user