WithContainerPort ensures that, if in the current status there is a container with the passed name the passed container port will be added, possibly overriding the one already present with the same name
(name string, value *corev1.ContainerPort)
| 244 | // a container with the passed name the passed container port will be |
| 245 | // added, possibly overriding the one already present with the same name |
| 246 | func (builder *Builder) WithContainerPort(name string, value *corev1.ContainerPort) *Builder { |
| 247 | builder.WithContainer(name) |
| 248 | |
| 249 | for idxContainer, container := range builder.status.Spec.Containers { |
| 250 | if container.Name == name { |
| 251 | for idxPort, port := range container.Ports { |
| 252 | if port.Name == value.Name { |
| 253 | builder.status.Spec.Containers[idxContainer].Ports[idxPort] = *value |
| 254 | return builder |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | builder.status.Spec.Containers[idxContainer].Ports = append( |
| 259 | builder.status.Spec.Containers[idxContainer].Ports, |
| 260 | *value) |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | return builder |
| 265 | } |
| 266 | |
| 267 | // WithContainerSecurityContext ensures that, if in the current status there is |
| 268 | // a container with the passed name and the securityContext is empty, the securityContext will be |
no test coverage detected