Skip to content

Commit

Permalink
Merge pull request #174 from kmodules/quant
Browse files Browse the repository at this point in the history
Fix OpenAPI type for resource.Quantity fields
  • Loading branch information
k8s-ci-robot committed Mar 25, 2019
2 parents 2c44c73 + 45a8321 commit b8adde9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/internal/codegen/parse/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"}
Expand All @@ -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()
Expand Down

0 comments on commit b8adde9

Please sign in to comment.