(ctx devspacecontext.Context, devPod *latest.DevPod, devContainer *latest.DevContainer, podTemplate *corev1.PodTemplateSpec)
| 433 | } |
| 434 | |
| 435 | func 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 | |
| 462 | func hashConfig(replacePod *latest.DevPod) (string, error) { |
| 463 | out, err := yaml.Marshal(replacePod) |
no test coverage detected