refactor: remove all calls to common.NewShellCmdWithArgs

This commit is contained in:
Jose Diaz-Gonzalez
2024-02-12 20:58:51 -05:00
parent 3c6cc68086
commit d8401a4d86
4 changed files with 76 additions and 56 deletions

View File

@@ -174,22 +174,27 @@ func LogVerboseQuietContainerLogsTail(containerID string, lines int, tail bool)
args = append(args, "--follow")
}
sc := NewShellCmdWithArgs(DockerBin(), args...)
var mu sync.Mutex
sc.Command.Stdout = &writer{
mu: &mu,
source: "stdout",
}
sc.Command.Stderr = &writer{
mu: &mu,
source: "stderr",
}
result, err := CallExecCommand(ExecCommandInput{
Command: DockerBin(),
Args: args,
DisableStdioBuffer: true,
StdoutWriter: &writer{
mu: &mu,
source: "stdout",
},
StderrWriter: &writer{
mu: &mu,
source: "stderr",
},
})
if err := sc.Command.Start(); err != nil {
if err != nil {
LogExclaim(fmt.Sprintf("Failed to fetch container logs: %s", containerID))
return
}
if err := sc.Command.Wait(); err != nil {
if !tail && result.ExitCode != 0 {
LogExclaim(fmt.Sprintf("Failed to fetch container logs: %s", containerID))
}
}