Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use filtered table output to list running Otel containers #17

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions cmd/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ func getIDs(dockerOutput []byte) []string {
var result []string
outputArray := strings.Split(string(dockerOutput), "\n")

for _, entry := range outputArray {
// Each container in the Docker Compose stack will have the name of the directory
if strings.Contains(entry, otelConfigDirName) {
fields := strings.Fields(entry)
if len(fields) > 0 {
result = append(result, fields[0])
}
for _, entry := range outputArray[1:] {
calebschoepp marked this conversation as resolved.
Show resolved Hide resolved
fields := strings.Fields(entry)
if len(fields) > 0 {
result = append(result, fields[0])
}
}

Expand All @@ -42,8 +39,7 @@ func cleanUp() error {
}

fmt.Println("Stopping Spin OTel Docker containers...")

getContainers := exec.Command("docker", "ps")
getContainers := exec.Command("docker", "ps", fmt.Sprintf("--filter=name=%s*", otelConfigDirName), "--format=table")
dockerPsOutput, err := getContainers.CombinedOutput()
if err != nil {
fmt.Println(string(dockerPsOutput))
Expand Down
Loading