MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / WithContainerPort

Method WithContainerPort

pkg/podspec/builder.go:246–265  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
246func (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

Callers 2

builder_test.goFile · 0.80
DeploymentFunction · 0.80

Calls 1

WithContainerMethod · 0.95

Tested by

no test coverage detected