MCPcopy Index your code
hub / github.com/devspace-sh/devspace / getPodTemplateContainer

Function getPodTemplateContainer

pkg/devspace/services/podreplace/builder.go:435–460  ·  view source on GitHub ↗
(ctx devspacecontext.Context, devPod *latest.DevPod, devContainer *latest.DevContainer, podTemplate *corev1.PodTemplateSpec)

Source from the content-addressed store, hash-verified

433}
434
435func getPodTemplateContainer(ctx devspacecontext.Context, devPod *latest.DevPod, devContainer *latest.DevContainer, podTemplate *corev1.PodTemplateSpec) (int, *corev1.Container, error) {
436 containerName := devContainer.Container
437 if containerName == "" && len(podTemplate.Spec.Containers) > 1 {
438 containers, err := matchesImageSelector(ctx, podTemplate, devPod)
439 if err != nil {
440 return 0, nil, err
441 } else if len(containers) != 1 {
442 names := []string{}
443 for _, c := range podTemplate.Spec.Containers {
444 names = append(names, c.Name)
445 }
446
447 return 0, nil, fmt.Errorf("couldn't modify pod as multiple containers were found '%s', but no dev.*.container was specified", strings.Join(names, "' '"))
448 }
449
450 containerName = containers[0]
451 }
452
453 for i, con := range podTemplate.Spec.Containers {
454 if containerName == "" || con.Name == containerName {
455 return i, &con, nil
456 }
457 }
458
459 return 0, nil, fmt.Errorf("couldn't find container '%s' in pod", containerName)
460}
461
462func hashConfig(replacePod *latest.DevPod) (string, error) {
463 out, err := yaml.Marshal(replacePod)

Callers 8

replaceResourcesFunction · 0.85
replaceWorkingDirFunction · 0.85
replaceSecurityContextFunction · 0.85
replaceCommandFunction · 0.85
replaceEnvFunction · 0.85
replaceAttachFunction · 0.85
replaceTerminalFunction · 0.85
replaceImageFunction · 0.85

Calls 2

matchesImageSelectorFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected