Skip to main content

ObjectMetaTemplateExt

Trait ObjectMetaTemplateExt 

Source
pub trait ObjectMetaTemplateExt<K>
where Self: KubeOperations<Self, K> + ResourceExt + Clone + 'static, <Self as Lookup>::DynamicType: Eq + Hash + Clone, K: Resource<Scope = NamespaceResourceScope> + Default + Clone + Debug + Serialize + for<'de> Deserialize<'de>, <K as Resource>::DynamicType: Default,
{ const OPERATOR_NAME: &'static str; // Required methods fn managed_object_name(&self) -> String; fn metadata_template(&self) -> Option<&MetadataTemplate>; // Provided methods fn template_operator_name() -> String { ... } fn needs_meta_template_apply( &self, live: &PartialObjectMeta<K>, ) -> Option<FilteredMetadata> { ... } async fn apply_meta_template( &self, client: Client, metrics: &ControllerMetrics, filtered: FilteredMetadata, ) -> Result<K> { ... } }
Expand description

Implemented by operator resources that manage a child Kubernetes object whose metadata (labels and annotations) can be customized via a MetadataTemplate.

Generic over K so the same mechanism can serve any resource type that has ObjectMeta (Secret, ConfigMap, …). The default implementations of [needs_meta_template_apply] and [apply_meta_template] cover the common SSA cleanup/apply flow; implementors only need to supply the three required methods.

Required Associated Constants§

Source

const OPERATOR_NAME: &'static str

The SSA field-manager name used for the main operator apply.

Required Methods§

Source

fn managed_object_name(&self) -> String

Name of the managed child object.

Source

fn metadata_template(&self) -> Option<&MetadataTemplate>

Template supplying extra labels/annotations, if configured.

Provided Methods§

Source

fn template_operator_name() -> String

Name of the SSA field manager used for template-owned metadata fields.

Source

fn needs_meta_template_apply( &self, live: &PartialObjectMeta<K>, ) -> Option<FilteredMetadata>

Checks whether the live object’s metadata matches the desired template state and, if not, returns the pre-filtered FilteredMetadata ready to pass to [apply_meta_template].

Reads the managed-fields list for both the main operator and the template manager, covering all three out-of-sync cases:

  • A desired key is missing or has the wrong value.
  • The desired template is empty but the template manager still owns fields (template removed).
  • The desired template shrank and the template manager owns stale keys.
Source

async fn apply_meta_template( &self, client: Client, metrics: &ControllerMetrics, filtered: FilteredMetadata, ) -> Result<K>

Applies filtered to the managed child object using the template SSA field manager.

Passing an empty FilteredMetadata (no labels, no annotations) causes SSA to release any previously template-owned keys. Obtain filtered from [needs_meta_template_apply]. Callers are responsible for surfacing any discarded keys (see FilteredMetadata::has_discards).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§