in internal/components/setup/common.go [130:157]
func RunCommandsAndWait(run config.Run, timeout time.Duration, cluster *util.K8sClusterInfo) error {
waitSet := util.NewWaitSet(timeout)
commands := run.Command
if len(commands) < 1 {
return nil
}
waitSet.WaitGroup.Add(1)
go executeCommandsAndWait(commands, run.Waits, waitSet, cluster)
go func() {
waitSet.WaitGroup.Wait()
close(waitSet.FinishChan)
}()
select {
case <-waitSet.FinishChan:
logger.Log.Infof("all commands executed successfully")
case err := <-waitSet.ErrChan:
logger.Log.Errorf("execute command error")
return err
case <-time.After(waitSet.Timeout):
return fmt.Errorf("wait for commands run timeout after %d seconds", int(timeout.Seconds()))
}
return nil
}