pub struct RenderedResourceCoords {
pub api_version: String,
pub kind: String,
pub name: String,
pub namespace: Option<String>,
}Expand description
Identifying coordinates of a rendered K8s resource — the
(apiVersion, kind, metadata.name, metadata.namespace) 4-tuple
every consumer that walks a rendered serde_json::Value resource
unwraps by hand pre-lift.
The three K8s API-path segments (apiVersion, kind,
metadata.name) are REQUIRED — a rendered resource missing any
of them cannot be applied via kube-rs’s dynamic API surface, so
the extraction fails fast at the boundary rather than as a
downstream Api::patch panic. metadata.namespace is
intentionally kept as Option<String> because different consumers
resolve the fallback differently: apply_owned uses the
caller-supplied namespace: &str argument (the reconciler already
resolved the target namespace upstream), while flux_ref_from_json
records the K8s canonical "default" fallback into the persisted
FluxResourceRef.namespace slot. The peer method
Self::namespace_or_default applies the K8s canonical fallback
(Process::DEFAULT_NAMESPACE = "default") for consumers wanting
the same shape [FluxResourceRef.namespace] carries.
Pre-lift the 3+1 slot extraction was hand-authored at TWO sites
past the ★★ PRIME-DIRECTIVE ≥ 2 duplication threshold across
tatara-reconciler:
tatara-reconciler::phase_machine::flux_ref_from_json— the post-SSAFluxResourceRefbuilder that persists intoProcessStatus.flux_resources; namespace half fallback- defaulted to"default".tatara-reconciler::ssapply::apply_owned— the SSA entry point that extracts (apiVersion, kind, name) for thekube::Api::patchcall; namespace half discarded (thenamespace: &strargument comes from the caller upstream).
Both callsites restated the same three
.get(K).and_then(|v| v.as_str()).ok_or_else(|| anyhow!(...))? .to_string() incantations with subtly different error wording
("resource missing X" vs "rendered resource missing X"); post-
lift both route through this ONE substrate owner with the
canonical "rendered resource missing X" wording. A future
addition (case-fold on the group, a rename of the namespace
fallback, a stricter kind gate, a Unicode-safe collation step,
support for metadata.generateName as a name fallback) lands at
the primitive’s body on the substrate, not at 2 independent
hand-writes across 2 reconciler files.
Namespace fallback const is shared with
Process::DEFAULT_NAMESPACE — a rename of the K8s canonical
default namespace lands at that ONE workspace-wide const, not at
per-primitive local literals that would drift silently.
Fields§
§api_version: StringapiVersion — the group+version pair kube-rs uses to resolve
the ApiResource for the SSA call.
kind: Stringkind — the resource kind (Kustomization, HelmRelease, …).
name: Stringmetadata.name — the API-path leaf segment.
namespace: Option<String>metadata.namespace — raw from the resource, None when the
slot is absent (a cluster-scoped resource, or a namespaced
resource whose namespace was left for the API server to
substitute). Consumers apply their own fallback:
Self::namespace_or_default applies the K8s canonical
"default" (matching what [FluxResourceRef.namespace]
records); other consumers substitute a caller-supplied string
(see tatara-reconciler::ssapply::apply_owned).
Implementations§
Source§impl RenderedResourceCoords
impl RenderedResourceCoords
Sourcepub fn from_json(res: &Value) -> Result<Self>
pub fn from_json(res: &Value) -> Result<Self>
Extract the 4-tuple from a rendered K8s resource JSON Value.
Fails with a canonical "rendered resource missing X" message
when any of the three required slots (apiVersion, kind,
metadata.name) is absent or non-string; metadata.namespace
is optional and captured as None when absent.
The error wording is pinned by
[tests::rendered_resource_coords_error_wording_is_canonical]
so a regression that reshaped the message surfaces at the test
surface rather than as silent drift between the two pre-lift
call sites (which used subtly different wording — "resource missing X" in apply_owned vs "rendered resource missing X" in flux_ref_from_json).
Sourcepub fn namespace_or_default(&self) -> &str
pub fn namespace_or_default(&self) -> &str
metadata.namespace slice with the K8s canonical "default"
fallback applied — matching what Process::DEFAULT_NAMESPACE
spells for the Process-borne coordinate primitive family
and what [FluxResourceRef.namespace] records into
ProcessStatus.flux_resources.
Trait Implementations§
Source§impl Clone for RenderedResourceCoords
impl Clone for RenderedResourceCoords
Source§fn clone(&self) -> RenderedResourceCoords
fn clone(&self) -> RenderedResourceCoords
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RenderedResourceCoords
impl Debug for RenderedResourceCoords
impl Eq for RenderedResourceCoords
Source§impl PartialEq for RenderedResourceCoords
impl PartialEq for RenderedResourceCoords
impl StructuralPartialEq for RenderedResourceCoords
Auto Trait Implementations§
impl Freeze for RenderedResourceCoords
impl RefUnwindSafe for RenderedResourceCoords
impl Send for RenderedResourceCoords
impl Sync for RenderedResourceCoords
impl Unpin for RenderedResourceCoords
impl UnsafeUnpin for RenderedResourceCoords
impl UnwindSafe for RenderedResourceCoords
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> 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 moreimpl<T> OptionalSend for T
impl<T> OptionalSync for T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);