mirror of
https://github.com/turbot/steampipe.git
synced 2026-03-24 11:00:34 -04:00
Show error if export flag set for interactive query. Closes #2696
Fail with helpful message if invalid typename passed to check command. Closes #2693
This commit is contained in:
@@ -153,6 +153,9 @@ func validateQueryArgs(ctx context.Context, args []string) error {
|
||||
if interactiveMode && (viper.IsSet(constants.ArgSnapshot) || viper.IsSet(constants.ArgShare)) {
|
||||
return fmt.Errorf("cannot share snapshots in interactive mode")
|
||||
}
|
||||
if len(viper.GetStringSlice(constants.ArgExport)) > 0 {
|
||||
return fmt.Errorf("cannot export query results in interactive mode")
|
||||
}
|
||||
// if share or snapshot args are set, there must be a query specified
|
||||
err := cmdconfig.ValidateSnapshotArgs(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,7 +21,11 @@ func executionTreeToSnapshot(e *controlexecute.ExecutionTree) (*dashboardtypes.S
|
||||
// get root benchmark/control
|
||||
switch root := e.Root.Children[0].(type) {
|
||||
case *controlexecute.ResultGroup:
|
||||
dashboardNode = root.GroupItem.(modconfig.DashboardLeafNode)
|
||||
var ok bool
|
||||
dashboardNode, ok = root.GroupItem.(modconfig.DashboardLeafNode)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid node found in control execution tree - cannot cast '%s' to a DashboardLeafNode", root.GroupItem.Name())
|
||||
}
|
||||
nodeType = "benchmark"
|
||||
case *controlexecute.ControlRun:
|
||||
dashboardNode = root.Control
|
||||
|
||||
@@ -3,6 +3,7 @@ package controlexecute
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
"log"
|
||||
"sort"
|
||||
"time"
|
||||
@@ -194,6 +195,10 @@ func (e *ExecutionTree) getExecutionRootFromArg(arg string) (modconfig.ModTreeIt
|
||||
if !found || !ok {
|
||||
return nil, fmt.Errorf("no resources found matching argument '%s'", arg)
|
||||
}
|
||||
// root item must be either a benchmark or a control
|
||||
if !helpers.StringSliceContains([]string{modconfig.BlockTypeControl, modconfig.BlockTypeBenchmark}, root.BlockType()) {
|
||||
return nil, fmt.Errorf("cannot execute '%s' using check, only controls and benchmarks may be run", resource.Name())
|
||||
}
|
||||
return root, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user