k8s_openapi/v1_35/api/core/v1/
windows_security_context_options.rs

1// Generated from definition io.k8s.api.core.v1.WindowsSecurityContextOptions
2
3/// WindowsSecurityContextOptions contain Windows-specific options and credentials.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct WindowsSecurityContextOptions {
6    /// GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field.
7    pub gmsa_credential_spec: Option<std::string::String>,
8
9    /// GMSACredentialSpecName is the name of the GMSA credential spec to use.
10    pub gmsa_credential_spec_name: Option<std::string::String>,
11
12    /// HostProcess determines if a container should be run as a 'Host Process' container. All of a Pod's containers must have the same effective HostProcess value (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). In addition, if HostProcess is true then HostNetwork must also be set to true.
13    pub host_process: Option<bool>,
14
15    /// The UserName in Windows to run the entrypoint of the container process. Defaults to the user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.
16    pub run_as_user_name: Option<std::string::String>,
17}
18
19impl crate::DeepMerge for WindowsSecurityContextOptions {
20    fn merge_from(&mut self, other: Self) {
21        crate::DeepMerge::merge_from(&mut self.gmsa_credential_spec, other.gmsa_credential_spec);
22        crate::DeepMerge::merge_from(&mut self.gmsa_credential_spec_name, other.gmsa_credential_spec_name);
23        crate::DeepMerge::merge_from(&mut self.host_process, other.host_process);
24        crate::DeepMerge::merge_from(&mut self.run_as_user_name, other.run_as_user_name);
25    }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for WindowsSecurityContextOptions {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30        #[allow(non_camel_case_types)]
31        enum Field {
32            Key_gmsa_credential_spec,
33            Key_gmsa_credential_spec_name,
34            Key_host_process,
35            Key_run_as_user_name,
36            Other,
37        }
38
39        impl<'de> crate::serde::Deserialize<'de> for Field {
40            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41                struct Visitor;
42
43                impl crate::serde::de::Visitor<'_> for Visitor {
44                    type Value = Field;
45
46                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47                        f.write_str("field identifier")
48                    }
49
50                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51                        Ok(match v {
52                            "gmsaCredentialSpec" => Field::Key_gmsa_credential_spec,
53                            "gmsaCredentialSpecName" => Field::Key_gmsa_credential_spec_name,
54                            "hostProcess" => Field::Key_host_process,
55                            "runAsUserName" => Field::Key_run_as_user_name,
56                            _ => Field::Other,
57                        })
58                    }
59                }
60
61                deserializer.deserialize_identifier(Visitor)
62            }
63        }
64
65        struct Visitor;
66
67        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68            type Value = WindowsSecurityContextOptions;
69
70            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71                f.write_str("WindowsSecurityContextOptions")
72            }
73
74            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75                let mut value_gmsa_credential_spec: Option<std::string::String> = None;
76                let mut value_gmsa_credential_spec_name: Option<std::string::String> = None;
77                let mut value_host_process: Option<bool> = None;
78                let mut value_run_as_user_name: Option<std::string::String> = None;
79
80                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81                    match key {
82                        Field::Key_gmsa_credential_spec => value_gmsa_credential_spec = crate::serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_gmsa_credential_spec_name => value_gmsa_credential_spec_name = crate::serde::de::MapAccess::next_value(&mut map)?,
84                        Field::Key_host_process => value_host_process = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_run_as_user_name => value_run_as_user_name = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
87                    }
88                }
89
90                Ok(WindowsSecurityContextOptions {
91                    gmsa_credential_spec: value_gmsa_credential_spec,
92                    gmsa_credential_spec_name: value_gmsa_credential_spec_name,
93                    host_process: value_host_process,
94                    run_as_user_name: value_run_as_user_name,
95                })
96            }
97        }
98
99        deserializer.deserialize_struct(
100            "WindowsSecurityContextOptions",
101            &[
102                "gmsaCredentialSpec",
103                "gmsaCredentialSpecName",
104                "hostProcess",
105                "runAsUserName",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for WindowsSecurityContextOptions {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "WindowsSecurityContextOptions",
116            self.gmsa_credential_spec.as_ref().map_or(0, |_| 1) +
117            self.gmsa_credential_spec_name.as_ref().map_or(0, |_| 1) +
118            self.host_process.as_ref().map_or(0, |_| 1) +
119            self.run_as_user_name.as_ref().map_or(0, |_| 1),
120        )?;
121        if let Some(value) = &self.gmsa_credential_spec {
122            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gmsaCredentialSpec", value)?;
123        }
124        if let Some(value) = &self.gmsa_credential_spec_name {
125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gmsaCredentialSpecName", value)?;
126        }
127        if let Some(value) = &self.host_process {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostProcess", value)?;
129        }
130        if let Some(value) = &self.run_as_user_name {
131            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "runAsUserName", value)?;
132        }
133        crate::serde::ser::SerializeStruct::end(state)
134    }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for WindowsSecurityContextOptions {
139    fn schema_name() -> std::borrow::Cow<'static, str> {
140        "io.k8s.api.core.v1.WindowsSecurityContextOptions".into()
141    }
142
143    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
144        crate::schemars::json_schema!({
145            "description": "WindowsSecurityContextOptions contain Windows-specific options and credentials.",
146            "type": "object",
147            "properties": {
148                "gmsaCredentialSpec": {
149                    "description": "GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field.",
150                    "type": "string",
151                },
152                "gmsaCredentialSpecName": {
153                    "description": "GMSACredentialSpecName is the name of the GMSA credential spec to use.",
154                    "type": "string",
155                },
156                "hostProcess": {
157                    "description": "HostProcess determines if a container should be run as a 'Host Process' container. All of a Pod's containers must have the same effective HostProcess value (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). In addition, if HostProcess is true then HostNetwork must also be set to true.",
158                    "type": "boolean",
159                },
160                "runAsUserName": {
161                    "description": "The UserName in Windows to run the entrypoint of the container process. Defaults to the user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.",
162                    "type": "string",
163                },
164            },
165        })
166    }
167}