diff --git a/generator/generator.go b/generator/generator.go index c4ae7259..5d340a85 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -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) diff --git a/parse/builder/builder.go b/parse/builder/builder.go index e5dd16b9..f3a6d343 100644 --- a/parse/builder/builder.go +++ b/parse/builder/builder.go @@ -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 diff --git a/types/reflection.go b/types/reflection.go index 0f021abc..cf70770e 100644 --- a/types/reflection.go +++ b/types/reflection.go @@ -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":