Skip to content

Commit

Permalink
✨ Add support for oneOf/anyOf/allOf/not ClusterClass schema constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Sep 26, 2024
1 parent 8c4c67b commit 0947e55
Show file tree
Hide file tree
Showing 9 changed files with 963 additions and 6 deletions.
48 changes: 48 additions & 0 deletions api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,54 @@ type JSONSchemaProps struct {
// It can be used to add additional data for higher level tools.
// +optional
XMetadata *VariableSchemaMetadata `json:"x-metadata,omitempty"`

// x-kubernetes-int-or-string specifies that this value is
// either an integer or a string. If this is true, an empty
// type is allowed and type as child of anyOf is permitted
// if following one of the following patterns:
//
// 1) anyOf:
// - type: integer
// - type: string
// 2) allOf:
// - anyOf:
// - type: integer
// - type: string
// - ... zero or more
// +optional
XIntOrString bool `json:"x-kubernetes-int-or-string,omitempty"`

// AllOf specifies that the variable must validate against all of the subschemas in the array.
// NOTE: This field uses PreserveUnknownFields and Schemaless,
// because recursive validation is not possible.
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
AllOf []JSONSchemaProps `json:"allOf,omitempty"`

// OneOf specifies that the variable must validate against exactly one of the subschemas in the array.
// NOTE: This field uses PreserveUnknownFields and Schemaless,
// because recursive validation is not possible.
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
OneOf []JSONSchemaProps `json:"oneOf,omitempty"`

// AnyOf specifies that the variable must validate against one or more of the subschemas in the array.
// NOTE: This field uses PreserveUnknownFields and Schemaless,
// because recursive validation is not possible.
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
AnyOf []JSONSchemaProps `json:"anyOf,omitempty"`

// Not specifies that the variable must not validate against the subschema.
// NOTE: This field uses PreserveUnknownFields and Schemaless,
// because recursive validation is not possible.
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
Not *JSONSchemaProps `json:"not,omitempty"`
}

// VariableSchemaMetadata is the metadata of a variable or a nested field within a variable.
Expand Down
26 changes: 26 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0947e55

Please sign in to comment.