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

Method WithContainerVolumeMount

pkg/podspec/builder.go:134–157  ·  view source on GitHub ↗

WithContainerVolumeMount 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

132// WithContainerVolumeMount ensure that the passed the volume mount exist in
133// the current status, overriding the present one when needed
134func (builder *Builder) WithContainerVolumeMount(
135 name string, volumeMount *corev1.VolumeMount, overwrite bool,
136) *Builder {
137 builder.WithContainer(name)
138
139 for idxContainer, container := range builder.status.Spec.Containers {
140 if container.Name == name {
141 for idxMount, mount := range container.VolumeMounts {
142 if mount.Name == volumeMount.Name {
143 if overwrite {
144 builder.status.Spec.Containers[idxContainer].VolumeMounts[idxMount] = *volumeMount
145 }
146 return builder
147 }
148 }
149
150 builder.status.Spec.Containers[idxContainer].VolumeMounts = append(
151 builder.status.Spec.Containers[idxContainer].VolumeMounts,
152 *volumeMount)
153 }
154 }
155
156 return builder
157}
158
159// WithContainerEnv add the provided EnvVar to a container
160func (builder *Builder) WithContainerEnv(name string, env corev1.EnvVar, overwrite bool) *Builder {

Callers 2

builder_test.goFile · 0.80
DeploymentFunction · 0.80

Calls 1

WithContainerMethod · 0.95

Tested by

no test coverage detected