@@ -189,92 +189,116 @@ impl PodSecurityContextBuilder {
189189 }
190190
191191 pub fn se_linux_level ( & mut self , level : & str ) -> & mut Self {
192- self . pod_security_context . se_linux_options =
193- Some ( self . pod_security_context . se_linux_options . clone ( ) . map_or (
194- SELinuxOptions {
195- level : Some ( level. to_string ( ) ) ,
196- ..SELinuxOptions :: default ( )
197- } ,
198- |o| SELinuxOptions {
199- level : Some ( level. to_string ( ) ) ,
200- ..o
201- } ,
202- ) ) ;
192+ self . pod_security_context . se_linux_options = Some (
193+ self . pod_security_context
194+ . se_linux_options
195+ . clone ( )
196+ . map_or_else (
197+ || SELinuxOptions {
198+ level : Some ( level. to_string ( ) ) ,
199+ ..SELinuxOptions :: default ( )
200+ } ,
201+ |o| SELinuxOptions {
202+ level : Some ( level. to_string ( ) ) ,
203+ ..o
204+ } ,
205+ ) ,
206+ ) ;
203207 self
204208 }
205209
206210 pub fn se_linux_role ( & mut self , role : & str ) -> & mut Self {
207- self . pod_security_context . se_linux_options =
208- Some ( self . pod_security_context . se_linux_options . clone ( ) . map_or (
209- SELinuxOptions {
210- role : Some ( role. to_string ( ) ) ,
211- ..SELinuxOptions :: default ( )
212- } ,
213- |o| SELinuxOptions {
214- role : Some ( role. to_string ( ) ) ,
215- ..o
216- } ,
217- ) ) ;
211+ self . pod_security_context . se_linux_options = Some (
212+ self . pod_security_context
213+ . se_linux_options
214+ . clone ( )
215+ . map_or_else (
216+ || SELinuxOptions {
217+ role : Some ( role. to_string ( ) ) ,
218+ ..SELinuxOptions :: default ( )
219+ } ,
220+ |o| SELinuxOptions {
221+ role : Some ( role. to_string ( ) ) ,
222+ ..o
223+ } ,
224+ ) ,
225+ ) ;
218226 self
219227 }
220228
221229 pub fn se_linux_type ( & mut self , type_ : & str ) -> & mut Self {
222- self . pod_security_context . se_linux_options =
223- Some ( self . pod_security_context . se_linux_options . clone ( ) . map_or (
224- SELinuxOptions {
225- type_ : Some ( type_. to_string ( ) ) ,
226- ..SELinuxOptions :: default ( )
227- } ,
228- |o| SELinuxOptions {
229- type_ : Some ( type_. to_string ( ) ) ,
230- ..o
231- } ,
232- ) ) ;
230+ self . pod_security_context . se_linux_options = Some (
231+ self . pod_security_context
232+ . se_linux_options
233+ . clone ( )
234+ . map_or_else (
235+ || SELinuxOptions {
236+ type_ : Some ( type_. to_string ( ) ) ,
237+ ..SELinuxOptions :: default ( )
238+ } ,
239+ |o| SELinuxOptions {
240+ type_ : Some ( type_. to_string ( ) ) ,
241+ ..o
242+ } ,
243+ ) ,
244+ ) ;
233245 self
234246 }
235247
236248 pub fn se_linux_user ( & mut self , user : & str ) -> & mut Self {
237- self . pod_security_context . se_linux_options =
238- Some ( self . pod_security_context . se_linux_options . clone ( ) . map_or (
239- SELinuxOptions {
240- user : Some ( user. to_string ( ) ) ,
241- ..SELinuxOptions :: default ( )
242- } ,
243- |o| SELinuxOptions {
244- user : Some ( user. to_string ( ) ) ,
245- ..o
246- } ,
247- ) ) ;
249+ self . pod_security_context . se_linux_options = Some (
250+ self . pod_security_context
251+ . se_linux_options
252+ . clone ( )
253+ . map_or_else (
254+ || SELinuxOptions {
255+ user : Some ( user. to_string ( ) ) ,
256+ ..SELinuxOptions :: default ( )
257+ } ,
258+ |o| SELinuxOptions {
259+ user : Some ( user. to_string ( ) ) ,
260+ ..o
261+ } ,
262+ ) ,
263+ ) ;
248264 self
249265 }
250266
251267 pub fn seccomp_profile_localhost ( & mut self , profile : & str ) -> & mut Self {
252- self . pod_security_context . seccomp_profile =
253- Some ( self . pod_security_context . seccomp_profile . clone ( ) . map_or (
254- SeccompProfile {
255- localhost_profile : Some ( profile. to_string ( ) ) ,
256- ..SeccompProfile :: default ( )
257- } ,
258- |o| SeccompProfile {
259- localhost_profile : Some ( profile. to_string ( ) ) ,
260- ..o
261- } ,
262- ) ) ;
268+ self . pod_security_context . seccomp_profile = Some (
269+ self . pod_security_context
270+ . seccomp_profile
271+ . clone ( )
272+ . map_or_else (
273+ || SeccompProfile {
274+ localhost_profile : Some ( profile. to_string ( ) ) ,
275+ ..SeccompProfile :: default ( )
276+ } ,
277+ |o| SeccompProfile {
278+ localhost_profile : Some ( profile. to_string ( ) ) ,
279+ ..o
280+ } ,
281+ ) ,
282+ ) ;
263283 self
264284 }
265285
266286 pub fn seccomp_profile_type ( & mut self , type_ : & str ) -> & mut Self {
267- self . pod_security_context . seccomp_profile =
268- Some ( self . pod_security_context . seccomp_profile . clone ( ) . map_or (
269- SeccompProfile {
270- type_ : type_. to_string ( ) ,
271- ..SeccompProfile :: default ( )
272- } ,
273- |o| SeccompProfile {
274- type_ : type_. to_string ( ) ,
275- ..o
276- } ,
277- ) ) ;
287+ self . pod_security_context . seccomp_profile = Some (
288+ self . pod_security_context
289+ . seccomp_profile
290+ . clone ( )
291+ . map_or_else (
292+ || SeccompProfile {
293+ type_ : type_. to_string ( ) ,
294+ ..SeccompProfile :: default ( )
295+ } ,
296+ |o| SeccompProfile {
297+ type_ : type_. to_string ( ) ,
298+ ..o
299+ } ,
300+ ) ,
301+ ) ;
278302 self
279303 }
280304
@@ -292,47 +316,59 @@ impl PodSecurityContextBuilder {
292316 }
293317
294318 pub fn win_credential_spec ( & mut self , spec : & str ) -> & mut Self {
295- self . pod_security_context . windows_options =
296- Some ( self . pod_security_context . windows_options . clone ( ) . map_or (
297- WindowsSecurityContextOptions {
298- gmsa_credential_spec : Some ( spec. to_string ( ) ) ,
299- ..WindowsSecurityContextOptions :: default ( )
300- } ,
301- |o| WindowsSecurityContextOptions {
302- gmsa_credential_spec : Some ( spec. to_string ( ) ) ,
303- ..o
304- } ,
305- ) ) ;
319+ self . pod_security_context . windows_options = Some (
320+ self . pod_security_context
321+ . windows_options
322+ . clone ( )
323+ . map_or_else (
324+ || WindowsSecurityContextOptions {
325+ gmsa_credential_spec : Some ( spec. to_string ( ) ) ,
326+ ..WindowsSecurityContextOptions :: default ( )
327+ } ,
328+ |o| WindowsSecurityContextOptions {
329+ gmsa_credential_spec : Some ( spec. to_string ( ) ) ,
330+ ..o
331+ } ,
332+ ) ,
333+ ) ;
306334 self
307335 }
308336
309337 pub fn win_credential_spec_name ( & mut self , name : & str ) -> & mut Self {
310- self . pod_security_context . windows_options =
311- Some ( self . pod_security_context . windows_options . clone ( ) . map_or (
312- WindowsSecurityContextOptions {
313- gmsa_credential_spec_name : Some ( name. to_string ( ) ) ,
314- ..WindowsSecurityContextOptions :: default ( )
315- } ,
316- |o| WindowsSecurityContextOptions {
317- gmsa_credential_spec_name : Some ( name. to_string ( ) ) ,
318- ..o
319- } ,
320- ) ) ;
338+ self . pod_security_context . windows_options = Some (
339+ self . pod_security_context
340+ . windows_options
341+ . clone ( )
342+ . map_or_else (
343+ || WindowsSecurityContextOptions {
344+ gmsa_credential_spec_name : Some ( name. to_string ( ) ) ,
345+ ..WindowsSecurityContextOptions :: default ( )
346+ } ,
347+ |o| WindowsSecurityContextOptions {
348+ gmsa_credential_spec_name : Some ( name. to_string ( ) ) ,
349+ ..o
350+ } ,
351+ ) ,
352+ ) ;
321353 self
322354 }
323355
324356 pub fn win_run_as_user_name ( & mut self , name : & str ) -> & mut Self {
325- self . pod_security_context . windows_options =
326- Some ( self . pod_security_context . windows_options . clone ( ) . map_or (
327- WindowsSecurityContextOptions {
328- run_as_user_name : Some ( name. to_string ( ) ) ,
329- ..WindowsSecurityContextOptions :: default ( )
330- } ,
331- |o| WindowsSecurityContextOptions {
332- run_as_user_name : Some ( name. to_string ( ) ) ,
333- ..o
334- } ,
335- ) ) ;
357+ self . pod_security_context . windows_options = Some (
358+ self . pod_security_context
359+ . windows_options
360+ . clone ( )
361+ . map_or_else (
362+ || WindowsSecurityContextOptions {
363+ run_as_user_name : Some ( name. to_string ( ) ) ,
364+ ..WindowsSecurityContextOptions :: default ( )
365+ } ,
366+ |o| WindowsSecurityContextOptions {
367+ run_as_user_name : Some ( name. to_string ( ) ) ,
368+ ..o
369+ } ,
370+ ) ,
371+ ) ;
336372 self
337373 }
338374}
0 commit comments