Skip to content

Commit d936d08

Browse files
committed
followup comments
1 parent 8cb03aa commit d936d08

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

integration/delete_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package integration
1818

1919
import (
2020
"context"
21+
"strings"
2122
"testing"
2223
"time"
2324

@@ -147,9 +148,9 @@ func getComposeContainers(ctx context.Context, t *testutil.T, projectNamePrefix
147148
for _, c := range cl {
148149
if project, ok := c.Labels["com.docker.compose.project"]; ok {
149150
// Check if project name starts with the prefix (e.g., "skaffold-")
150-
if len(project) > len(projectNamePrefix) && project[:len(projectNamePrefix)] == projectNamePrefix {
151-
result = append(result, c)
152-
}
151+
if strings.HasPrefix(project, projectNamePrefix) {
152+
result = append(result, c)
153+
}
153154
}
154155
}
155156

integration/util.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -523,20 +523,19 @@ func waitForComposeContainersRunning(t *testing.T, projectNamePrefix string, min
523523
var runningCount int
524524
for _, c := range containers {
525525
if project, ok := c.Labels["com.docker.compose.project"]; ok {
526-
if len(project) >= len(projectNamePrefix) && project[:len(projectNamePrefix)] == projectNamePrefix {
527-
// Verify container is actually running
528-
cInfo, err := client.RawClient().ContainerInspect(ctx, c.ID)
529-
if err != nil {
530-
return false, err
531-
}
532-
533-
if cInfo.State.Running {
534-
runningCount++
535-
}
536-
537-
if cInfo.State.Dead || cInfo.State.Restarting {
538-
return false, fmt.Errorf("container %v is in dead or restarting state", c.ID)
539-
}
526+
// Check if project name starts with the prefix (e.g., "skaffold-")
527+
if strings.HasPrefix(project, projectNamePrefix) {
528+
// The container is already known to be running from ContainerList(All: false).
529+
// We only need to inspect to check for undesirable states like restarting.
530+
cInfo, err := client.RawClient().ContainerInspect(ctx, c.ID)
531+
if err != nil {
532+
return false, err
533+
}
534+
535+
if cInfo.State.Dead || cInfo.State.Restarting {
536+
return false, fmt.Errorf("container %v is in dead or restarting state", c.ID)
537+
}
538+
runningCount++
540539
}
541540
}
542541
}

0 commit comments

Comments
 (0)