1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-04 16:50:41 +00:00

Add intOrString and dnsLabel types

This commit is contained in:
Darren Shepherd
2017-12-29 15:06:36 -07:00
parent 6c007d23ef
commit 162f6088af
4 changed files with 14 additions and 1 deletions

View File

@@ -74,6 +74,10 @@ func getTypeString(nullable bool, typeName string, schema *types.Schema, schemas
return "string"
case "enum":
return "string"
case "intOrString":
return "intstr.IntOrString"
case "dnsLabel":
return "string"
default:
if schema != nil && schemas != nil {
otherSchema := schemas.Schema(&schema.Version, typeName)

View File

@@ -5,6 +5,7 @@ var typeTemplate = `package client
{{- if .schema | hasGet }}
import (
"github.com/rancher/norman/types"
"k8s.io/apimachinery/pkg/util/intstr"
)
{{- end}}

View File

@@ -239,6 +239,14 @@ func (b *Builder) convert(fieldType string, value interface{}, op Operation) (in
return convert.ToString(value), nil
case "string":
return convert.ToString(value), nil
case "dnsLabel":
return convert.ToString(value), nil
case "intOrString":
num, err := convert.ToNumber(value)
if err == nil {
return num, nil
}
return convert.ToString(value), nil
case "base64":
return convert.ToString(value), nil
case "reference":

View File

@@ -423,7 +423,7 @@ func (s *Schemas) determineSchemaType(version *APIVersion, t reflect.Type) (stri
return "date", nil
}
if t.Name() == "IntOrString" {
return "string", nil
return "intOrString", nil
}
if t.Name() == "Quantity" {
return "string", nil