From 9b9ec3b599abb9e8ab179aa94c97cc760d218010 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Sat, 22 Apr 2023 17:03:12 +0200 Subject: [PATCH] :sparkles: testdata/cronjob_types.go: add NestedStructWithSeveralFieldsDoubleMarked (#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 * 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 --------- Signed-off-by: Jan Fajerski --- pkg/crd/testdata/cronjob_types.go | 6 +++++- .../testdata/testdata.kubebuilder.io_cronjobs.yaml | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/crd/testdata/cronjob_types.go b/pkg/crd/testdata/cronjob_types.go index 3b9a9ef76..85d07bf4f 100644 --- a/pkg/crd/testdata/cronjob_types.go +++ b/pkg/crd/testdata/cronjob_types.go @@ -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"` diff --git a/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml b/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml index ce3163cba..bdd7f2307 100644 --- a/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml +++ b/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml @@ -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: @@ -7434,6 +7447,7 @@ spec: - mapOfInfo - nestedMapOfInfo - nestedStructWithSeveralFields + - nestedStructWithSeveralFieldsDoubleMarked - nestedassociativeList - patternObject - schedule