use super::*;
pub trait ConfigMapExt: ResourceBuilder {
fn new(name: impl ToString) -> Self;
fn immutable(self, yes: bool) -> Self;
fn binary_data(self, data: impl IntoIterator<Item = (impl ToString, ByteString)>) -> Self;
fn data(self, data: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self;
fn data_mut(&mut self) -> &mut BTreeMap<String, String>;
fn binary_data_mut(&mut self) -> &mut BTreeMap<String, ByteString>;
}
impl ConfigMapExt for corev1::ConfigMap {
fn new(name: impl ToString) -> Self {
let metadata = metadata(name);
Self {
metadata,
..default()
}
}
fn immutable(self, yes: bool) -> Self {
let immutable = Some(yes);
Self { immutable, ..self }
}
fn binary_data(self, data: impl IntoIterator<Item = (impl ToString, ByteString)>) -> Self {
let data = data
.into_iter()
.map(|(key, value)| (key.to_string(), value))
.collect();
Self {
binary_data: Some(data),
..self
}
}
fn data(self, data: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self {
let data = data
.into_iter()
.map(|(key, value)| (key.to_string(), value.to_string()))
.collect();
Self {
data: Some(data),
..self
}
}
fn data_mut(&mut self) -> &mut BTreeMap<String, String> {
self.data.get_or_insert_with(default)
}
fn binary_data_mut(&mut self) -> &mut BTreeMap<String, ByteString> {
self.binary_data.get_or_insert_with(default)
}
}