Skip to content

Commit b8adde9

Browse files
authored
Merge pull request #174 from kmodules/quant
Fix OpenAPI type for resource.Quantity fields
2 parents 2c44c73 + 45a8321 commit b8adde9

File tree

1 file changed

+10
-0
lines changed
  • pkg/internal/codegen/parse

1 file changed

+10
-0
lines changed

pkg/internal/codegen/parse/crd.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ func (b *APIs) getDuration() string {
147147
}`
148148
}
149149

150+
func (b *APIs) getQuantity() string {
151+
return `v1beta1.JSONSchemaProps{
152+
Type: "string",
153+
}`
154+
}
155+
150156
func (b *APIs) objSchema() string {
151157
return `v1beta1.JSONSchemaProps{
152158
Type: "object",
@@ -159,6 +165,7 @@ func (b *APIs) typeToJSONSchemaProps(t *types.Type, found sets.String, comments
159165
// Special cases
160166
time := types.Name{Name: "Time", Package: "k8s.io/apimachinery/pkg/apis/meta/v1"}
161167
duration := types.Name{Name: "Duration", Package: "k8s.io/apimachinery/pkg/apis/meta/v1"}
168+
quantity := types.Name{Name: "Quantity", Package: "k8s.io/apimachinery/pkg/api/resource"}
162169
meta := types.Name{Name: "ObjectMeta", Package: "k8s.io/apimachinery/pkg/apis/meta/v1"}
163170
unstructured := types.Name{Name: "Unstructured", Package: "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"}
164171
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
178185
case duration:
179186
specialTypeProps.Type = "string"
180187
return specialTypeProps, b.getDuration()
188+
case quantity:
189+
specialTypeProps.Type = "string"
190+
return specialTypeProps, b.getQuantity()
181191
case meta, unstructured, rawExtension:
182192
specialTypeProps.Type = "object"
183193
return specialTypeProps, b.objSchema()

0 commit comments

Comments
 (0)