Skip to main content

FinalizerExt

Trait FinalizerExt 

Source
pub trait FinalizerExt: Resource {
    // Required methods
    fn has_finalizer(&self, name: &str) -> bool;
    fn add_finalizer(&mut self, name: &str) -> bool;
    fn remove_finalizer(&mut self, name: &str) -> bool;
}
Expand description

Extension trait for managing finalizers on any Resource

Kept separate from ResourceExt so that it is only in scope when imported explicitly, and does not collide with downstream extension traits defining the same method names.

These methods only change the object in memory. For reconcilers, prefer kube_runtime::finalizer, which persists the finalizer before any cleanup-relevant work starts (see the module docs).

use k8s_openapi::api::core::v1::Pod;
use kube_core::FinalizerExt;

let mut pod = Pod::default();
assert!(!pod.has_finalizer("my.finalizer"));
assert!(pod.add_finalizer("my.finalizer"));
assert!(pod.has_finalizer("my.finalizer"));
assert!(pod.remove_finalizer("my.finalizer"));

Required Methods§

Source

fn has_finalizer(&self, name: &str) -> bool

Returns whether the given finalizer is present

Source

fn add_finalizer(&mut self, name: &str) -> bool

Adds a finalizer if it is not already present

Returns true if the finalizer was added, false if it was already present.

Source

fn remove_finalizer(&mut self, name: &str) -> bool

Removes a finalizer if present

Returns true if the finalizer was removed, false if it was not present.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§