Skip to content

Commit d684885

Browse files
committed
followup comments
1 parent 8cb03aa commit d684885

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

integration/delete_test.go

Lines changed: 2 additions & 1 deletion
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,7 +148,7 @@ 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+
if strings.HasPrefix(project, projectNamePrefix) {
151152
result = append(result, c)
152153
}
153154
}

integration/util.go

Lines changed: 5 additions & 6 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
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.
528530
cInfo, err := client.RawClient().ContainerInspect(ctx, c.ID)
529531
if err != nil {
530532
return false, err
531533
}
532534

533-
if cInfo.State.Running {
534-
runningCount++
535-
}
536-
537535
if cInfo.State.Dead || cInfo.State.Restarting {
538536
return false, fmt.Errorf("container %v is in dead or restarting state", c.ID)
539537
}
538+
runningCount++
540539
}
541540
}
542541
}

0 commit comments

Comments
 (0)