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

Method WithContainerEnv

pkg/podspec/builder.go:160–180  ·  view source on GitHub ↗

WithContainerEnv add the provided EnvVar to a container

(name string, env corev1.EnvVar, overwrite bool)

Source from the content-addressed store, hash-verified

158
159// WithContainerEnv add the provided EnvVar to a container
160func (builder *Builder) WithContainerEnv(name string, env corev1.EnvVar, overwrite bool) *Builder {
161 builder.WithContainer(name)
162
163 for idxContainer, container := range builder.status.Spec.Containers {
164 if container.Name == name {
165 for idx, envVar := range container.Env {
166 if envVar.Name == env.Name {
167 if overwrite {
168 builder.status.Spec.Containers[idxContainer].Env[idx] = env
169 }
170 return builder
171 }
172 }
173
174 builder.status.Spec.Containers[idxContainer].Env = append(builder.status.Spec.Containers[idxContainer].Env, env)
175 return builder
176 }
177 }
178
179 return builder
180}
181
182// WithServiceAccountName add the provided ServiceAccountName
183func (builder *Builder) WithServiceAccountName(name string, overwrite bool) *Builder {

Callers 2

builder_test.goFile · 0.80
DeploymentFunction · 0.80

Calls 1

WithContainerMethod · 0.95

Tested by

no test coverage detected