mirror of
https://github.com/rancher/norman.git
synced 2025-09-16 07:09:44 +00:00
Add hostname tag and fix dnsLabel validation issue
This commit is contained in:
@@ -78,6 +78,8 @@ func getTypeString(nullable bool, typeName string, schema *types.Schema, schemas
|
||||
return "intstr.IntOrString"
|
||||
case "dnsLabel":
|
||||
return "string"
|
||||
case "hostname":
|
||||
return "string"
|
||||
default:
|
||||
if schema != nil && schemas != nil {
|
||||
otherSchema := schemas.Schema(&schema.Version, typeName)
|
||||
|
@@ -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
|
||||
|
@@ -101,6 +101,8 @@ func (s *Schemas) setupFilters(schema *Schema) {
|
||||
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||
case "dnsLabel":
|
||||
fallthrough
|
||||
case "hostname":
|
||||
fallthrough
|
||||
case "string":
|
||||
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||
case "int":
|
||||
|
Reference in New Issue
Block a user