Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/crd/markers/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ import (
var TopologyMarkers = []*definitionWithHelp{
must(markers.MakeDefinition("listMapKey", markers.DescribesField, ListMapKey(""))).
WithHelp(ListMapKey("").Help()),
must(markers.MakeDefinition("listMapKey", markers.DescribesType, ListMapKey(""))).
WithHelp(ListMapKey("").Help()),
must(markers.MakeDefinition("listType", markers.DescribesField, ListType(""))).
WithHelp(ListType("").Help()),
must(markers.MakeDefinition("listType", markers.DescribesType, ListType(""))).
WithHelp(ListType("").Help()),
must(markers.MakeDefinition("mapType", markers.DescribesField, MapType(""))).
WithHelp(MapType("").Help()),
must(markers.MakeDefinition("mapType", markers.DescribesType, MapType(""))).
WithHelp(MapType("").Help()),
must(markers.MakeDefinition("structType", markers.DescribesField, StructType(""))).
WithHelp(StructType("").Help()),
must(markers.MakeDefinition("structType", markers.DescribesType, StructType(""))).
WithHelp(StructType("").Help()),
}

func init() {
Expand Down
21 changes: 21 additions & 0 deletions pkg/crd/testdata/cronjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,24 @@ type CronJobSpec struct {
// +listMapKey=secondary
AssociativeList []AssociativeType `json:"associativeList"`

// This tests that associative lists work via a nested type.
NestedAssociativeList NestedAssociativeList `json:"nestedassociativeList"`

// A map that allows different actors to manage different fields
// +mapType=granular
MapOfInfo map[string][]byte `json:"mapOfInfo"`

// A map that allows different actors to manage different fields via a nested type.
NestedMapOfInfo NestedMapOfInfo `json:"nestedMapOfInfo"`

// A struct that can only be entirely replaced
// +structType=atomic
StructWithSeveralFields NestedObject `json:"structWithSeveralFields"`

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

// This tests that type references are properly flattened
// +kubebuilder:validation:optional
JustNestedObject *JustNestedObject `json:"justNestedObject,omitempty"`
Expand Down Expand Up @@ -267,6 +277,9 @@ type NestedObject struct {
Bar bool `json:"bar"`
}

// +structType=atomic
type NestedStructWithSeveralFields NestedObject

type JustNestedObject NestedObject

// +kubebuilder:validation:MinProperties=1
Expand Down Expand Up @@ -303,6 +316,14 @@ type AssociativeType struct {
Foo string `json:"foo"`
}

// +listType=map
// +listMapKey=name
// +listMapKey=secondary
type NestedAssociativeList []AssociativeType

// +mapType=granular
type NestedMapOfInfo map[string][]byte

// +kubebuilder:validation:MinLength=4
// This tests that markers that are allowed on both fields and types are applied to types
type LongerString string
Expand Down
46 changes: 46 additions & 0 deletions pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7260,6 +7260,14 @@ spec:
type: object
description: Checks that maps containing types that contain maps work
type: object
nestedMapOfInfo:
additionalProperties:
format: byte
type: string
description: A map that allows different actors to manage different
fields via a nested type.
type: object
x-kubernetes-map-type: granular
nestedNestedMap:
additionalProperties:
additionalProperties:
Expand All @@ -7269,6 +7277,41 @@ spec:
type: object
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:
bar:
type: boolean
foo:
type: string
required:
- bar
- foo
type: object
nestedassociativeList:
description: This tests that associative lists work via a nested type.
items:
properties:
foo:
type: string
name:
type: string
secondary:
type: integer
required:
- foo
- name
- secondary
type: object
type: array
x-kubernetes-list-map-keys:
- name
- secondary
x-kubernetes-list-type: map
noReallySuspend:
description: This flag is like suspend, but for when you really mean
it. It helps test the +kubebuilder:validation:Type marker.
Expand Down Expand Up @@ -7380,6 +7423,9 @@ spec:
- intWithValidations
- jobTemplate
- mapOfInfo
- nestedMapOfInfo
- nestedStructWithSeveralFields
- nestedassociativeList
- patternObject
- schedule
- structWithSeveralFields
Expand Down