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:
@@ -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)
|
||||
|
@@ -5,6 +5,7 @@ var typeTemplate = `package client
|
||||
{{- if .schema | hasGet }}
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
{{- end}}
|
||||
|
||||
|
@@ -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":
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user