ensure_cluster_finalizer

Function ensure_cluster_finalizer 

Source
pub async fn ensure_cluster_finalizer<T>(
    client: &Client,
    resource: &T,
    finalizer: &str,
) -> Result<()>
where T: Resource<DynamicType = (), Scope = ClusterResourceScope> + ResourceExt + Clone + Debug + Serialize + for<'de> Deserialize<'de>,
Expand description

Add a finalizer to a cluster-scoped resource if not already present.

This function is similar to ensure_finalizer() but works with cluster-scoped resources that don’t have a namespace. It checks if the specified finalizer is present on the resource, and adds it if missing.

§Arguments

  • client - Kubernetes client for accessing the API
  • resource - The cluster-scoped resource to add the finalizer to
  • finalizer - The finalizer string to add

§Returns

Returns Ok(()) if the finalizer was added or already present.

§Errors

Returns an error if the API patch operation fails.

§Example

const FINALIZER: &str = "bind9globalcluster.dns.firestoned.io/finalizer";
ensure_cluster_finalizer(&client, &cluster, FINALIZER).await.unwrap();