ConfigMapSpec

Struct ConfigMapSpec 

Source
pub struct ConfigMapSpec { /* private fields */ }
Expand description

Specification for creating a Kubernetes ConfigMap.

ConfigMaps store configuration data as key-value pairs that can be consumed by pods through environment variables, command-line arguments, or configuration files.

§Examples

use lmrc_kubernetes::ConfigMapSpec;

let configmap = ConfigMapSpec::new("app-config")
    .with_data("database.url", "postgres://localhost:5432/mydb")
    .with_data("log.level", "info")
    .with_label("app", "my-application");

Implementations§

Source§

impl ConfigMapSpec

Source

pub fn new(name: impl Into<String>) -> Self

Creates a new ConfigMapSpec with the given name.

§Arguments
  • name - The name of the ConfigMap
§Examples
use lmrc_kubernetes::ConfigMapSpec;

let configmap = ConfigMapSpec::new("my-config");
Source

pub fn with_data(self, key: impl Into<String>, value: impl Into<String>) -> Self

Adds a text data entry to the ConfigMap.

§Arguments
  • key - The key for the data entry
  • value - The string value
§Examples
use lmrc_kubernetes::ConfigMapSpec;

let configmap = ConfigMapSpec::new("my-config")
    .with_data("app.name", "my-application");
Source

pub fn with_data_map(self, data: HashMap<String, String>) -> Self

Adds multiple text data entries from a HashMap.

§Arguments
  • data - HashMap of key-value pairs
§Examples
use lmrc_kubernetes::ConfigMapSpec;
use std::collections::HashMap;

let mut data = HashMap::new();
data.insert("key1".to_string(), "value1".to_string());
data.insert("key2".to_string(), "value2".to_string());

let configmap = ConfigMapSpec::new("my-config")
    .with_data_map(data);
Source

pub fn with_binary_data(self, key: impl Into<String>, value: Vec<u8>) -> Self

Adds binary data to the ConfigMap.

§Arguments
  • key - The key for the binary data entry
  • value - The binary data as bytes
§Examples
use lmrc_kubernetes::ConfigMapSpec;

let binary_data = vec![0x89, 0x50, 0x4E, 0x47];
let configmap = ConfigMapSpec::new("my-config")
    .with_binary_data("image.png", binary_data);
Source

pub fn with_label( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Adds a label to the ConfigMap.

§Arguments
  • key - The label key
  • value - The label value
§Examples
use lmrc_kubernetes::ConfigMapSpec;

let configmap = ConfigMapSpec::new("my-config")
    .with_label("environment", "production");
Source

pub fn immutable(self, immutable: bool) -> Self

Makes the ConfigMap immutable.

Once a ConfigMap is marked as immutable, its data cannot be changed. This provides protection against accidental updates and improves performance.

§Examples
use lmrc_kubernetes::ConfigMapSpec;

let configmap = ConfigMapSpec::new("my-config")
    .with_data("version", "1.0.0")
    .immutable(true);
Source

pub fn from_file( self, filename: impl Into<String>, content: impl Into<String>, ) -> Self

Loads data from a file content.

§Arguments
  • filename - The key to use (typically the filename)
  • content - The file content
§Examples
use lmrc_kubernetes::ConfigMapSpec;

let config_content = "database:\n  host: localhost\n  port: 5432";
let configmap = ConfigMapSpec::new("my-config")
    .from_file("database.yaml", config_content);
Source

pub fn validate(&self) -> Result<(), String>

Validates the ConfigMap specification.

§Returns

Returns Ok(()) if valid, or an error message if invalid.

§Examples
use lmrc_kubernetes::ConfigMapSpec;

let configmap = ConfigMapSpec::new("my-config")
    .with_data("key", "value");

assert!(configmap.validate().is_ok());
Source

pub fn name(&self) -> &str

Returns the ConfigMap name.

Source

pub fn data(&self) -> &HashMap<String, String>

Returns the data entries.

Source

pub fn binary_data(&self) -> &HashMap<String, Vec<u8>>

Returns the binary data entries.

Source

pub fn labels(&self) -> &HashMap<String, String>

Returns the labels.

Source

pub fn is_immutable(&self) -> bool

Returns whether the ConfigMap is immutable.

Trait Implementations§

Source§

impl Clone for ConfigMapSpec

Source§

fn clone(&self) -> ConfigMapSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConfigMapSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more