mirror of
https://github.com/turbot/steampipe.git
synced 2026-03-24 11:00:34 -04:00
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/turbot/go-kit/helpers"
|
|
"github.com/turbot/steampipe-plugin-sdk/logging"
|
|
"github.com/turbot/steampipe/cmdconfig"
|
|
"github.com/turbot/steampipe/constants"
|
|
"github.com/turbot/steampipe/report/reportserver"
|
|
"github.com/turbot/steampipe/utils"
|
|
)
|
|
|
|
func reportCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "report [report]",
|
|
TraverseChildren: true,
|
|
Args: cobra.ArbitraryArgs,
|
|
Run: runReportCmd,
|
|
Short: "Run a report",
|
|
Long: `Run a report...TODO better description!`,
|
|
}
|
|
|
|
cmdconfig.OnCmd(cmd).
|
|
AddBoolFlag(constants.ArgHelp, "h", false, "Help for report")
|
|
return cmd
|
|
}
|
|
|
|
func runReportCmd(cmd *cobra.Command, args []string) {
|
|
logging.LogTime("runReportCmd start")
|
|
defer func() {
|
|
logging.LogTime("runReportCmd end")
|
|
if r := recover(); r != nil {
|
|
utils.ShowError(helpers.ToError(r))
|
|
}
|
|
}()
|
|
|
|
cmdconfig.Viper().Set(constants.ConfigKeyShowInteractiveOutput, false)
|
|
|
|
ctx, cancel := context.WithCancel(cmd.Context())
|
|
startCancelHandler(cancel)
|
|
|
|
// start db if necessary
|
|
//err := db_local.EnsureDbAndStartService(constants.InvokerReport, true)
|
|
//utils.FailOnErrorWithMessage(err, "failed to start service")
|
|
//defer db_local.ShutdownService(constants.InvokerReport)
|
|
|
|
server, err := reportserver.NewServer(ctx)
|
|
|
|
if err != nil {
|
|
utils.FailOnError(err)
|
|
}
|
|
|
|
defer server.Shutdown()
|
|
|
|
server.Start()
|
|
}
|