Merge pull request #337 from replicatedhq/divolgin/progress

Report back some basic progress
This commit is contained in:
divolgin
2021-03-18 12:11:54 -07:00
committed by GitHub
2 changed files with 29 additions and 0 deletions

View File

@@ -121,6 +121,20 @@ func runPreflights(v *viper.Viper, arg string) error {
}
}
}()
} else {
// make sure we don't block any senders
go func() {
for {
select {
case _, ok := <-progressCh:
if !ok {
return
}
case <-finishedCh:
return
}
}
}()
}
defer func() {

View File

@@ -18,6 +18,11 @@ type CollectOpts struct {
ProgressChan chan interface{}
}
type CollectProgress struct {
Name string
Status string
}
type CollectResult interface {
Analyze() []*analyze.AnalyzeResult
IsRBACAllowed() bool
@@ -144,12 +149,22 @@ func Collect(opts CollectOpts, p *troubleshootv1beta2.Preflight) (CollectResult,
}
}
opts.ProgressChan <- CollectProgress{
Name: collector.GetDisplayName(),
Status: "running",
}
result, err := collector.RunCollectorSync(nil)
if err != nil {
opts.ProgressChan <- errors.Errorf("failed to run collector %s: %v\n", collector.GetDisplayName(), err)
continue
}
opts.ProgressChan <- CollectProgress{
Name: collector.GetDisplayName(),
Status: "completed",
}
if result != nil {
for k, v := range result {
allCollectedData[k] = v