(nodeUser, node, containerName string)
| 84 | } |
| 85 | |
| 86 | func checkContainerExistence(nodeUser, node, containerName string) (bool, error) { |
| 87 | cmd := exec.Command("ssh", nodeUser+"@"+node, "docker ps -a --format "+`{{.Names}}`+" | grep "+`"`+containerName+`"`) |
| 88 | output, err := cmd.Output() |
| 89 | if err != nil { |
| 90 | return false, err |
| 91 | } |
| 92 | for _, name := range strings.Fields(string(output)) { |
| 93 | if name == containerName { |
| 94 | return true, nil |
| 95 | } |
| 96 | } |
| 97 | return false, nil |
| 98 | } |
| 99 | |
| 100 | func checkAndDeleteContainerOnNode(nodeUser, node, containerName string) error { |
| 101 | if ok, _ := checkContainerExistence(nodeUser, node, containerName); ok { |
no test coverage detected