mirror of
https://github.com/turbot/steampipe.git
synced 2026-03-06 06:35:52 -05:00
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package reportexecute
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/turbot/steampipe/db/db_common"
|
|
"github.com/turbot/steampipe/report/reportevents"
|
|
"github.com/turbot/steampipe/report/reportinterfaces"
|
|
"github.com/turbot/steampipe/statushooks"
|
|
"github.com/turbot/steampipe/workspace"
|
|
)
|
|
|
|
func ExecuteReportNode(ctx context.Context, reportName string, workspace *workspace.Workspace, client db_common.Client) error {
|
|
// create context for the report execution
|
|
// (for now just disable all status messages - replace with event based? )
|
|
reportCtx := statushooks.DisableStatusHooks(ctx)
|
|
executionTree, err := NewReportExecutionTree(reportName, client, workspace)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
go func() {
|
|
workspace.PublishReportEvent(&reportevents.ExecutionStarted{ReportNode: executionTree.Root})
|
|
|
|
if err := executionTree.Execute(reportCtx); err != nil {
|
|
if executionTree.Root.GetRunStatus() != reportinterfaces.ReportRunError {
|
|
// set error state on the root node
|
|
executionTree.Root.SetError(err)
|
|
}
|
|
}
|
|
workspace.PublishReportEvent(&reportevents.ExecutionComplete{Report: executionTree.Root})
|
|
}()
|
|
|
|
return nil
|
|
}
|