k8s_openapi_ext/ext/
service_account.rs1use super::*;
2
3pub trait ServiceAccountExt: super::ResourceBuilder {
4 fn new(name: impl ToString) -> Self;
5
6 fn automount_service_account_token(self, yes: bool) -> Self;
7
8 fn image_pull_secret(self, secret: impl ToString) -> Self;
9
10 fn image_pull_secrets(self, secrets: impl IntoIterator<Item = impl ToString>) -> Self;
11}
12
13impl ServiceAccountExt for corev1::ServiceAccount {
14 fn new(name: impl ToString) -> Self {
15 let metadata = metadata(name);
16 Self {
17 metadata,
18 ..default()
22 }
23 }
24
25 fn automount_service_account_token(self, yes: bool) -> Self {
26 let automount_service_account_token = Some(yes);
27 Self {
28 automount_service_account_token,
29 ..self
30 }
31 }
32
33 fn image_pull_secret(self, name: impl ToString) -> Self {
34 let secret = corev1::LocalObjectReference::new(name);
35 let image_pull_secrets = Some(vec![secret]);
36 Self {
37 image_pull_secrets,
38 ..self
39 }
40 }
41
42 fn image_pull_secrets(self, secrets: impl IntoIterator<Item = impl ToString>) -> Self {
43 let secrets = secrets
44 .into_iter()
45 .map(corev1::LocalObjectReference::new)
46 .collect();
47 let image_pull_secrets = Some(secrets);
48 Self {
49 image_pull_secrets,
50 ..self
51 }
52 }
53}