Skip to content

Commit d606155

Browse files
STAC-22844: Drop support for setting up a scope on a subject
1 parent 218df2f commit d606155

150 files changed

Lines changed: 18760 additions & 1345 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/rbac/flags.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@ const (
44
Subject = "subject"
55
Permission = "permission"
66
Resource = "resource"
7-
Scope = "scope"
87

98
SubjectUsage = "The handle of the subject of the permissions. If you're using LDAP, please use the usernameKey configured in StackState"
109
PermissionRevokeUsage = "The permission to revoke"
1110
PermissionGrantUsage = "The permission to grant"
1211
PermissionDescribeUsage = "Filter the permissions by permission name"
13-
ResourceDescribeUsage = "Filter the permissions by a resource identifier (e.g. system or a view name)"
14-
ResourceGrantUsage = "The resource to grant the permission to (e.g. \"system\" or a view name)"
15-
ResourceRevokeUsage = "The resource to revoke the permission to (e.g. \"system\" or a view name)"
16-
ScopeUsage = "The query in STQL that will be prepended to every topology element retrieved in StackState. " +
17-
"For example, if your scope is \"label = 'A'\", then all STQL executed in StackState" +
18-
" (e.g. Retrieving topology) will only return elements that have the label A"
12+
ResourceDescribeUsage = "Filter the permissions by a resource identifier (e.g. system, a resource name or tag)"
13+
ResourceGrantUsage = "The resource to grant the permission to (e.g. \"system\" or a resource name or tag)"
14+
ResourceRevokeUsage = "The resource to revoke the permission to (e.g. \"system\" or a resource name or tag)"
1915

20-
DefaultResource = "system"
21-
DefaultScope = "id = '-1'"
22-
DefaultSTQLVersion = "0.0.1"
16+
DefaultResource = "system"
2317
)

cmd/rbac/rbac_create_subject.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
type CreateSubjectArgs struct {
1111
Subject string
12-
Scope string
1312
}
1413

