mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
Merge pull request #337 from replicatedhq/divolgin/progress
Report back some basic progress
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user