get_last_transition_time

Function get_last_transition_time 

Source
pub fn get_last_transition_time(
    existing_conditions: &[Condition],
    condition_type: &str,
) -> String
Expand description

Get the last transition time from an existing condition, or current time if none exists.

When updating a condition, we want to preserve the lastTransitionTime if the condition status hasn’t actually changed. This function retrieves the existing timestamp if available, or returns the current time for new conditions.

This is useful for preserving transition times when only the message changes but the overall status remains the same.

§Arguments

  • existing_conditions - The existing conditions from the resource’s status
  • condition_type - The type of condition to look for

§Returns

The existing lastTransitionTime if found, otherwise the current time as RFC3339.

§Example

let existing_conditions = vec![]; // From resource status
let time = get_last_transition_time(&existing_conditions, "Ready");