pub struct Rule {
pub rule: String,
pub message: Option<Message>,
pub field_path: Option<String>,
pub reason: Option<Reason>,
}Expand description
Rule is a CEL validation rule for the CRD field
Fields§
§rule: Stringrule represents the expression which will be evaluated by CEL.
The self variable in the CEL expression is bound to the scoped value.
message: Option<Message>message represents CEL validation message for the provided type If unset, the message is “failed rule: {Rule}”.
field_path: Option<String>fieldPath represents the field path returned when the validation fails. It must be a relative JSON path, scoped to the location of the field in the schema
reason: Option<Reason>reason is a machine-readable value providing more detail about why a field failed the validation.
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn new(rule: impl Into<String>) -> Rule
pub fn new(rule: impl Into<String>) -> Rule
Initialize the rule
use kube_core::Rule;
let r = Rule::new("self == oldSelf");
assert_eq!(r.rule, "self == oldSelf".to_string())Sourcepub fn message(self, message: impl Into<Message>) -> Rule
pub fn message(self, message: impl Into<Message>) -> Rule
Set the rule message.
use kube_core::Rule;
use kube_core::{Rule, Message};
let r = Rule::new("self == oldSelf").message("is immutable");
assert_eq!(r.rule, "self == oldSelf".to_string());
assert_eq!(r.message, Some(Message::Message("is immutable".to_string())));Sourcepub fn reason(self, reason: impl Into<Reason>) -> Rule
pub fn reason(self, reason: impl Into<Reason>) -> Rule
Set the failure reason.
use kube_core::Rule;
use kube_core::{Rule, Reason};
let r = Rule::new("self == oldSelf").reason(Reason::default());
assert_eq!(r.rule, "self == oldSelf".to_string());
assert_eq!(r.reason, Some(Reason::FieldValueInvalid));Sourcepub fn field_path(self, field_path: impl Into<String>) -> Rule
pub fn field_path(self, field_path: impl Into<String>) -> Rule
Set the failure field_path.
use kube_core::Rule;
use kube_core::Rule;
let r = Rule::new("self == oldSelf").field_path("obj.field");
assert_eq!(r.rule, "self == oldSelf".to_string());
assert_eq!(r.field_path, Some("obj.field".to_string()));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rule, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rule, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Rule
impl Serialize for Rule
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnwindSafe for Rule
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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