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
impl ConfigMapSpec
Sourcepub fn with_data_map(self, data: HashMap<String, String>) -> Self
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);Sourcepub fn with_binary_data(self, key: impl Into<String>, value: Vec<u8>) -> Self
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 entryvalue- 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);Sourcepub fn immutable(self, immutable: bool) -> Self
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);Sourcepub fn from_file(
self,
filename: impl Into<String>,
content: impl Into<String>,
) -> Self
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);Sourcepub fn is_immutable(&self) -> bool
pub fn is_immutable(&self) -> bool
Returns whether the ConfigMap is immutable.
Trait Implementations§
Source§impl Clone for ConfigMapSpec
impl Clone for ConfigMapSpec
Source§fn clone(&self) -> ConfigMapSpec
fn clone(&self) -> ConfigMapSpec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConfigMapSpec
impl RefUnwindSafe for ConfigMapSpec
impl Send for ConfigMapSpec
impl Sync for ConfigMapSpec
impl Unpin for ConfigMapSpec
impl UnwindSafe for ConfigMapSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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