WithContainerEnv add the provided EnvVar to a container
(name string, env corev1.EnvVar, overwrite bool)
| 158 | |
| 159 | // WithContainerEnv add the provided EnvVar to a container |
| 160 | func (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 |
| 183 | func (builder *Builder) WithServiceAccountName(name string, overwrite bool) *Builder { |
no test coverage detected