Skip to content

Commit

Permalink
✨ testdata/cronjob_types.go: add NestedStructWithSeveralFieldsDoubleM…
Browse files Browse the repository at this point in the history
…arked (#704)

* testdata/cronjob_types.go: drop field annotation of NestedStructWithSeveralFields

The type `NestedStructWithSeveralFields` is already annotated.
Annotating the field of the same name is not necessary, might confuse
user looking at this example and potentially cover up future regressions
(the field annotation might cover up the type annotation not having the
wanted effect).

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>

* testdata/cronjob_types.go: add NestedStructWithSeveralFieldsDoubleMarked

This adds a field to the cronjob test data, that ensures that fields
which are marked twice (once through a type marker, one through a field
marker) still generate the correct yaml structure.

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>

---------

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
  • Loading branch information
jan--f committed Apr 22, 2023
1 parent f0ba62a commit 9b9ec3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/crd/testdata/cronjob_types.go
Expand Up @@ -165,9 +165,13 @@ type CronJobSpec struct {
StructWithSeveralFields NestedObject `json:"structWithSeveralFields"`

// A struct that can only be entirely replaced via a nested type.
// +structType=atomic
NestedStructWithSeveralFields NestedStructWithSeveralFields `json:"nestedStructWithSeveralFields"`

// A struct that can only be entirely replaced via a nested type and
// field markers.
// +structType=atomic
NestedStructWithSeveralFieldsDoubleMarked NestedStructWithSeveralFields `json:"nestedStructWithSeveralFieldsDoubleMarked"`

// This tests that type references are properly flattened
// +kubebuilder:validation:optional
JustNestedObject *JustNestedObject `json:"justNestedObject,omitempty"`
Expand Down
14 changes: 14 additions & 0 deletions pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml
Expand Up @@ -7301,6 +7301,19 @@ spec:
- foo
type: object
x-kubernetes-map-type: atomic
nestedStructWithSeveralFieldsDoubleMarked:
description: A struct that can only be entirely replaced via a nested
type and field markers.
properties:
bar:
type: boolean
foo:
type: string
required:
- bar
- foo
type: object
x-kubernetes-map-type: atomic
nestedassociativeList:
description: This tests that associative lists work via a nested type.
items:
Expand Down Expand Up @@ -7434,6 +7447,7 @@ spec:
- mapOfInfo
- nestedMapOfInfo
- nestedStructWithSeveralFields
- nestedStructWithSeveralFieldsDoubleMarked
- nestedassociativeList
- patternObject
- schedule
Expand Down

0 comments on commit 9b9ec3b

Please sign in to comment.