pub struct DiffEngine;Expand description
Diff engine for comparing Kubernetes resources
Implementations§
Source§impl DiffEngine
impl DiffEngine
Sourcepub fn normalize(resource: &mut Value)
pub fn normalize(resource: &mut Value)
Normalize a resource for comparison by removing auto-generated fields
This removes fields that Kubernetes generates automatically and should not be considered when comparing desired vs live state:
- metadata.resourceVersion
- metadata.uid
- metadata.generation
- metadata.creationTimestamp
- metadata.managedFields
- metadata.selfLink
- status (entire section)
Sourcepub fn to_comparable_yaml(resource: &Value) -> Result<String>
pub fn to_comparable_yaml(resource: &Value) -> Result<String>
Convert a resource to normalized YAML string for comparison
This normalizes the resource and converts it to YAML with consistent formatting for reliable comparison.
Sourcepub fn diff_yaml(desired: &Value, live: &Value) -> Result<String>
pub fn diff_yaml(desired: &Value, live: &Value) -> Result<String>
Compare two resources and return a unified diff (kubectl-style)
This generates a unified diff similar to kubectl diff by:
- Normalizing both resources
- Converting to YAML
- Running a line-by-line unified diff algorithm
Returns empty string if resources are equivalent.
Sourcepub fn are_equivalent(desired: &Value, live: &Value) -> Result<bool>
pub fn are_equivalent(desired: &Value, live: &Value) -> Result<bool>
Check if two resources are equivalent after normalization
This is a simple equality check after normalization. Use this for determining if resources differ, then use diff_yaml() to show what changed.
Sourcepub async fn normalize_with_server(
resource: &Value,
client: Option<&dyn KubeClient>,
) -> Result<Value>
pub async fn normalize_with_server( resource: &Value, client: Option<&dyn KubeClient>, ) -> Result<Value>
Normalize a resource with optional server-side normalization
If a client is provided, sends the resource to the server with dry-run to apply server-side defaults. Otherwise, just clones the resource. In both cases, applies client-side normalization to remove metadata fields.
Sourcepub async fn diff_yaml_with_server(
desired: &Value,
live: &Value,
client: &dyn KubeClient,
) -> Result<String>
pub async fn diff_yaml_with_server( desired: &Value, live: &Value, client: &dyn KubeClient, ) -> Result<String>
Generate a diff with server-side normalization
Uses server-side apply dry-run to normalize the desired resource, then compares against the live resource (which already has server defaults).
Sourcepub async fn are_equivalent_with_server(
desired: &Value,
live: &Value,
client: &dyn KubeClient,
) -> Result<bool>
pub async fn are_equivalent_with_server( desired: &Value, live: &Value, client: &dyn KubeClient, ) -> Result<bool>
Check if two resources are equivalent with server-side normalization
Uses server-side apply dry-run to normalize the desired resource, then compares against the live resource.
Auto Trait Implementations§
impl Freeze for DiffEngine
impl RefUnwindSafe for DiffEngine
impl Send for DiffEngine
impl Sync for DiffEngine
impl Unpin for DiffEngine
impl UnsafeUnpin for DiffEngine
impl UnwindSafe for DiffEngine
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> 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