k8s_openapi_ext/ext/
security_context.rs1use super::*;
2
3pub trait SecurityContextExt {
4 fn new() -> Self;
5
6 fn allow_privilege_escalation(self, yes: bool) -> Self;
7 fn read_only_root_filesystem(self, yes: bool) -> Self;
8 fn run_as_group(self, group: i64) -> Self;
9 fn run_as_non_root(self, yes: bool) -> Self;
10 fn run_as_user(self, user: i64) -> Self;
11 fn privileged(self, yes: bool) -> Self;
12}
13
14impl SecurityContextExt for corev1::SecurityContext {
15 fn new() -> Self {
16 Self {
17 ..default()
30 }
31 }
32
33 fn allow_privilege_escalation(self, yes: bool) -> Self {
34 Self {
35 allow_privilege_escalation: Some(yes),
36 ..self
37 }
38 }
39
40 fn read_only_root_filesystem(self, yes: bool) -> Self {
41 Self {
42 read_only_root_filesystem: Some(yes),
43 ..self
44 }
45 }
46
47 fn run_as_group(self, group: i64) -> Self {
48 Self {
49 run_as_group: Some(group),
50 ..self
51 }
52 }
53
54 fn run_as_non_root(self, yes: bool) -> Self {
55 Self {
56 run_as_non_root: Some(yes),
57 ..self
58 }
59 }
60
61 fn run_as_user(self, user: i64) -> Self {
62 Self {
63 run_as_user: Some(user),
64 ..self
65 }
66 }
67
68 fn privileged(self, privileged: bool) -> Self {
69 Self {
70 privileged: Some(privileged),
71 ..self
72 }
73 }
74}