Skip to content

Commit 800df6f

Browse files
author
Phillip Wittrock
authored
Merge pull request #246 from kragniz/crd-schema-primitive-types
Generate correct CRD primitive types
2 parents 1ebf7d3 + ba90a3f commit 800df6f

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

cmd/internal/codegen/parse/crd.go

+2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ func (b *APIs) parsePrimitiveValidation(t *types.Type, found sets.String, commen
224224
if err := primitiveTemplate.Execute(buff, primitiveTemplateArgs{props, n, f, s}); err != nil {
225225
log.Fatalf("%v", err)
226226
}
227+
props.Type = n
228+
props.Format = f
227229
return props, buff.String()
228230
}
229231

test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ function test_crd_validation {
518518
// +kubebuilder:validation:Maximum=100\
519519
// +kubebuilder:validation:ExclusiveMinimum=true\
520520
Power float32 \`json:"power"\`\
521+
Bricks int32 \`json:"bricks"\`\
521522
// +kubebuilder:validation:MaxLength=15\
522523
// +kubebuilder:validation:MinLength=1\
523524
Name string \`json:"name"\`\

test/data/resource/expected/crd-expected.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ spec:
2929
- Wolf
3030
- Dragon
3131
type: string
32+
bricks:
33+
format: int32
34+
type: integer
3235
comment:
3336
format: byte
3437
type: string
@@ -44,16 +47,18 @@ spec:
4447
type: string
4548
power:
4649
exclusiveMinimum: true
50+
format: float
4751
maximum: 100
48-
type: float32
52+
type: number
4953
rank:
5054
enum:
5155
- 1
5256
- 2
5357
- 3
54-
type: int
58+
format: int64
59+
type: integer
5560
winner:
56-
type: bool
61+
type: boolean
5762
type: object
5863
status:
5964
type: object

test/projects/memcached-api-server/test/hack/install.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ spec:
2424
spec:
2525
properties:
2626
size:
27+
format: int32
2728
maximum: 100
2829
minimum: 5
29-
type: int32
30+
type: integer
3031
type: object
3132
status:
3233
properties:

0 commit comments

Comments
 (0)