pub struct ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations {
pub field_path: Option<String>,
pub message: Option<String>,
pub message_expression: Option<String>,
pub reason: Option<ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidationsReason>,
pub rule: String,
}
Expand description
ValidationRule describes a validation rule written in the CEL expression language.
Fields§
§field_path: Option<String>
fieldPath represents the field path returned when the validation fails.
It must be a relative JSON path (i.e. with array notation) scoped to the location of this x-kubernetes-validations extension in the schema and refer to an existing field.
e.g. when validation checks if a specific attribute foo
under a map testMap
, the fieldPath could be set to .testMap.foo
If the validation checks two lists must have unique attributes, the fieldPath could be set to either of the list: e.g. .testList
It does not support list numeric index.
It supports child operation to refer to an existing field currently. Refer to JSONPath support in Kubernetes for more info.
Numeric index of array is not supported.
For field name which contains special characters, use ['specialName']
to refer the field name.
e.g. for attribute foo.34$
appears in a list testList
, the fieldPath could be set to .testList['foo.34$']
message: Option<String>
message represents the message displayed when validation fails. The message is required if the Rule contains line breaks. The message must not contain line breaks. If unset, the message is “failed rule: {Rule}”. e.g. “must be a URL with the host matching spec.host”
message_expression: Option<String>
messageExpression declares a CEL expression that evaluates to the validation failure message that is returned when this rule fails. Since messageExpression is used as a failure message, it must evaluate to a string. If both message and messageExpression are present on a rule, then messageExpression will be used if validation fails. If messageExpression results in a runtime error, the validation failure message is produced as if the messageExpression field were unset. If messageExpression evaluates to an empty string, a string with only spaces, or a string that contains line breaks, then the validation failure message will also be produced as if the messageExpression field were unset. messageExpression has access to all the same variables as the rule; the only difference is the return type. Example: “x must be less than max (”+string(self.max)+“)”
reason: Option<ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidationsReason>
reason provides a machine-readable validation failure reason that is returned to the caller when a request fails this validation rule. The currently supported reasons are: “FieldValueInvalid”, “FieldValueForbidden”, “FieldValueRequired”, “FieldValueDuplicate”. If not set, default to use “FieldValueInvalid”. All future added reasons must be accepted by clients when reading this value and unknown reasons should be treated as FieldValueInvalid.
rule: String
rule represents the expression which will be evaluated by CEL.
ref: https://github.com/google/cel-spec
The Rule is scoped to the location of the x-kubernetes-validations extension in the schema.
The self
variable in the CEL expression is bound to the scoped value.
If the Rule is scoped to an object with properties, the accessible properties of the object are field selectable
via self.field
and field presence can be checked via has(self.field)
.
If the Rule is scoped to an object with additionalProperties (i.e. a map) the value of the map
are accessible via self[mapKey]
, map containment can be checked via mapKey in self
and all entries of the map
are accessible via CEL macros and functions such as self.all(...)
.
If the Rule is scoped to an array, the elements of the array are accessible via self[i]
and also by macros and
functions.
If the Rule is scoped to a scalar, self
is bound to the scalar value.
Examples:
- Rule scoped to a map of objects: {“rule”: “self.components[‘Widget’].priority < 10”}
- Rule scoped to a list of integers: {“rule”: “self.values.all(value, value >= 0 && value < 100)”}
- Rule scoped to a string value: {“rule”: “self.startsWith(‘kube’)”}
Unknown data preserved in custom resources via x-kubernetes-preserve-unknown-fields is not accessible in CEL expressions. This includes:
- Unknown field values that are preserved by object schemas with x-kubernetes-preserve-unknown-fields.
- Object properties where the property schema is of an “unknown type”. An “unknown type” is recursively defined as:
- A schema with no type and x-kubernetes-preserve-unknown-fields set to true
- An array where the items schema is of an “unknown type”
- An object where the additionalProperties schema is of an “unknown type”
Only property names of the form [a-zA-Z_.-/][a-zA-Z0-9_.-/]*
are accessible.
Accessible property names are escaped according to the following rules when accessed in the expression:
- ‘__’ escapes to ‘underscores’
- ‘.’ escapes to ‘dot’
- ‘-’ escapes to ‘dash’
- ‘/’ escapes to ‘slash’
- Property names that exactly match a CEL RESERVED keyword escape to ‘{keyword}’. The keywords are:
“true”, “false”, “null”, “in”, “as”, “break”, “const”, “continue”, “else”, “for”, “function”, “if”,
“import”, “let”, “loop”, “package”, “namespace”, “return”.
Examples:
- Rule accessing a property named “namespace”: {“rule”: “self.namespace > 0”}
- Rule accessing a property named “x-prop”: {“rule”: “self.x__dash__prop > 0”}
- Rule accessing a property named “redact__d”: {“rule”: “self.redact__underscores__d > 0”}
If rule
makes use of the oldSelf
variable it is implicitly a
transition rule
.
By default, the oldSelf
variable is the same type as self
.
Transition rules by default are applied only on UPDATE requests and are skipped if an old value could not be found.
Trait Implementations§
Source§impl Clone for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl Clone for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Source§fn clone(
&self,
) -> ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
fn clone( &self, ) -> ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Default for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl Default for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Source§fn default() -> ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
fn default() -> ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Source§impl<'de> Deserialize<'de> for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl<'de> Deserialize<'de> for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl JsonSchema for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl PartialEq for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl PartialEq for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Source§fn eq(
&self,
other: &ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations,
) -> bool
fn eq( &self, other: &ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations, ) -> bool
self
and other
values to be equal, and is used by ==
.impl StructuralPartialEq for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Auto Trait Implementations§
impl Freeze for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl RefUnwindSafe for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl Send for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl Sync for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl Unpin for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
impl UnwindSafe for ClusterClassVariablesSchemaOpenApiv3SchemaXKubernetesValidations
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more