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 May 16, 2024
1 parent 80dac12 commit 4bfc44e
Show file tree
Hide file tree
Showing 7 changed files with 630 additions and 0 deletions.
36 changes: 36 additions & 0 deletions api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,42 @@ type JSONSchemaProps struct {
// NOTE: Can be set for all types.
// +optional
Default *apiextensionsv1.JSON `json:"default,omitempty"`

// AllOf specifies that the variable must validate against all of the subschemas in the array.
// NOTE: Can only be set if type is object.
// 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: Can only be set if type is object.
// 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: Can only be set if type is object.
// 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: Can only be set if type is object.
// 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"`
}

// ClusterClassPatch defines a patch which is applied to customize the referenced templates.
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.

48 changes: 48 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.

56 changes: 56 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 4bfc44e

Please sign in to comment.