1514
func CreateSubjectCommand(deps *di.Deps) *cobra.Command {
@@ -24,8 +23,6 @@ func CreateSubjectCommand(deps *di.Deps) *cobra.Command {
2423
cmd.Flags().StringVar(&args.Subject, Subject, "", SubjectUsage)
2524
cmd.MarkFlagRequired(Subject) //nolint:errcheck
2625

27-
cmd.Flags().StringVar(&args.Scope, Scope, DefaultScope, ScopeUsage)
28-
2926
return cmd
3027
}
3128

@@ -36,9 +33,7 @@ func RunCreateSubjectCommand(args *CreateSubjectArgs) di.CmdWithApiFn {
3633
api *stackstate_api.APIClient,
3734
serverInfo *stackstate_api.ServerInfo,
3835
) common.CLIError {
39-
subject := stackstate_api.NewCreateSubject(args.Scope, DefaultSTQLVersion)
4036
resp, err := api.SubjectApi.CreateSubject(cli.Context, args.Subject).
41-
CreateSubject(*subject).
4237
Execute()
4338

4439
if err != nil {

cmd/rbac/rbac_create_subject_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/stackvista/stackstate-cli/generated/stackstate_api"
87
"github.com/stackvista/stackstate-cli/internal/di"
98
"github.com/stretchr/testify/assert"
109
)
@@ -24,10 +23,6 @@ func TestCreateSubjectJson(t *testing.T) {
2423
assert.Len(t, calls, 1)
2524
assert.Equal(t, SomeSubject, calls[0].Psubject)
2625

27-
expectedSubject := stackstate_api.NewCreateSubject(DefaultScope, DefaultSTQLVersion)
28-
29-
assert.Equal(t, expectedSubject, calls[0].PcreateSubject)
30-
3126
expectedJson := []map[string]interface{}{
3227
{
3328
"created-subject": SomeSubject,
@@ -41,16 +36,12 @@ func TestCreateSubject(t *testing.T) {
4136
cli := di.NewMockDeps(t)
4237
cmd := CreateSubjectCommand(&cli.Deps)
4338

44-
di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--subject", SomeOtherSubject, "--scope", SomeScope)
39+
di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--subject", SomeOtherSubject)
4540

4641
calls := *cli.MockClient.ApiMocks.SubjectApi.CreateSubjectCalls
4742
assert.Len(t, calls, 1)
4843
assert.Equal(t, SomeOtherSubject, calls[0].Psubject)
4944

50-
otherExpectedSubject := stackstate_api.NewCreateSubject(SomeScope, DefaultSTQLVersion)
51-
52-
assert.Equal(t, otherExpectedSubject, calls[0].PcreateSubject)
53-
5445
expectedStrings := []string{
5546
fmt.Sprintf("Created subject '%s'", SomeOtherSubject),
5647
}

cmd/rbac/rbac_describe_subjects.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,14 @@ func RunDescribeSubjectsCommand(args *DescribeSubjectsArgs) di.CmdWithApiFn {
4242

4343
if cli.IsJson() {
4444
cli.Printer.PrintJson(map[string]interface{}{
45-
"handle": subject.Handle,
46-
"scopeQuery": safeDeref(subject.ScopeQuery),
45+
"handle": subject.Handle,
4746
})
4847
} else {
4948
cli.Printer.Table(printer.TableData{
50-
Header: []string{"Subject", "Scope Query"},
49+
Header: []string{"Subject"},
5150
Data: [][]interface{}{
5251
{
5352
subject.Handle,
54-
safeDeref(subject.ScopeQuery),
5553
},
5654
},
5755
MissingTableDataMsg: printer.NotFoundMsg{Types: "matching subjects"},
@@ -72,11 +70,11 @@ func RunDescribeSubjectsCommand(args *DescribeSubjectsArgs) di.CmdWithApiFn {
7270
data := make([][]interface{}, 0)
7371

7472
for _, subject := range subjects {
75-
data = append(data, []interface{}{subject.Handle, safeDeref(subject.ScopeQuery)})
73+
data = append(data, []interface{}{subject.Handle})
7674
}
7775

7876
cli.Printer.Table(printer.TableData{
79-
Header: []string{"Subject", "Scope Query"},
77+
Header: []string{"Subject"},
8078
Data: data,
8179
MissingTableDataMsg: printer.NotFoundMsg{Types: "subjects"},
8280
})

cmd/rbac/rbac_describe_subjects_test.go

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@ import (
1212
var (
1313
SomeScopeVar = SomeScope
1414
SubjectConfig1 = stackstate_api.SubjectConfig{
15-
Handle: SomeSubject,
16-
ScopeQuery: &SomeScopeVar,
15+
Handle: SomeSubject,
1716
}
1817

1918
SomeOtherSubject = "handle"
20-
SomeOtherScope = "meaningOfLife = 23"
2119

2220
SubjectConfig2 = stackstate_api.SubjectConfig{
23-
Handle: SomeOtherSubject,
24-
ScopeQuery: &SomeOtherScope,
21+
Handle: SomeOtherSubject,
2522
}
2623

2724
SubjectConfig3 = stackstate_api.SubjectConfig{
28-
Handle: SubjectHandle,
29-
ScopeQuery: nil,
25+
Handle: SubjectHandle,
3026
}
3127
)
3228

@@ -47,11 +43,11 @@ func TestDescribeSubjectsTable(t *testing.T) {
4743

4844
expected := []printer.TableData{
4945
{
50-
Header: []string{"Subject", "Scope Query"},
46+
Header: []string{"Subject"},
5147
Data: [][]interface{}{
52-
{SubjectConfig1.Handle, *SubjectConfig1.ScopeQuery},
53-
{SubjectConfig2.Handle, *SubjectConfig2.ScopeQuery},
54-
{SubjectConfig3.Handle, ""},
48+
{SubjectConfig1.Handle},
49+
{SubjectConfig2.Handle},
50+
{SubjectConfig3.Handle},
5551
},
5652
MissingTableDataMsg: printer.NotFoundMsg{Types: "subjects"},
5753
},
@@ -100,9 +96,9 @@ func TestDescribeSubjectsTableWithFilter(t *testing.T) {
10096

10197
expected := []printer.TableData{
10298
{
103-
Header: []string{"Subject", "Scope Query"},
99+
Header: []string{"Subject"},
104100
Data: [][]interface{}{
105-
{SubjectConfig1.Handle, *SubjectConfig1.ScopeQuery},
101+
{SubjectConfig1.Handle},
106102
},
107103
MissingTableDataMsg: printer.NotFoundMsg{Types: "matching subjects"},
108104
},
@@ -130,12 +126,10 @@ func TestDescribeSubjectsJsonWithFilter(t *testing.T) {
130126

131127
expectedJson := []map[string]interface{}{
132128
{
133-
"handle": SubjectConfig1.Handle,
134-
"scopeQuery": *SubjectConfig1.ScopeQuery,
129+
"handle": SubjectConfig1.Handle,
135130
},
136131
{
137-
"handle": SubjectConfig3.Handle,
138-
"scopeQuery": "",
132+
"handle": SubjectConfig3.Handle,
139133
},
140134
}
141135

generated/stackstate_api/.openapi-generator/FILES

Lines changed: 108 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ api_agent_registrations.go
88
api_api_token.go
99
api_authorize_ingestion_api_key.go
1010
api_component.go
11+
api_dashboards.go
1112
api_dummy.go
1213
api_event.go
1314
api_export.go
@@ -84,7 +85,23 @@ docs/ComponentHighlightMetricSectionAllOf.md
8485
docs/ComponentNotFoundError.md
8586
docs/ComponentQuery.md
8687
docs/ComponentViewArguments.md
87-
docs/CreateSubject.md
88+
docs/DashboardAuthorizationError.md
89+
docs/DashboardClientErrors.md
90+
docs/DashboardCloneSchema.md
91+
docs/DashboardInvalidIdentifierError.md
92+
docs/DashboardList.md
93+
docs/DashboardNotFoundError.md
94+
docs/DashboardPatchSchema.md
95+
docs/DashboardReadBaseSchema.md
96+
docs/DashboardReadFullSchema.md
97+
docs/DashboardReadFullSchemaAllOf.md
98+
docs/DashboardReadMetadataSchema.md
99+
docs/DashboardReadMetadataSchemaAllOf.md
100+
docs/DashboardReadSchema.md
101+
docs/DashboardScope.md
102+
docs/DashboardValidationError.md
103+
docs/DashboardWriteSchema.md
104+
docs/DashboardsApi.md
88105
docs/DataUnavailable.md
89106
docs/DependencyDirection.md
90107
docs/DummyApi.md
@@ -278,10 +295,42 @@ docs/OpsgenieChannelRefId.md
278295
docs/OpsgenieChannelWriteSchema.md
279296
docs/OpsgenieNotificationChannel.md
280297
docs/OpsgenieNotificationChannelAllOf.md
298+
docs/OpsgeniePriority.md
299+
docs/OpsgenieRegion.md
281300
docs/OpsgenieResponder.md
301+
docs/OpsgenieResponderType.md
282302
docs/PermissionDescription.md
283303
docs/Permissions.md
284304
docs/PermissionsApi.md
305+
docs/PersesDashboard.md
306+
docs/PersesDashboardDisplaySpec.md
307+
docs/PersesDashboardSpec.md
308+
docs/PersesDatasourceSpec.md
309+
docs/PersesGridItem.md
310+
docs/PersesGridLayoutCollapse.md
311+
docs/PersesGridLayoutDisplay.md
312+
docs/PersesJSONRef.md
313+
docs/PersesLayout.md
314+
docs/PersesLayoutKind.md
315+
docs/PersesLayoutSpec.md
316+
docs/PersesLink.md
317+
docs/PersesListVariable.md
318+
docs/PersesListVariableDefaultSingleValue.md
319+
docs/PersesListVariableDefaultSliceValues.md
320+
docs/PersesListVariableDefaultValue.md
321+
docs/PersesListVariableSpec.md
322+
docs/PersesPanel.md
323+
docs/PersesPanelDisplay.md
324+
docs/PersesPanelSpec.md
325+
docs/PersesPlugin.md
326+
docs/PersesProjectMetadata.md
327+
docs/PersesQuery.md
328+
docs/PersesQuerySpec.md
329+
docs/PersesTextVariable.md
330+
docs/PersesTextVariableSpec.md
331+
docs/PersesVariableDisplaySpec.md
332+
docs/PersesVariableSort.md
333+
docs/PersesVariableTypes.md
285334
docs/ProblemApi.md
286335
docs/ProblemNotFound.md
287336
docs/PromData.md
@@ -332,6 +381,7 @@ docs/SpanFilter.md
332381
docs/SpanKind.md
333382
docs/SpanLink.md
334383
docs/SpanParentType.md
384+
docs/SpanResponse.md
335385
docs/SpanSortDirection.md
336386
docs/SpanSortField.md
337387
docs/SpanSortOption.md
@@ -369,6 +419,7 @@ docs/TimelineSummary.md
369419
docs/TimelineSummaryError.md
370420
docs/TimelineSummaryEventBucket.md
371421
docs/TimelineSummaryHealthChange.md
422+
docs/TimelineSummaryOverflow.md
372423
docs/TimelineSummaryRequest.md
373424
docs/TimelineSummaryRequestArguments.md
374425
docs/TooManyActiveQueries.md
@@ -397,9 +448,10 @@ docs/TraceApiSpanNotFound.md
397448
docs/TraceApiSpansBadRequest.md
398449
docs/TraceApiTraceNotFound.md
399450
docs/TraceFilter.md
400-
docs/TraceIdentifier.md
401451
docs/TraceQuery.md
402-
docs/Traces.md
452+
docs/TraceQueryMatch.md
453+
docs/TraceQueryMatchAllOf.md
454+
docs/TraceQueryResponse.md
403455
docs/TracesApi.md
404456
docs/UnlicensedSubscription.md
405457
docs/UnmatchedCheckState.md
@@ -458,7 +510,22 @@ model_component_highlight_metric_section_all_of.go
458510
model_component_not_found_error.go
459511
model_component_query.go
460512
model_component_view_arguments.go
461-
model_create_subject.go
513+
model_dashboard_authorization_error.go
514+
model_dashboard_client_errors.go
515+
model_dashboard_clone_schema.go
516+
model_dashboard_invalid_identifier_error.go
517+
model_dashboard_list.go
518+
model_dashboard_not_found_error.go
519+
model_dashboard_patch_schema.go
520+
model_dashboard_read_base_schema.go
521+
model_dashboard_read_full_schema.go
522+
model_dashboard_read_full_schema_all_of.go
523+
model_dashboard_read_metadata_schema.go
524+
model_dashboard_read_metadata_schema_all_of.go
525+
model_dashboard_read_schema.go
526+
model_dashboard_scope.go
527+
model_dashboard_validation_error.go
528+
model_dashboard_write_schema.go
462529
model_data_unavailable.go
463530
model_dependency_direction.go
464531
model_duration_histogram.go
@@ -638,9 +705,41 @@ model_opsgenie_channel_ref_id.go
638705
model_opsgenie_channel_write_schema.go
639706
model_opsgenie_notification_channel.go
640707
model_opsgenie_notification_channel_all_of.go
708+
model_opsgenie_priority.go
709+
model_opsgenie_region.go
641710
model_opsgenie_responder.go
711+
model_opsgenie_responder_type.go
642712
model_permission_description.go
643713
model_permissions.go
714+
model_perses_dashboard.go
715+
model_perses_dashboard_display_spec.go
716+
model_perses_dashboard_spec.go
717+
model_perses_datasource_spec.go
718+
model_perses_grid_item.go
719+
model_perses_grid_layout_collapse.go
720+
model_perses_grid_layout_display.go
721+
model_perses_json_ref.go
722+
model_perses_layout.go
723+
model_perses_layout_kind.go
724+
model_perses_layout_spec.go
725+
model_perses_link.go
726+
model_perses_list_variable.go
727+
model_perses_list_variable_default_single_value.go
728+
model_perses_list_variable_default_slice_values.go
729+
model_perses_list_variable_default_value.go
730+
model_perses_list_variable_spec.go
731+
model_perses_panel.go
732+
model_perses_panel_display.go
733+
model_perses_panel_spec.go
734+
model_perses_plugin.go
735+
model_perses_project_metadata.go
736+
model_perses_query.go
737+
model_perses_query_spec.go
738+
model_perses_text_variable.go
739+
model_perses_text_variable_spec.go
740+
model_perses_variable_display_spec.go
741+
model_perses_variable_sort.go
742+
model_perses_variable_types.go
644743
model_problem_not_found.go
645744
model_prom_data.go
646745
model_prom_data_result.go
@@ -687,6 +786,7 @@ model_span_filter.go
687786
model_span_kind.go
688787
model_span_link.go
689788
model_span_parent_type.go
789+
model_span_response.go
690790
model_span_sort_direction.go
691791
model_span_sort_field.go
692792
model_span_sort_option.go
@@ -719,6 +819,7 @@ model_timeline_summary.go
719819
model_timeline_summary_error.go
720820
model_timeline_summary_event_bucket.go
721821
model_timeline_summary_health_change.go
822+
model_timeline_summary_overflow.go
722823
model_timeline_summary_request.go
723824
model_timeline_summary_request_arguments.go
724825
model_too_many_active_queries.go
@@ -745,9 +846,10 @@ model_trace_api_span_not_found.go
745846
model_trace_api_spans_bad_request.go
746847
model_trace_api_trace_not_found.go
747848
model_trace_filter.go
748-
model_trace_identifier.go
749849
model_trace_query.go
750-
model_traces.go
850+
model_trace_query_match.go
851+
model_trace_query_match_all_of.go
852+
model_trace_query_response.go
751853
model_unlicensed_subscription.go
752854
model_unmatched_check_state.go
753855
model_user_name_mismatch_error.go

0 commit comments

Comments
 (0)