k8s_openapi_ext/ext/
secret_env_source.rs

1use super::*;
2
3/// Builders for `corev1::SecretEnvSource` objects
4pub trait SecretEnvSourceExt: Sized {
5    /// Constructs `corev1::SecretEnvSource` object from secret of this `name`
6    ///
7    fn secret_name(name: impl ToString) -> Self;
8
9    /// Specifies whether the Secret must be defined
10    ///
11    fn optional(self, yes: bool) -> Self;
12
13    /// Marks this `Secret` as required (equivalent to calling .optional(false))
14    ///
15    fn required(self) -> Self {
16        self.optional(false)
17    }
18}
19
20impl SecretEnvSourceExt for corev1::SecretEnvSource {
21    fn secret_name(name: impl ToString) -> Self {
22        let name = name.to_string();
23        Self { name, ..default() }
24    }
25
26    fn optional(self, yes: bool) -> Self {
27        Self {
28            optional: Some(yes),
29            ..self
30        }
31    }
32}