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

Method WithInitContainerVolumeMount

pkg/podspec/builder.go:325–348  ·  view source on GitHub ↗

WithInitContainerVolumeMount ensure that the passed the volume mount exist in the current status, overriding the present one when needed

(
	name string, volumeMount *corev1.VolumeMount, overwrite bool,
)

Source from the content-addressed store, hash-verified

323// WithInitContainerVolumeMount ensure that the passed the volume mount exist in
324// the current status, overriding the present one when needed
325func (builder *Builder) WithInitContainerVolumeMount(
326 name string, volumeMount *corev1.VolumeMount, overwrite bool,
327) *Builder {
328 builder.WithInitContainer(name)
329
330 for idxContainer, container := range builder.status.Spec.InitContainers {
331 if container.Name == name {
332 for idxMount, mount := range container.VolumeMounts {
333 if mount.Name == volumeMount.Name {
334 if overwrite {
335 builder.status.Spec.InitContainers[idxContainer].VolumeMounts[idxMount] = *volumeMount
336 }
337 return builder
338 }
339 }
340
341 builder.status.Spec.InitContainers[idxContainer].VolumeMounts = append(
342 builder.status.Spec.InitContainers[idxContainer].VolumeMounts,
343 *volumeMount)
344 }
345 }
346
347 return builder
348}
349
350// WithInitContainerCommand ensures that, if in the current status there is
351// an init container with the passed name and the command is empty, the command will be

Callers 2

builder_test.goFile · 0.80
DeploymentFunction · 0.80

Calls 1

WithInitContainerMethod · 0.95

Tested by

no test coverage detected