Skip to content

Commit

Permalink
Improving how transformation cmd completion is detected
Browse files Browse the repository at this point in the history
Signed-off-by: gabriel-farache <gfarache@redhat.com>
  • Loading branch information
gabriel-farache committed Nov 28, 2023
1 parent 8026f8b commit 996704b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,14 @@ func (fs *FileSystem) runTransform(currentRunDir string, currentRunConfigPaths [
logrus.Errorf("failed to start the transform command. Error: %q", err)
return err
}
go func() {
if err := cmd.Wait(); err != nil {
logrus.Errorf("failed to wait for end of the transform command. Error: %q", err)
}
logrus.Debug("Closing transform channel")
transformCh <- nil
close(transformCh)
}()
wg := sync.WaitGroup{}
outCh := make(chan string, 10)
stdoutReader := bufio.NewReader(stdout)
Expand Down Expand Up @@ -2461,13 +2469,7 @@ func (fs *FileSystem) runTransform(currentRunDir string, currentRunConfigPaths [
wg.Wait()
close(outCh)
}()
flag := true
for outputLine := range outCh {
if flag && strings.Contains(outputLine, portStr) {
flag = false
transformCh <- nil
close(transformCh)
}
if verbose {
generateVerboseLogs(outputLine)
} else {
Expand Down

0 comments on commit 996704b

Please sign in to comment.