Skip to content

Commit 61c4267

Browse files
committed
refactor: use replacePods[*].containerName if persistPath.containerName not found
1 parent 3b54ca3 commit 61c4267

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/devspace/services/podreplace/persist.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ func persistPaths(podName string, replacePod *latest.ReplacePod, copiedPod *core
3737
}
3838

3939
if len(copiedPod.Spec.Containers) > 1 && p.ContainerName == "" {
40-
names := []string{}
41-
for _, c := range copiedPod.Spec.Containers {
42-
names = append(names, c.Name)
40+
if replacePod.ContainerName == "" {
41+
names := []string{}
42+
for _, c := range copiedPod.Spec.Containers {
43+
names = append(names, c.Name)
44+
}
45+
46+
return fmt.Errorf("couldn't persist path %s as multiple containers were found %s, but no containerName was specified", p.Path, strings.Join(names, " "))
4347
}
4448

45-
return fmt.Errorf("couldn't persist path %s as multiple containers were found %s, but no containerName was specified", p.Path, strings.Join(names, " "))
49+
p.ContainerName = replacePod.ContainerName
4650
}
4751

4852
var container *corev1.Container

0 commit comments

Comments
 (0)