1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
use super::*;
pub trait PodSpecExt {
fn container(container: corev1::Container) -> Self;
fn containers(containers: impl IntoIterator<Item = corev1::Container>) -> Self;
fn service_account_name(self, name: impl ToString) -> Self;
fn image_pull_secret(self, name: impl ToString) -> Self;
fn volumes(self, volumes: impl IntoIterator<Item = corev1::Volume>) -> Self;
}
impl PodSpecExt for corev1::PodSpec {
fn container(container: corev1::Container) -> Self {
let containers = vec![container];
Self {
containers,
// active_deadline_seconds: todo!(),
// affinity: todo!(),
// automount_service_account_token: todo!(),
// dns_config: todo!(),
// dns_policy: todo!(),
// enable_service_links: todo!(),
// ephemeral_containers: todo!(),
// host_aliases: todo!(),
// host_ipc: todo!(),
// host_network: todo!(),
// host_pid: todo!(),
// hostname: todo!(),
// image_pull_secrets: todo!(),
// init_containers: todo!(),
// node_name: todo!(),
// node_selector: todo!(),
// overhead: todo!(),
// preemption_policy: todo!(),
// priority: todo!(),
// priority_class_name: todo!(),
// readiness_gates: todo!(),
// restart_policy: todo!(),
// runtime_class_name: todo!(),
// scheduler_name: todo!(),
// security_context: todo!(),
// service_account: todo!(),
// service_account_name: todo!(),
// set_hostname_as_fqdn: todo!(),
// share_process_namespace: todo!(),
// subdomain: todo!(),
// termination_grace_period_seconds: todo!(),
// tolerations: todo!(),
// topology_spread_constraints: todo!(),
// volumes: todo!(),
..default()
}
}
fn containers(containers: impl IntoIterator<Item = corev1::Container>) -> Self {
let containers = Vec::from_iter(containers);
Self {
containers,
..default()
}
}
fn service_account_name(self, name: impl ToString) -> Self {
let service_account_name = Some(name.to_string());
Self {
service_account_name,
..self
}
}
fn image_pull_secret(self, name: impl ToString) -> Self {
let image_pull_secret_name = Some(name.to_string());
Self {
image_pull_secrets: Some(vec![corev1::LocalObjectReference {
name: image_pull_secret_name,
}]),
..self
}
}
fn volumes(self, volumes: impl IntoIterator<Item = corev1::Volume>) -> Self {
let volumes = Some(volumes.into_iter().collect());
Self { volumes, ..self }
}
}