Skip to main content

Guard

Enum Guard 

Source
pub enum Guard {
Show 22 variants Truthy { path: String, }, Not { path: String, }, Eq { path: String, value: GuardValue, }, NotEq { path: String, value: GuardValue, }, Absent { path: String, }, MatchesPattern { path: String, pattern: String, templated: bool, }, RangeKeyPrefix { path: String, prefix: String, }, RangeKeyEquals { path: String, key: String, }, RangeKeyMatches { path: String, pattern: String, }, Or { paths: Vec<String>, }, AnyOf { alternatives: Vec<Vec<Guard>>, }, Range { path: String, }, With { path: String, }, Default { path: String, }, TypeIs { path: String, schema_type: String, }, NotTypeIs { path: String, schema_type: String, }, IntGt { path: String, bound: i64, }, IntLt { path: String, bound: i64, }, AtMostOneMember { path: String, }, MinMembers { path: String, bound: i64, }, HasKey { path: String, key: String, }, ContainsEquals { path: String, value: GuardValue, },
}
Expand description

A guard condition from an if, with, or range block.

Variants§

§

Truthy

Simple truthy check: if .Values.X

Fields

§path: String

Values path tested for truthiness.

§

Not

Negated truthy check: if not .Values.X

Fields

§path: String

Values path tested for falsiness.

§

Eq

Equality check: if eq .Values.X "value" / if eq .Values.X false.

Fields

§path: String

Values path compared with the literal.

§value: GuardValue

Literal required at the path.

§

NotEq

Inequality check: if ne .Values.X "value" / if ne .Values.X false.

Fields

§path: String

Values path compared with the literal.

§value: GuardValue

Literal excluded at the path.

§

Absent

Path absence check, used for structural rules where missing values are semantically distinct from false values.

Fields

§path: String

Values path whose absence selects the branch.

§

MatchesPattern

The path’s string value matches a literal regular expression: if regexMatch "…" .Values.X. regexMatch type-asserts a string subject, so the guard holding implies string-ness as well. When templated is set the subject reached the match through tpl, so the pattern constrains the rendered OUTPUT: a raw value carrying a template action is admitted regardless (its render may match).

Fields

§path: String

Values path subjected to the pattern test.

§pattern: String

Literal regular expression required by the branch.

§templated: bool

Whether matching occurs after rendering the value through tpl.

§

RangeKeyPrefix

A destructured range key starts with a literal prefix. The path names the ranged collection; the predicate applies to its matching entries, not to the collection value itself.

Fields

§path: String

Values path of the ranged collection.

§prefix: String

Literal prefix required of the current key.

§

RangeKeyEquals

A destructured range key equals a literal (if eq $key "name"). The path names the ranged collection; the predicate selects exactly the entry with that key. Document-level lowering may only use the POSITIVE form (the key exists in the collection); the negation runs for every OTHER member and has no key-presence encoding.

Fields

§path: String

Values path of the ranged collection.

§key: String

Literal key selected by the branch.

§

RangeKeyMatches

A destructured range key matches a literal regular expression (if regexMatch "[A-Z]" $name). The path names the ranged collection; the predicate applies per key, so lowering targets the collection’s key domain (traefik’s uppercase ingressRoute gate).

Fields

§path: String

Values path of the ranged collection.

§pattern: String

Regular expression required of the current key.

§

Or

Disjunction: if or .Values.A .Values.B

Fields

§paths: Vec<String>

Values paths whose truthiness forms the disjunction.

§

AnyOf

Disjunction whose arms may each contain a conjunction of typed guards.

This preserves structural forms such as or (and .Values.A .Values.B) (eq .Values.mode "prod") without degrading them into truthiness checks for every mentioned path.

Fields

§alternatives: Vec<Vec<Guard>>

Guard conjunctions that form the disjunction’s alternatives.

§

Range

Body of range .Values.X / range .foo block. The referenced path is being iterated as a collection, not interpreted as a boolean-valued scalar. This should not contribute a boolean type hint downstream.

Fields

§path: String

Values path used as the range source.

§

With

Body of with .Values.X block. This distinguishes header binding from if-style truthy checks. The bound path is null-tolerant by construction because with nil skips the body.

Fields

§path: String

Values path selected as the branch context.

§

Default

Rendered via a default ... <path> fallback, either in prefix form (default "x" .Values.X) or pipeline form (.Values.X | default "x").

