WithContainerSecurityContext ensures that, if in the current status there is a container with the passed name and the securityContext is empty, the securityContext will be set to the one passed. If `overwrite` is true the command is overwritten even when it's not empty
( name string, ctx *corev1.SecurityContext, overwrite bool, )
| 269 | // set to the one passed. |
| 270 | // If `overwrite` is true the command is overwritten even when it's not empty |
| 271 | func (builder *Builder) WithContainerSecurityContext( |
| 272 | name string, |
| 273 | ctx *corev1.SecurityContext, |
| 274 | overwrite bool, |
| 275 | ) *Builder { |
| 276 | builder.WithContainer(name) |
| 277 | |
| 278 | for idx, value := range builder.status.Spec.Containers { |
| 279 | if value.Name == name { |
| 280 | if overwrite || value.SecurityContext == nil { |
| 281 | builder.status.Spec.Containers[idx].SecurityContext = ctx |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | return builder |
| 287 | } |
| 288 | |
| 289 | // WithInitContainer ensures that in the current status there is an init container |
| 290 | // with the passed name |
no test coverage detected