Skip to content
Open
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 @@ -42,6 +42,14 @@ var TopologyMarkers = []*definitionWithHelp{
WithHelp(StructType("").Help()),
must(markers.MakeDefinition("structType", markers.DescribesType, StructType(""))).
WithHelp(StructType("").Help()),
must(markers.MakeDefinition("k8s:listType", markers.DescribesField, ListType(""))).
WithHelp(ListType("").Help()),
must(markers.MakeDefinition("k8s:listType", markers.DescribesType, ListType(""))).
WithHelp(ListType("").Help()),
must(markers.MakeDefinition("k8s:listMapKey", markers.DescribesField, ListMapKey(""))).
WithHelp(ListMapKey("").Help()),
must(markers.MakeDefinition("k8s:listMapKey", markers.DescribesType, ListMapKey(""))).
WithHelp(ListMapKey("").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 @@ -204,9 +204,25 @@ type CronJobSpec struct {
// +listMapKey=secondary
AssociativeList []AssociativeType `json:"associativeList"`

// This tests that associative lists work using the +k8s:listType alias.
// +k8s:listType=map
// +k8s:listMapKey=name
K8sAssociativeList []AssociativeType `json:"k8sAssociativeList"`

// This tests that +k8s:listType=set works.
// +k8s:listType=set
K8sSetList []string `json:"k8sSetList,omitempty"`

// This tests that +k8s:listType=atomic works.
// +k8s:listType=atomic
K8sAtomicList []string `json:"k8sAtomicList,omitempty"`

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

// This tests that associative lists work via a nested type using the +k8s:listType alias.
K8sNestedAssociativeList K8sNestedAssociativeList `json:"k8sNestedAssociativeList"`

// A map that allows different actors to manage different fields
// +mapType=granular
MapOfInfo map[string][]byte `json:"mapOfInfo"`
Expand Down Expand Up @@ -541,6 +557,11 @@ type AssociativeType struct {
// +listMapKey=secondary
type NestedAssociativeList []AssociativeType

// +k8s:listType=map
// +k8s:listMapKey=name
// +k8s:listMapKey=secondary
type K8sNestedAssociativeList []AssociativeType

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

Expand Down
55 changes: 55 additions & 0 deletions pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9340,6 +9340,59 @@ spec:
- bar
- foo
type: object
k8sAssociativeList:
description: This tests that associative lists work using the +k8s:listType
alias.
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
x-kubernetes-list-type: map
k8sAtomicList:
description: This tests that +k8s:listType=atomic works.
items:
type: string
type: array
x-kubernetes-list-type: atomic
k8sNestedAssociativeList:
description: This tests that associative lists work via a nested type
using the +k8s:listType alias.
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
k8sSetList:
description: This tests that +k8s:listType=set works.
items:
type: string
type: array
x-kubernetes-list-type: set
kubernetesDefaultedEmptyMap:
additionalProperties:
type: string
Expand Down Expand Up @@ -9727,6 +9780,8 @@ spec:
- int32WithValidations
- intWithValidations
- jobTemplate
- k8sAssociativeList
- k8sNestedAssociativeList
- kubernetesDefaultedEmptyMap
- kubernetesDefaultedEmptyObject
- kubernetesDefaultedEmptySlice
Expand Down