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

Method WithContainerSecurityContext

pkg/podspec/builder.go:271–287  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

269// set to the one passed.
270// If `overwrite` is true the command is overwritten even when it's not empty
271func (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

Callers 1

DeploymentFunction · 0.80

Calls 1

WithContainerMethod · 0.95

Tested by

no test coverage detected