MCPcopy
hub / github.com/kubernetes/test-infra / processContainers

Function processContainers

releng/config-forker/pkg/forker.go:209–262  ·  view source on GitHub ↗

processContainers applies env var fixes, image fixes, and replacement annotations to all containers in a pod spec. It returns an error wrapping the job name if any replacement fails.

(
	ctx context.Context,
	spec *v1.PodSpec,
	vars templateVars,
	annotation string,
	jobName string,
	resolver ImageResolver,
)

Source from the content-addressed store, hash-verified

207// annotations to all containers in a pod spec. It returns an error wrapping
208// the job name if any replacement fails.
209func processContainers(
210 ctx context.Context,
211 spec *v1.PodSpec,
212 vars templateVars,
213 annotation string,
214 jobName string,
215 resolver ImageResolver,
216) error {
217 if spec == nil {
218 return nil
219 }
220
221 for idx := range spec.Containers {
222 container := &spec.Containers[idx]
223 container.Env = fixEnvVars(container.Env, vars.Version)
224 container.Image = fixImage(container.Image, vars.Version)
225
226 var err error
227
228 container.Image, err = resolveImage(ctx, resolver, container.Image)
229 if err != nil {
230 return fmt.Errorf("%s: %w", jobName, err)
231 }
232
233 container.Command, err = performReplacement(
234 container.Command, vars, annotation,
235 )
236 if err != nil {
237 return fmt.Errorf("%s: %w", jobName, err)
238 }
239
240 container.Args, err = performReplacement(
241 container.Args, vars, annotation,
242 )
243 if err != nil {
244 return fmt.Errorf("%s: %w", jobName, err)
245 }
246
247 for envIdx := range container.Env {
248 container.Env[envIdx].Name,
249 container.Env[envIdx].Value,
250 err = performEnvReplacement(
251 container.Env[envIdx].Name,
252 container.Env[envIdx].Value,
253 vars, annotation,
254 )
255 if err != nil {
256 return fmt.Errorf("%s: %w", jobName, err)
257 }
258 }
259 }
260
261 return nil
262}
263
264func generatePostsubmits(
265 ctx context.Context,

Callers 2

generatePostsubmitsFunction · 0.85
generatePresubmitsFunction · 0.85

Calls 5

fixEnvVarsFunction · 0.85
fixImageFunction · 0.85
resolveImageFunction · 0.85
performReplacementFunction · 0.85
performEnvReplacementFunction · 0.85

Tested by

no test coverage detected