Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateStructural ¶
func ValidateStructural(fldPath *field.Path, s *Structural) field.ErrorList
ValidateStructural checks that s is a structural schema with the invariants:
* structurality: both `ForbiddenGenerics` and `ForbiddenExtensions` only have zero values, with the two exceptions for IntOrString. * RawExtension: for every schema with `x-kubernetes-embedded-resource: true`, `x-kubernetes-preserve-unknown-fields: true` and `type: object` are set * IntOrString: for `x-kubernetes-int-or-string: true` either `type` is empty under `anyOf` and `allOf` or the schema structure is one of these:
- anyOf: - type: integer - type: string
- allOf: - anyOf: - type: integer - type: string - ... zero or more
* every specified field or array in s is also specified outside of value validation. * metadata at the root can only restrict the name and generateName, and not be specified at all in nested contexts. * additionalProperties at the root is not allowed.
Types ¶
type Extensions ¶
type Extensions struct { // x-kubernetes-preserve-unknown-fields stops the API server // decoding step from pruning fields which are not specified // in the validation schema. This affects fields recursively, // but switches back to normal pruning behaviour if nested // properties or additionalProperties are specified in the schema. // False means that the pruning behaviour is inherited from the parent. // False does not mean to activate pruning. XPreserveUnknownFields bool // x-kubernetes-embedded-resource defines that the value is an // embedded Kubernetes runtime.Object, with TypeMeta and // ObjectMeta. The type must be object. It is allowed to further // restrict the embedded object. Both ObjectMeta and TypeMeta // are validated automatically. x-kubernetes-preserve-unknown-fields // must be true. XEmbeddedResource bool // 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 XIntOrString bool // x-kubernetes-list-map-keys annotates lists with the x-kubernetes-list-type `map` by specifying the keys used // as the index of the map. // // This tag MUST only be used on lists that have the "x-kubernetes-list-type" // extension set to "map". Also, the values specified for this attribute must // be a scalar typed field of the child structure (no nesting is supported). XListMapKeys []string // x-kubernetes-list-type annotates a list to further describe its topology. // This extension must only be used on lists and may have 3 possible values: // // 1) `atomic`: the list is treated as a single entity, like a scalar. // Atomic lists will be entirely replaced when updated. This extension // may be used on any type of list (struct, scalar, ...). // 2) `set`: // Sets are lists that must not have multiple items with the same value. Each // value must be a scalar (or another atomic type). // 3) `map`: // These lists are like maps in that their elements have a non-index key // used to identify them. Order is preserved upon merge. The map tag // must only be used on a list with elements of type object. XListType *string // x-kubernetes-map-type annotates an object to further describe its topology. // This extension must only be used when type is object and may have 2 possible values: // // 1) `granular`: // These maps are actual maps (key-value pairs) and each fields are independent // from each other (they can each be manipulated by separate actors). This is // the default behaviour for all maps. // 2) `atomic`: the list is treated as a single entity, like a scalar. // Atomic maps will be entirely replaced when updated. // +optional XMapType *string // x-kubernetes-validations describes a list of validation rules for expression validation. // Use the v1 struct since this gets serialized as an extension. XValidations apiextensionsv1.ValidationRules }
Extensions contains the Kubernetes OpenAPI v3 vendor extensions.
func (*Extensions) DeepCopy ¶
func (in *Extensions) DeepCopy() *Extensions
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extensions.
func (*Extensions) DeepCopyInto ¶
func (in *Extensions) DeepCopyInto(out *Extensions)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Generic ¶
type Generic struct { Description string // type specifies the type of a value. // It can be object, array, number, integer, boolean, string. // It is optional only if x-kubernetes-preserve-unknown-fields // or x-kubernetes-int-or-string is true. Type string Title string Default JSON AdditionalProperties *StructuralOrBool Nullable bool }
Generic contains the generic schema fields not allowed in value validation.
func (*Generic) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Generic.
func (*Generic) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type JSON ¶
type JSON struct {
Object interface{}
}
JSON wraps an arbitrary JSON value to be able to implement deepcopy.
func (JSON) DeepCopyInto ¶
DeepCopyInto creates a deep copy of the wrapped JSON value and stores it in into.
type NestedValueValidation ¶
type NestedValueValidation struct { ValueValidation Items *NestedValueValidation Properties map[string]NestedValueValidation // Anything set in the following will make the scheme // non-structural, with the exception of these two patterns if // x-kubernetes-int-or-string is true: // // 1) anyOf: // - type: integer // - type: string // 2) allOf: // - anyOf: // - type: integer // - type: string // - ... zero or more ForbiddenGenerics Generic ForbiddenExtensions Extensions }
NestedValueValidation contains value validations, items and properties usable when nested under a logical junctor, and catch all structs for generic and vendor extensions schema fields.
func (*NestedValueValidation) DeepCopy ¶
func (in *NestedValueValidation) DeepCopy() *NestedValueValidation
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NestedValueValidation.
func (*NestedValueValidation) DeepCopyInto ¶
func (in *NestedValueValidation) DeepCopyInto(out *NestedValueValidation)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Structural ¶
type Structural struct { Items *Structural Properties map[string]Structural Generic Extensions ValueValidation *ValueValidation }
Structural represents a structural schema.
func NewStructural ¶
func NewStructural(s *apiextensions.JSONSchemaProps) (*Structural, error)
NewStructural converts an OpenAPI v3 schema into a structural schema. A pre-validated JSONSchemaProps will not fail on NewStructural. This means that we require that:
- items is not an array of schemas - the following fields are not set:
- id
- schema
- $ref
- patternProperties
- dependencies
- additionalItems
- definitions.
The follow fields are not preserved: - externalDocs - example.
func (*Structural) DeepCopy ¶
func (in *Structural) DeepCopy() *Structural
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Structural.
func (*Structural) DeepCopyInto ¶
func (in *Structural) DeepCopyInto(out *Structural)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*Structural) StripNullable ¶ added in v0.17.0
func (s *Structural) StripNullable() *Structural
StripNullable returns a copy without nullable.
func (*Structural) StripValueValidations ¶ added in v0.16.4
func (s *Structural) StripValueValidations() *Structural
StripValueValidations returns a copy without value validations.
func (*Structural) ToKubeOpenAPI ¶ added in v0.20.0
func (s *Structural) ToKubeOpenAPI() *spec.Schema
ToKubeOpenAPI converts a structural schema to go-openapi schema. It is faithful and roundtrippable.
func (*Structural) Unfold ¶
func (s *Structural) Unfold() *Structural
Unfold expands vendor extensions of a structural schema. It mutates the receiver.
type StructuralOrBool ¶
type StructuralOrBool struct { Structural *Structural Bool bool }
StructuralOrBool is either a structural schema or a boolean.
func (*StructuralOrBool) DeepCopy ¶
func (in *StructuralOrBool) DeepCopy() *StructuralOrBool
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StructuralOrBool.
func (*StructuralOrBool) DeepCopyInto ¶
func (in *StructuralOrBool) DeepCopyInto(out *StructuralOrBool)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ValueValidation ¶
type ValueValidation struct { Format string Maximum *float64 ExclusiveMaximum bool Minimum *float64 ExclusiveMinimum bool MaxLength *int64 MinLength *int64 Pattern string MaxItems *int64 MinItems *int64 UniqueItems bool MultipleOf *float64 Enum []JSON MaxProperties *int64 MinProperties *int64 Required []string AllOf []NestedValueValidation OneOf []NestedValueValidation AnyOf []NestedValueValidation Not *NestedValueValidation }
ValueValidation contains all schema fields not contributing to the structure of the schema.
func (*ValueValidation) DeepCopy ¶
func (in *ValueValidation) DeepCopy() *ValueValidation
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValueValidation.
func (*ValueValidation) DeepCopyInto ¶
func (in *ValueValidation) DeepCopyInto(out *ValueValidation)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Visitor ¶
type Visitor struct { // Structural is called on each Structural node in the schema, before recursing into // the subtrees. It is allowed to mutate s. Return true if something has been changed. // +optional Structural func(s *Structural) bool // NestedValueValidation is called on each NestedValueValidation node in the schema, // before recursing into subtrees. It is allowed to mutate vv. Return true if something // has been changed. // +optional NestedValueValidation func(vv *NestedValueValidation) bool }
Visitor recursively walks through a structural schema.
func (*Visitor) Visit ¶
func (m *Visitor) Visit(s *Structural)
Visit recursively walks through the structural schema and calls the given callbacks at each node of those types.