Skip to content

Commit

Permalink
Merge pull request #246 from kragniz/crd-schema-primitive-types
Browse files Browse the repository at this point in the history
Generate correct CRD primitive types
  • Loading branch information
Phillip Wittrock authored Jun 1, 2018
2 parents 1ebf7d3 + ba90a3f commit 800df6f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/internal/codegen/parse/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ func (b *APIs) parsePrimitiveValidation(t *types.Type, found sets.String, commen
if err := primitiveTemplate.Execute(buff, primitiveTemplateArgs{props, n, f, s}); err != nil {
log.Fatalf("%v", err)
}
props.Type = n
props.Format = f
return props, buff.String()
}

Expand Down
1 change: 1 addition & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ function test_crd_validation {
// +kubebuilder:validation:Maximum=100\
// +kubebuilder:validation:ExclusiveMinimum=true\
Power float32 \`json:"power"\`\
Bricks int32 \`json:"bricks"\`\
// +kubebuilder:validation:MaxLength=15\
// +kubebuilder:validation:MinLength=1\
Name string \`json:"name"\`\
Expand Down
11 changes: 8 additions & 3 deletions test/data/resource/expected/crd-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ spec:
- Wolf
- Dragon
type: string
bricks:
format: int32
type: integer
comment:
format: byte
type: string
Expand All @@ -44,16 +47,18 @@ spec:
type: string
power:
exclusiveMinimum: true
format: float
maximum: 100
type: float32
type: number
rank:
enum:
- 1
- 2
- 3
type: int
format: int64
type: integer
winner:
type: bool
type: boolean
type: object
status:
type: object
Expand Down
3 changes: 2 additions & 1 deletion test/projects/memcached-api-server/test/hack/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ spec:
spec:
properties:
size:
format: int32
maximum: 100
minimum: 5
type: int32
type: integer
type: object
status:
properties:
Expand Down

0 comments on commit 800df6f

Please sign in to comment.