From 45a832133205872f81bbe5edf97a630d30adafbc Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Sun, 24 Mar 2019 02:16:06 -0700 Subject: [PATCH] Fix OpenAPI type for resource.Quantity fields Signed-off-by: Tamal Saha --- pkg/internal/codegen/parse/crd.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/internal/codegen/parse/crd.go b/pkg/internal/codegen/parse/crd.go index 98b730bd5..a03f6bb82 100644 --- a/pkg/internal/codegen/parse/crd.go +++ b/pkg/internal/codegen/parse/crd.go @@ -147,6 +147,12 @@ func (b *APIs) getDuration() string { }` } +func (b *APIs) getQuantity() string { + return `v1beta1.JSONSchemaProps{ + Type: "string", +}` +} + func (b *APIs) objSchema() string { return `v1beta1.JSONSchemaProps{ Type: "object", @@ -159,6 +165,7 @@ func (b *APIs) typeToJSONSchemaProps(t *types.Type, found sets.String, comments // Special cases time := types.Name{Name: "Time", Package: "k8s.io/apimachinery/pkg/apis/meta/v1"} duration := types.Name{Name: "Duration", Package: "k8s.io/apimachinery/pkg/apis/meta/v1"} + quantity := types.Name{Name: "Quantity", Package: "k8s.io/apimachinery/pkg/api/resource"} meta := types.Name{Name: "ObjectMeta", Package: "k8s.io/apimachinery/pkg/apis/meta/v1"} unstructured := types.Name{Name: "Unstructured", Package: "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"} rawExtension := types.Name{Name: "RawExtension", Package: "k8s.io/apimachinery/pkg/runtime"} @@ -178,6 +185,9 @@ func (b *APIs) typeToJSONSchemaProps(t *types.Type, found sets.String, comments case duration: specialTypeProps.Type = "string" return specialTypeProps, b.getDuration() + case quantity: + specialTypeProps.Type = "string" + return specialTypeProps, b.getQuantity() case meta, unstructured, rawExtension: specialTypeProps.Type = "object" return specialTypeProps, b.objSchema()