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 APIresource- The cluster-scoped resource to add the finalizer tofinalizer- 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();