This is stronger than a plain truthy guard: the template explicitly substitutes a fallback when the path is empty/nil, so null is an accepted chart input for that render site even when values.yaml ships a non-null default.

Fields

§path: String

Values path protected by a fallback.

§

TypeIs

A typeIs "<json type>" <path> check in template logic.

This is not a truthiness guard. It is a structural type declaration: helpers such as Bitnami’s common.tplvalues.render explicitly branch on typeIs "string" .value, so callers may supply that values path as a string even when another branch renders it as a YAML object fragment.

Fields

§path: String

Values path subjected to the type test.

§schema_type: String

JSON Schema type name selected by the branch.

§

NotTypeIs

The complement of Guard::TypeIs: the else arm of a type dispatch (if typeIs "string" x … else …).

Rows need this as a first-class variant because dropping the complement collapses a type-switch partition: member reads and structural placements under the else would otherwise apply to EVERY type of the dispatched path.

Fields

§path: String

Values path subjected to the type test.

§schema_type: String

JSON Schema type name excluded by the branch.

§

IntGt

The path’s RAW value is a JSON integer strictly greater than bound.

This deliberately claims less than the Sprig coercion it stands in for: gt (int64 .Values.x) N also holds for numeric strings and true, so this guard is a SOUND SUBSET usable only where firing less often is safe (a fail-arm condition), never as an exact branch condition whose negation must also hold.

Fields

§path: String

Values path subjected to the integer comparison.

§bound: i64

Exclusive lower bound.

§

IntLt

The path’s RAW value is a JSON integer strictly less than bound.

The mirror of Guard::IntGt, with the same sound-subset contract: lt (int .Values.x) N also holds for coercible non-integers, so this guard may only strengthen positive-polarity consumers.

Fields

§path: String

Values path subjected to the integer comparison.

§bound: i64

Exclusive upper bound.

§

AtMostOneMember

The collection at path has at most one entry.

A sound SUBSET stand-in for loop-carried conditions that provably hold on a range’s FIRST iteration (an empty-initialized dedup accumulator cannot shadow anything yet): with at most one member, every iteration is the first. Like Guard::IntGt, it may only strengthen positive-polarity consumers.

Fields

§path: String

Values path expected to hold the bounded collection.

§

MinMembers

The value at path is a mapping with at least bound members — the exact meaning of gt (keys X | len) N (keys aborts on non-maps, so the render reaches the body only for maps).

Fields

§path: String

Values path expected to hold the mapping.

§bound: i64

Inclusive minimum number of mapping members.

§

HasKey

The mapping at path contains key as a literal member — Sprig hasKey/dig observability, where a present nil member IS present (cilium’s removed-option guards abort on the truthy "<nil>" rendering of an explicit null). Contrast Guard::Absent, which counts explicit null as absent for the nil-safe selector lanes.

Fields

§path: String

Values path expected to hold a mapping.

§key: String

Literal mapping key whose presence selects the branch.

§

ContainsEquals

SOME item of the list at path deep-equals the scalar literal — Sprig has LITERAL .Values.list, the dual of the literal-list membership (has .Values.x (list …)). has returns false on a nil haystack and aborts rendering on non-lists, so the guard holds exactly for arrays carrying the literal (oauth2-proxy gates its secret keys on has "cookie-secret" .Values.config.requiredSecretKeys).

Fields

§path: String

Values path expected to hold a list.

§value: GuardValue

Literal that at least one list item must equal.

Implementations§

Source§

impl Guard

Source

pub fn value_paths(&self) -> Vec<&str>

Return all .Values.* paths referenced by this guard.

Source

pub fn map_value_paths<F>(self, map: &mut F) -> Self
where F: FnMut(&str) -> String,

Rewrite value paths carried by this guard.

Trait Implementations§

Source§

impl Clone for Guard

Source§

fn clone(&self) -> Guard

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Guard

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Guard

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Guard

Source§

impl From<Guard> for Predicate

Source§

fn from(guard: Guard) -> Self

Converts to this type from the input type.
Source§

impl Hash for Guard

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Guard

Source§

fn cmp(&self, other: &Guard) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Guard

Source§

fn eq(&self, other: &Guard) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Guard

Source§

fn partial_cmp(&self, other: &Guard) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Guard

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Guard

Auto Trait Implementations§

§

impl Freeze for Guard

§

impl RefUnwindSafe for Guard

§

impl Send for Guard

§

impl Sync for Guard

§

impl Unpin for Guard

§

impl UnsafeUnpin for Guard

§

impl UnwindSafe for Guard

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.