Skip to content

Commit a3a9f8f

Browse files
committed
Remove stql option
Signed-off-by: Jeroen van Erp <jeroen.vanerp@suse.com>
1 parent 8a5801a commit a3a9f8f

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

cmd/topology/topology_state.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/spf13/cobra"
88
"github.com/stackvista/stackstate-cli/generated/stackstate_api"
9-
stscobra "github.com/stackvista/stackstate-cli/internal/cobra"
109
"github.com/stackvista/stackstate-cli/internal/common"
1110
"github.com/stackvista/stackstate-cli/internal/di"
1211
"github.com/stackvista/stackstate-cli/internal/printer"
@@ -17,7 +16,6 @@ type StateArgs struct {
1716
Tags []string
1817
Identifiers []string
1918
Limit int
20-
STQL string
2119
}
2220

2321
func StateCommand(cli *di.Deps) *cobra.Command {
@@ -45,10 +43,7 @@ sts topology state --type "otel service instance" --identifier "urn:opentelemetr
4543
sts topology state --type "otel service instance" --limit 10
4644
4745
# show state and display as JSON
48-
sts topology state --type "otel service instance" -o json
49-
50-
# show state using a custom STQL query
51-
sts topology state --stql 'type = "otel service instance" AND healthState = "CRITICAL"'`,
46+
sts topology state --type "otel service instance" -o json`,
5247
RunE: cli.CmdRunEWithApi(func(cmd *cobra.Command, cli *di.Deps, api *stackstate_api.APIClient, serverInfo *stackstate_api.ServerInfo) common.CLIError {
5348
return RunStateCommand(cmd, cli, api, serverInfo, args)
5449
}),
@@ -58,8 +53,6 @@ sts topology state --stql 'type = "otel service instance" AND healthState = "CRI
5853
cmd.Flags().StringSliceVar(&args.Tags, "tag", []string{}, "Filter by tags in format 'tag-name:tag-value' (multiple allowed, ANDed together)")
5954
cmd.Flags().StringSliceVar(&args.Identifiers, "identifier", []string{}, "Filter by component identifiers (multiple allowed, ANDed together)")
6055
cmd.Flags().IntVar(&args.Limit, "limit", 0, "Maximum number of components to output (must be positive)")
61-
cmd.Flags().StringVar(&args.STQL, "stql", "", "STQL query to select components (mutually exclusive with --type, --tag, --identifier)")
62-
stscobra.MarkMutexFlags(cmd, []string{"type", "stql"}, "query", true)
6356

6457
return cmd
6558
}
@@ -75,12 +68,7 @@ func RunStateCommand(
7568
return common.NewExecutionError(fmt.Errorf("limit must be a positive number, got: %d", args.Limit))
7669
}
7770

78-
var query string
79-
if args.STQL != "" {
80-
query = args.STQL
81-
} else {
82-
query = buildSTQLQuery(args.ComponentType, args.Tags, args.Identifiers)
83-
}
71+
query := buildSTQLQuery(args.ComponentType, args.Tags, args.Identifiers)
8472

8573
metadata := stackstate_api.NewQueryMetadata(
8674
false,

cmd/topology/topology_state_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -220,29 +220,3 @@ func TestTopologyStateLimit(t *testing.T) {
220220
table := tableCalls[0]
221221
assert.Len(t, table.Data, 2) // Only 2 components due to limit
222222
}
223-
224-
func TestTopologyStateWithSTQL(t *testing.T) {
225-
cli, cmd := setStateCmd(t)
226-
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse()
227-
228-
di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--stql", `type = "custom" AND healthState = "CRITICAL"`)
229-
230-
calls := *cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotCalls
231-
assert.Len(t, calls, 1)
232-
233-
// Verify the custom STQL query is used directly
234-
call := calls[0]
235-
request := call.PviewSnapshotRequest
236-
assert.Equal(t, `type = "custom" AND healthState = "CRITICAL"`, request.Query)
237-
}
238-
239-
func TestTopologyStateSTQLMutuallyExclusiveWithType(t *testing.T) {
240-
cli, cmd := setStateCmd(t)
241-
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse()
242-
243-
_, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--type", "test type", "--stql", "type = \"test\"")
244-
245-
assert.Error(t, err)
246-
assert.Contains(t, err.Error(), "type")
247-
assert.Contains(t, err.Error(), "stql")
248-
}

0 commit comments

Comments
 (0)