Skip to content

Commit d33eaf2

Browse files
Merge pull request #97 from StackVista/stac-22844
STAC-22844: Drop support for setting up a scope on a subject
2 parents 218df2f + 7ee7948 commit d33eaf2

File tree

152 files changed

+18793
-1161
lines changed

Some content is hidden

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

152 files changed

+18793
-1161
lines changed

cmd/rbac/flags.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ const (
1717
"For example, if your scope is \"label = 'A'\", then all STQL executed in StackState" +
1818
" (e.g. Retrieving topology) will only return elements that have the label A"
1919

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

cmd/rbac/rbac_create_subject.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:dupl
12
package rbac
23

34
import (
@@ -24,7 +25,7 @@ func CreateSubjectCommand(deps *di.Deps) *cobra.Command {
2425
cmd.Flags().StringVar(&args.Subject, Subject, "", SubjectUsage)
2526
cmd.MarkFlagRequired(Subject) //nolint:errcheck
2627

27-
cmd.Flags().StringVar(&args.Scope, Scope, DefaultScope, ScopeUsage)
28+
cmd.Flags().StringVar(&args.Scope, Scope, "", ScopeUsage)
2829

2930
return cmd
3031
}
@@ -36,7 +37,11 @@ func RunCreateSubjectCommand(args *CreateSubjectArgs) di.CmdWithApiFn {
3637
api *stackstate_api.APIClient,
3738
serverInfo *stackstate_api.ServerInfo,
3839
) common.CLIError {
39-
subject := stackstate_api.NewCreateSubject(args.Scope, DefaultSTQLVersion)
40+
subject := stackstate_api.NewCreateSubject()
41+
if args.Scope != "" {
42+
subject.SetQuery(args.Scope)
43+
}
44+
4045
resp, err := api.SubjectApi.CreateSubject(cli.Context, args.Subject).
4146
CreateSubject(*subject).
4247
Execute()

cmd/rbac/rbac_create_subject_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ func TestCreateSubjectJson(t *testing.T) {
2424
assert.Len(t, calls, 1)
2525
assert.Equal(t, SomeSubject, calls[0].Psubject)
2626

27-
expectedSubject := stackstate_api.NewCreateSubject(DefaultScope, DefaultSTQLVersion)
28-
27+
expectedSubject := stackstate_api.NewCreateSubject()
2928
assert.Equal(t, expectedSubject, calls[0].PcreateSubject)
3029

3130
expectedJson := []map[string]interface{}{
@@ -47,8 +46,8 @@ func TestCreateSubject(t *testing.T) {
4746
assert.Len(t, calls, 1)
4847
assert.Equal(t, SomeOtherSubject, calls[0].Psubject)
4948

50-
otherExpectedSubject := stackstate_api.NewCreateSubject(SomeScope, DefaultSTQLVersion)
51-
49+
otherExpectedSubject := stackstate_api.NewCreateSubject()
50+
otherExpectedSubject.SetQuery(SomeScope)
5251
assert.Equal(t, otherExpectedSubject, calls[0].PcreateSubject)
5352

5453
expectedStrings := []string{

cmd/rbac/rbac_delete_subject.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:dupl
12
package rbac
23

34
import (

cmd/rbac/rbac_describe_subjects.go

Lines changed: 4 additions & 13 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
})
@@ -85,10 +83,3 @@ func RunDescribeSubjectsCommand(args *DescribeSubjectsArgs) di.CmdWithApiFn {
8583
return nil
8684
}
8785
}
88-
89-
func safeDeref(text *string) string {
90-
if text == nil {
91-
return ""
92-
}
93-
return *text
94-
}

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

cmd/rbac/rbac_revoke.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func RunRevokePermissionsCommand(args *RevokePermissionsArgs) di.CmdWithApiFn {
4949
return common.NewResponseError(revokeErr, revokeResp)
5050
}
5151

52-
description, descrResp, descrErr := describePermissions(cli, api, args.Subject, args.Permission, args.Resource).Execute()
52+
description, descrResp, descrErr := describePermissions(cli, api, args.Subject, args.Permission, "").Execute()
5353

5454
if descrErr != nil {
5555
return common.NewResponseError(descrErr, descrResp)

cmd/rbac/rbac_revoke_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func TestRevokePermissions(t *testing.T) {
2626
assert.Len(t, describeCalls, 1)
2727
assert.Equal(t, SomeSubject, describeCalls[0].Psubject)
2828
assert.Equal(t, SomePermission, *describeCalls[0].Ppermission)
29-
assert.Equal(t, "system", *describeCalls[0].Presource)
3029

3130
di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--subject", SomeSubject, "--permission", SomePermission, "--resource", SomeResource)
3231

@@ -40,7 +39,6 @@ func TestRevokePermissions(t *testing.T) {
4039
assert.Len(t, describeCalls, 2)
4140
assert.Equal(t, SomeSubject, describeCalls[1].Psubject)
4241
assert.Equal(t, SomePermission, *describeCalls[1].Ppermission)
43-
assert.Equal(t, SomeResource, *describeCalls[1].Presource)
4442

4543
expectedResult := []printer.TableData{
4644
ExpectedTable,

generated/stackstate_api/.openapi-generator/FILES

Lines changed: 108 additions & 4 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
@@ -85,6 +86,23 @@ docs/ComponentNotFoundError.md
8586
docs/ComponentQuery.md
8687
docs/ComponentViewArguments.md
8788
docs/CreateSubject.md
89+
docs/DashboardAuthorizationError.md
90+
docs/DashboardClientErrors.md
91+
docs/DashboardCloneSchema.md
92+
docs/DashboardInvalidIdentifierError.md
93+
docs/DashboardList.md
94+
docs/DashboardNotFoundError.md
95+
docs/DashboardPatchSchema.md
96+
docs/DashboardReadBaseSchema.md
97+
docs/DashboardReadFullSchema.md
98+
docs/DashboardReadFullSchemaAllOf.md
99+
docs/DashboardReadMetadataSchema.md
100+
docs/DashboardReadMetadataSchemaAllOf.md
101+
docs/DashboardReadSchema.md
102+
docs/DashboardScope.md
103+
docs/DashboardValidationError.md
104+
docs/DashboardWriteSchema.md
105+
docs/DashboardsApi.md
88106
docs/DataUnavailable.md
89107
docs/DependencyDirection.md
90108
docs/DummyApi.md
@@ -278,10 +296,42 @@ docs/OpsgenieChannelRefId.md
278296
docs/OpsgenieChannelWriteSchema.md
279297
docs/OpsgenieNotificationChannel.md
280298
docs/OpsgenieNotificationChannelAllOf.md
299+
docs/OpsgeniePriority.md
300+
docs/OpsgenieRegion.md
281301
docs/OpsgenieResponder.md
302+
docs/OpsgenieResponderType.md
282303
docs/PermissionDescription.md
283304
docs/Permissions.md
284305
docs/PermissionsApi.md
306+
docs/PersesDashboard.md
307+
docs/PersesDashboardDisplaySpec.md
308+
docs/PersesDashboardSpec.md
309+
docs/PersesDatasourceSpec.md
310+
docs/PersesGridItem.md
311+
docs/PersesGridLayoutCollapse.md
312+
docs/PersesGridLayoutDisplay.md
313+
docs/PersesJSONRef.md
314+
docs/PersesLayout.md
315+
docs/PersesLayoutKind.md
316+
docs/PersesLayoutSpec.md
317+
docs/PersesLink.md
318+
docs/PersesListVariable.md
319+
docs/PersesListVariableDefaultSingleValue.md
320+
docs/PersesListVariableDefaultSliceValues.md
321+
docs/PersesListVariableDefaultValue.md
322+
docs/PersesListVariableSpec.md
323+
docs/PersesPanel.md
324+
docs/PersesPanelDisplay.md
325+
docs/PersesPanelSpec.md
326+
docs/PersesPlugin.md
327+
docs/PersesProjectMetadata.md
328+
docs/PersesQuery.md
329+
docs/PersesQuerySpec.md
330+
docs/PersesTextVariable.md
331+
docs/PersesTextVariableSpec.md
332+
docs/PersesVariableDisplaySpec.md
333+
docs/PersesVariableSort.md
334+
docs/PersesVariableTypes.md
285335
docs/ProblemApi.md
286336
docs/ProblemNotFound.md
287337
docs/PromData.md
@@ -332,6 +382,7 @@ docs/SpanFilter.md
332382
docs/SpanKind.md
333383
docs/SpanLink.md
334384
docs/SpanParentType.md
385+
docs/SpanResponse.md
335386
docs/SpanSortDirection.md
336387
docs/SpanSortField.md
337388
docs/SpanSortOption.md
@@ -369,6 +420,7 @@ docs/TimelineSummary.md
369420
docs/TimelineSummaryError.md
370421
docs/TimelineSummaryEventBucket.md
371422
docs/TimelineSummaryHealthChange.md
423+
docs/TimelineSummaryOverflow.md
372424
docs/TimelineSummaryRequest.md
373425
docs/TimelineSummaryRequestArguments.md
374426
docs/TooManyActiveQueries.md
@@ -397,9 +449,10 @@ docs/TraceApiSpanNotFound.md
397449
docs/TraceApiSpansBadRequest.md
398450
docs/TraceApiTraceNotFound.md
399451
docs/TraceFilter.md
400-
docs/TraceIdentifier.md
401452
docs/TraceQuery.md
402-
docs/Traces.md
453+
docs/TraceQueryMatch.md
454+
docs/TraceQueryMatchAllOf.md
455+
docs/TraceQueryResponse.md
403456
docs/TracesApi.md
404457
docs/UnlicensedSubscription.md
405458
docs/UnmatchedCheckState.md
@@ -459,6 +512,22 @@ model_component_not_found_error.go
459512
model_component_query.go
460513
model_component_view_arguments.go
461514
model_create_subject.go
515+
model_dashboard_authorization_error.go
516+
model_dashboard_client_errors.go
517+
model_dashboard_clone_schema.go
518+
model_dashboard_invalid_identifier_error.go
519+
model_dashboard_list.go
520+
model_dashboard_not_found_error.go
521+
model_dashboard_patch_schema.go
522+
model_dashboard_read_base_schema.go
523+
model_dashboard_read_full_schema.go
524+
model_dashboard_read_full_schema_all_of.go
525+
model_dashboard_read_metadata_schema.go
526+
model_dashboard_read_metadata_schema_all_of.go
527+
model_dashboard_read_schema.go
528+
model_dashboard_scope.go
529+
model_dashboard_validation_error.go
530+
model_dashboard_write_schema.go
462531
model_data_unavailable.go
463532
model_dependency_direction.go
464533
model_duration_histogram.go
@@ -638,9 +707,41 @@ model_opsgenie_channel_ref_id.go
638707
model_opsgenie_channel_write_schema.go
639708
model_opsgenie_notification_channel.go
640709
model_opsgenie_notification_channel_all_of.go
710+
model_opsgenie_priority.go
711+
model_opsgenie_region.go
641712
model_opsgenie_responder.go
713+
model_opsgenie_responder_type.go
642714
model_permission_description.go
643715
model_permissions.go
716+
model_perses_dashboard.go
717+
model_perses_dashboard_display_spec.go
718+
model_perses_dashboard_spec.go
719+
model_perses_datasource_spec.go
720+
model_perses_grid_item.go
721+
model_perses_grid_layout_collapse.go
722+
model_perses_grid_layout_display.go
723+
model_perses_json_ref.go
724+
model_perses_layout.go
725+
model_perses_layout_kind.go
726+
model_perses_layout_spec.go
727+
model_perses_link.go
728+
model_perses_list_variable.go
729+
model_perses_list_variable_default_single_value.go
730+
model_perses_list_variable_default_slice_values.go
731+
model_perses_list_variable_default_value.go
732+
model_perses_list_variable_spec.go
733+
model_perses_panel.go
734+
model_perses_panel_display.go
735+
model_perses_panel_spec.go
736+
model_perses_plugin.go
737+
model_perses_project_metadata.go
738+
model_perses_query.go
739+
model_perses_query_spec.go
740+
model_perses_text_variable.go
741+
model_perses_text_variable_spec.go
742+
model_perses_variable_display_spec.go
743+
model_perses_variable_sort.go
744+
model_perses_variable_types.go
644745
model_problem_not_found.go
645746
model_prom_data.go
646747
model_prom_data_result.go
@@ -687,6 +788,7 @@ model_span_filter.go
687788
model_span_kind.go
688789
model_span_link.go
689790
model_span_parent_type.go
791+
model_span_response.go
690792
model_span_sort_direction.go
691793
model_span_sort_field.go
692794
model_span_sort_option.go
@@ -719,6 +821,7 @@ model_timeline_summary.go
719821
model_timeline_summary_error.go
720822
model_timeline_summary_event_bucket.go
721823
model_timeline_summary_health_change.go
824+
model_timeline_summary_overflow.go
722825
model_timeline_summary_request.go
723826
model_timeline_summary_request_arguments.go
724827
model_too_many_active_queries.go
@@ -745,9 +848,10 @@ model_trace_api_span_not_found.go
745848
model_trace_api_spans_bad_request.go
746849
model_trace_api_trace_not_found.go
747850
model_trace_filter.go
748-
model_trace_identifier.go
749851
model_trace_query.go
750-
model_traces.go
852+
model_trace_query_match.go
853+
model_trace_query_match_all_of.go
854+
model_trace_query_response.go
751855
model_unlicensed_subscription.go
752856
model_unmatched_check_state.go
753857
model_user_name_mismatch_error.go

0 commit comments

Comments
 (0)