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"
|
return "intstr.IntOrString"
|
||||||
case "dnsLabel":
|
case "dnsLabel":
|
||||||
return "string"
|
return "string"
|
||||||
|
case "hostname":
|
||||||
|
return "string"
|
||||||
default:
|
default:
|
||||||
if schema != nil && schemas != nil {
|
if schema != nil && schemas != nil {
|
||||||
otherSchema := schemas.Schema(&schema.Version, typeName)
|
otherSchema := schemas.Schema(&schema.Version, typeName)
|
||||||
|
@@ -261,6 +261,18 @@ func (b *Builder) convert(fieldType string, value interface{}, op Operation) (in
|
|||||||
case "string":
|
case "string":
|
||||||
return convert.ToString(value), nil
|
return convert.ToString(value), nil
|
||||||
case "dnsLabel":
|
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)
|
str := convert.ToString(value)
|
||||||
if str == "" {
|
if str == "" {
|
||||||
return "", nil
|
return "", nil
|
||||||
|
@@ -101,6 +101,8 @@ func (s *Schemas) setupFilters(schema *Schema) {
|
|||||||
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
case "dnsLabel":
|
case "dnsLabel":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case "hostname":
|
||||||
|
fallthrough
|
||||||
case "string":
|
case "string":
|
||||||
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
case "int":
|
case "int":
|
||||||
|
Reference in New Issue
Block a user