mirror of
https://github.com/BishopFox/steampipe.git
synced 2026-11-07 10:25:57 -10:00
Rename report command to dashboard. #1459
This commit is contained in:
1 parent
5dd0dd69d8
commit
fff587f596
8 files changed
+59
-60
No files matched your search
@@ -16,32 +16,32 @@ import (
|
||||
"github.com/turbot/steampipe/utils"
|
||||
)
|
||||
|
||||
func reportCmd() *cobra.Command {
|
||||
func dashboardCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "report",
|
||||
Use: "dashboard",
|
||||
TraverseChildren: true,
|
||||
Args: cobra.ArbitraryArgs,
|
||||
Run: runReportCmd,
|
||||
Short: "Start the local report UI",
|
||||
Long: `Starts a local web server that enables real-time development of reports within the current mod.
|
||||
Run: runDashboardCmd,
|
||||
Short: "Start the local dashboard UI",
|
||||
Long: `Starts a local web server that enables real-time development of dashboards within the current mod.
|
||||
|
||||
The current mod is the working directory, or the directory specified by the --workspace-chdir flag.`,
|
||||
}
|
||||
|
||||
cmdconfig.OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgHelp, "h", false, "Help for report").
|
||||
AddBoolFlag(constants.ArgHelp, "h", false, "Help for dashboard").
|
||||
AddStringFlag(constants.ArgDashboardServerListen, "", string(dashboardserver.ListenTypeLocal), "Accept connections from: local (localhost only) or network (open)").
|
||||
AddIntFlag(constants.ArgDashboardServerPort, "", constants.ReportServerDefaultPort, "Report server port.")
|
||||
AddIntFlag(constants.ArgDashboardServerPort, "", constants.DashboardServerDefaultPort, "Dashboard server port.")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runReportCmd(cmd *cobra.Command, args []string) {
|
||||
func runDashboardCmd(cmd *cobra.Command, args []string) {
|
||||
ctx, cancel := context.WithCancel(cmd.Context())
|
||||
contexthelpers.StartCancelHandler(cancel)
|
||||
|
||||
logging.LogTime("runReportCmd start")
|
||||
logging.LogTime("runDashboardCmd start")
|
||||
defer func() {
|
||||
logging.LogTime("runReportCmd end")
|
||||
logging.LogTime("runDashboardCmd end")
|
||||
if r := recover(); r != nil {
|
||||
utils.ShowError(ctx, helpers.ToError(r))
|
||||
}
|
||||
@@ -53,12 +53,11 @@ func runReportCmd(cmd *cobra.Command, args []string) {
|
||||
serverListen := dashboardserver.ListenType(viper.GetString(constants.ArgDashboardServerListen))
|
||||
utils.FailOnError(serverListen.IsValid())
|
||||
|
||||
// ensure report assets are present and extract if not
|
||||
// ensure dashboard assets are present and extract if not
|
||||
err := dashboardassets.Ensure(ctx)
|
||||
utils.FailOnError(err)
|
||||
|
||||
|
||||
dbClient, err := db_local.GetLocalClient(ctx, constants.InvokerReport)
|
||||
dbClient, err := db_local.GetLocalClient(ctx, constants.InvokerDashboard)
|
||||
utils.FailOnError(err)
|
||||
|
||||
refreshResult := dbClient.RefreshConnectionAndSearchPaths(ctx)
|
||||
+1
-1
@@ -184,7 +184,7 @@ func AddCommands() {
|
||||
modCmd(),
|
||||
generateCompletionScriptsCmd(),
|
||||
pluginManagerCmd(),
|
||||
reportCmd(),
|
||||
dashboardCmd(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package constants
|
||||
|
||||
const (
|
||||
DashboardServerDefaultPort = 9194
|
||||
DashboardAssetsVersion = "0.13.0-alpha.7"
|
||||
DashboardAssetsImageRef = "us-docker.pkg.dev/steampipe/steampipe/assets:" + DashboardAssetsVersion
|
||||
)
|
||||
+19
-19
@@ -79,21 +79,21 @@ var ReservedConnectionNames = []string{
|
||||
|
||||
// introspection table names
|
||||
const (
|
||||
IntrospectionTableQuery = "steampipe_query"
|
||||
IntrospectionTableControl = "steampipe_control"
|
||||
IntrospectionTableBenchmark = "steampipe_benchmark"
|
||||
IntrospectionTableMod = "steampipe_mod"
|
||||
IntrospectionTableReport = "steampipe_report"
|
||||
IntrospectionTableContainer = "steampipe_report_container"
|
||||
IntrospectionTableReportCard = "steampipe_report_card"
|
||||
IntrospectionTableReportChart = "steampipe_report_chart"
|
||||
IntrospectionTableReportHierarchy = "steampipe_report_hierarchy"
|
||||
IntrospectionTableReportImage = "steampipe_report_image"
|
||||
IntrospectionTableReportInput = "steampipe_report_input"
|
||||
IntrospectionTableReportTable = "steampipe_report_table"
|
||||
IntrospectionTableReportText = "steampipe_report_text"
|
||||
IntrospectionTableVariable = "steampipe_variable"
|
||||
IntrospectionTableReference = "steampipe_reference"
|
||||
IntrospectionTableQuery = "steampipe_query"
|
||||
IntrospectionTableControl = "steampipe_control"
|
||||
IntrospectionTableBenchmark = "steampipe_benchmark"
|
||||
IntrospectionTableMod = "steampipe_mod"
|
||||
IntrospectionTableDashboard = "steampipe_dashboard"
|
||||
IntrospectionTableDashboardContainer = "steampipe_dashboard_container"
|
||||
IntrospectionTableDashboardCard = "steampipe_dashboard_card"
|
||||
IntrospectionTableDashboardChart = "steampipe_dashboard_chart"
|
||||
IntrospectionTableDashboardHierarchy = "steampipe_dashboard_hierarchy"
|
||||
IntrospectionTableDashboardImage = "steampipe_dashboard_image"
|
||||
IntrospectionTableDashboardInput = "steampipe_dashboard_input"
|
||||
IntrospectionTableDashboardTable = "steampipe_dashboard_table"
|
||||
IntrospectionTableDashboardText = "steampipe_dashboard_text"
|
||||
IntrospectionTableVariable = "steampipe_variable"
|
||||
IntrospectionTableReference = "steampipe_reference"
|
||||
)
|
||||
|
||||
// Invoker is a pseudoEnum for the command/operation which starts the service
|
||||
@@ -108,8 +108,8 @@ const (
|
||||
InvokerCheck = "check"
|
||||
// InvokerPlugin is set when invoked by a plugin command
|
||||
InvokerPlugin = "plugin"
|
||||
// InvokerReport is set when invoked by report command
|
||||
InvokerReport = "report"
|
||||
// InvokerDashboard is set when invoked by dashboard command
|
||||
InvokerDashboard = "dashboard"
|
||||
// InvokerConnectionWatcher is set when invoked by the connection watcher process
|
||||
InvokerConnectionWatcher = "connection-watcher"
|
||||
)
|
||||
@@ -117,8 +117,8 @@ const (
|
||||
// IsValid is a validator for Invoker known values
|
||||
func (i Invoker) IsValid() error {
|
||||
switch i {
|
||||
case InvokerService, InvokerQuery, InvokerCheck, InvokerPlugin, InvokerReport:
|
||||
case InvokerService, InvokerQuery, InvokerCheck, InvokerPlugin, InvokerDashboard:
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid invoker. Can be one of '%v', '%v', '%v', '%v' or '%v' ", InvokerService, InvokerQuery, InvokerPlugin, InvokerCheck, InvokerReport)
|
||||
return fmt.Errorf("invalid invoker. Can be one of '%v', '%v', '%v', '%v' or '%v' ", InvokerService, InvokerQuery, InvokerPlugin, InvokerCheck, InvokerDashboard)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package constants
|
||||
|
||||
const (
|
||||
ReportServerDefaultPort = 9194
|
||||
AssetsVersion = "0.13.0-alpha.7"
|
||||
AssetsImageRef = "us-docker.pkg.dev/steampipe/steampipe/assets:" + AssetsVersion
|
||||
)
|
||||
@@ -24,7 +24,7 @@ func Ensure(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if versionFile.Version == constants.AssetsVersion {
|
||||
if versionFile.Version == constants.DashboardAssetsVersion {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -50,15 +50,15 @@ func getCreateTablesSql(commonColumnSql []string) string {
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.Benchmark{}, constants.IntrospectionTableBenchmark, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.Mod{}, constants.IntrospectionTableMod, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.Variable{}, constants.IntrospectionTableVariable, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardContainer{}, constants.IntrospectionTableReport, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardContainer{}, constants.IntrospectionTableContainer, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardCard{}, constants.IntrospectionTableReportCard, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardChart{}, constants.IntrospectionTableReportChart, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardHierarchy{}, constants.IntrospectionTableReportHierarchy, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardImage{}, constants.IntrospectionTableReportImage, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardInput{}, constants.IntrospectionTableReportInput, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardTable{}, constants.IntrospectionTableReportTable, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardText{}, constants.IntrospectionTableReportText, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardContainer{}, constants.IntrospectionTableDashboard, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardContainer{}, constants.IntrospectionTableDashboardContainer, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardCard{}, constants.IntrospectionTableDashboardCard, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardChart{}, constants.IntrospectionTableDashboardChart, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardHierarchy{}, constants.IntrospectionTableDashboardHierarchy, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardImage{}, constants.IntrospectionTableDashboardImage, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardInput{}, constants.IntrospectionTableDashboardInput, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardTable{}, constants.IntrospectionTableDashboardTable, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.DashboardText{}, constants.IntrospectionTableDashboardText, commonColumnSql))
|
||||
createSql = append(createSql, getTableCreateSqlForResource(modconfig.ResourceReference{}, constants.IntrospectionTableReference, commonColumnSql))
|
||||
return strings.Join(createSql, "\n")
|
||||
}
|
||||
@@ -82,31 +82,31 @@ func getTableInsertSql(workspaceResources *modconfig.WorkspaceResourceMaps) stri
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(variable, constants.IntrospectionTableVariable))
|
||||
}
|
||||
for _, report := range workspaceResources.Dashboards {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(report, constants.IntrospectionTableReport))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(report, constants.IntrospectionTableDashboard))
|
||||
}
|
||||
for _, container := range workspaceResources.DashboardContainers {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(container, constants.IntrospectionTableContainer))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(container, constants.IntrospectionTableDashboardContainer))
|
||||
}
|
||||
for _, card := range workspaceResources.DashboardCards {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(card, constants.IntrospectionTableReportCard))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(card, constants.IntrospectionTableDashboardCard))
|
||||
}
|
||||
for _, chart := range workspaceResources.DashboardCharts {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(chart, constants.IntrospectionTableReportChart))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(chart, constants.IntrospectionTableDashboardChart))
|
||||
}
|
||||
for _, hierarchy := range workspaceResources.DashboardHierarchies {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(hierarchy, constants.IntrospectionTableReportHierarchy))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(hierarchy, constants.IntrospectionTableDashboardHierarchy))
|
||||
}
|
||||
for _, image := range workspaceResources.DashboardImages {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(image, constants.IntrospectionTableReportImage))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(image, constants.IntrospectionTableDashboardImage))
|
||||
}
|
||||
for _, image := range workspaceResources.DashboardInputs {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(image, constants.IntrospectionTableReportInput))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(image, constants.IntrospectionTableDashboardInput))
|
||||
}
|
||||
for _, table := range workspaceResources.DashboardTables {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(table, constants.IntrospectionTableReportTable))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(table, constants.IntrospectionTableDashboardTable))
|
||||
}
|
||||
for _, text := range workspaceResources.DashboardTexts {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(text, constants.IntrospectionTableReportText))
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(text, constants.IntrospectionTableDashboardText))
|
||||
}
|
||||
for _, reference := range workspaceResources.References {
|
||||
insertSql = append(insertSql, getTableInsertSqlForResource(reference, constants.IntrospectionTableReference))
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
// InstallAssets installs the Steampipe report server assets
|
||||
func InstallAssets(ctx context.Context, dest string) error {
|
||||
imageRef := constants.AssetsImageRef
|
||||
imageRef := constants.DashboardAssetsImageRef
|
||||
tempDir := NewTempDir(imageRef)
|
||||
defer tempDir.Delete()
|
||||
|
||||
|
||||
Reference in new issue
Block a user