Skip to content

Commit

Permalink
Fix crd flattening for XMapType to not duplicate entries
Browse files Browse the repository at this point in the history
Bug was introduced in #693.
  • Loading branch information
chrischdi committed Jun 29, 2022
1 parent c8fc4d4 commit f50232a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/crd/flatten.go
Expand Up @@ -143,6 +143,8 @@ func flattenAllOfInto(dst *apiext.JSONSchemaProps, src apiext.JSONSchemaProps, e
dstProps.Schema = &apiext.JSONSchemaProps{}
}
flattenAllOfInto(dstProps.Schema, *srcProps.Schema, errRec)
case "XMapType":
dstField.Set(srcField)
// NB(directxman12): no need to explicitly handle nullable -- false is considered to be the zero value
// TODO(directxman12): src isn't necessarily the field value -- it's just the most recent allOf entry
default:
Expand Down
4 changes: 1 addition & 3 deletions pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml
Expand Up @@ -7277,9 +7277,6 @@ spec:
description: Checks that multiply-nested maps work
type: object
nestedStructWithSeveralFields:
allOf:
- x-kubernetes-map-type: atomic
- x-kubernetes-map-type: atomic
description: A struct that can only be entirely replaced via a nested
type.
properties:
Expand All @@ -7291,6 +7288,7 @@ spec:
- bar
- foo
type: object
x-kubernetes-map-type: atomic
nestedassociativeList:
description: This tests that associative lists work via a nested type.
items:
Expand Down

0 comments on commit f50232a

Please sign in to comment.