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 Dec 1, 2023
1 parent 7b8a671 commit f895e95
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions internal/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,19 @@ func (fs *FileSystem) runTransform(currentRunDir string, currentRunConfigPaths [
logrus.Errorf("failed to start the transform command. Error: %q", err)
return err
}
flag := true
go func() {
if err := cmd.Wait(); err != nil {
logrus.Errorf("failed to wait for end of the transform command. Error: %q", err)
}
logrus.Debugf("Closing transformCh: %t", flag)
if flag {
flag = false
transformCh <- nil
close(transformCh)
}

}()
wg := sync.WaitGroup{}
outCh := make(chan string, 10)
stdoutReader := bufio.NewReader(stdout)
Expand Down Expand Up @@ -2454,17 +2467,17 @@ func (fs *FileSystem) runTransform(currentRunDir string, currentRunConfigPaths [
}
text, err = stderrReader.ReadString('\n')
}
logrus.Debugf("failed to fetch the stderr of move2kube transform. Error: %q", err)
logrus.Infof("failed to fetch the stderr of move2kube transform. Error: %q", err)
wg.Done()
}()
go func() {
wg.Wait()
close(outCh)
}()
flag := true
for outputLine := range outCh {
if flag && strings.Contains(outputLine, portStr) {
flag = false
logrus.Debug("Closing transformCh")
transformCh <- nil
close(transformCh)
}
Expand Down

0 comments on commit f895e95

Please sign in to comment.