Skip to content

Commit 305f88f

Browse files
STAC-22990: Support showing the source of an rbac subject
1 parent 9f313fe commit 305f88f

File tree

11 files changed

+214
-16
lines changed

11 files changed

+214
-16
lines changed

cmd/rbac/rbac_describe_subjects.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ func RunDescribeSubjectsCommand(args *DescribeSubjectsArgs) di.CmdWithApiFn {
4343
if cli.IsJson() {
4444
cli.Printer.PrintJson(map[string]interface{}{
4545
"handle": subject.Handle,
46+
"source": subject.Source,
4647
})
4748
} else {
4849
cli.Printer.Table(printer.TableData{
49-
Header: []string{"Subject"},
50+
Header: []string{"Subject", "Source"},
5051
Data: [][]interface{}{
5152
{
5253
subject.Handle,
54+
subject.Source,
5355
},
5456
},
5557
MissingTableDataMsg: printer.NotFoundMsg{Types: "matching subjects"},
@@ -70,11 +72,11 @@ func RunDescribeSubjectsCommand(args *DescribeSubjectsArgs) di.CmdWithApiFn {
7072
data := make([][]interface{}, 0)
7173

7274
for _, subject := range subjects {
73-
data = append(data, []interface{}{subject.Handle})
75+
data = append(data, []interface{}{subject.Handle, subject.Source})
7476
}
7577

7678
cli.Printer.Table(printer.TableData{
77-
Header: []string{"Subject"},
79+
Header: []string{"Subject", "Source"},
7880
Data: data,
7981
MissingTableDataMsg: printer.NotFoundMsg{Types: "subjects"},
8082
})

cmd/rbac/rbac_describe_subjects_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ var (
1313
SomeScopeVar = SomeScope
1414
SubjectConfig1 = stackstate_api.SubjectConfig{
1515
Handle: SomeSubject,
16+
Source: stackstate_api.SUBJECTSOURCE_OBSERVABILITY,
1617
}
1718

1819
SomeOtherSubject = "handle"
1920

2021
SubjectConfig2 = stackstate_api.SubjectConfig{
2122
Handle: SomeOtherSubject,
23+
Source: stackstate_api.SUBJECTSOURCE_OBSERVABILITY,
2224
}
2325

2426
SubjectConfig3 = stackstate_api.SubjectConfig{
2527
Handle: SubjectHandle,
28+
Source: stackstate_api.SUBJECTSOURCE_OBSERVABILITY,
2629
}
2730
)
2831

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

4447
expected := []printer.TableData{
4548
{
46-
Header: []string{"Subject"},
49+
Header: []string{"Subject", "Source"},
4750
Data: [][]interface{}{
48-
{SubjectConfig1.Handle},
49-
{SubjectConfig2.Handle},
50-
{SubjectConfig3.Handle},
51+
{SubjectConfig1.Handle, SubjectConfig1.Source},
52+
{SubjectConfig2.Handle, SubjectConfig1.Source},
53+
{SubjectConfig3.Handle, SubjectConfig1.Source},
5154
},
5255
MissingTableDataMsg: printer.NotFoundMsg{Types: "subjects"},
5356
},
@@ -96,9 +99,9 @@ func TestDescribeSubjectsTableWithFilter(t *testing.T) {
9699

97100
expected := []printer.TableData{
98101
{
99-
Header: []string{"Subject"},
102+
Header: []string{"Subject", "Source"},
100103
Data: [][]interface{}{
101-
{SubjectConfig1.Handle},
104+
{SubjectConfig1.Handle, SubjectConfig1.Source},
102105
},
103106
MissingTableDataMsg: printer.NotFoundMsg{Types: "matching subjects"},
104107
},
@@ -127,9 +130,11 @@ func TestDescribeSubjectsJsonWithFilter(t *testing.T) {
127130
expectedJson := []map[string]interface{}{
128131
{
129132
"handle": SubjectConfig1.Handle,
133+
"source": SubjectConfig3.Source,
130134
},
131135
{
132136
"handle": SubjectConfig3.Handle,
137+
"source": SubjectConfig3.Source,
133138
},
134139
}
135140

generated/stackstate_api/.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ docs/SubStreamList.md
393393
docs/SubStreamListItem.md
394394
docs/SubjectApi.md
395395
docs/SubjectConfig.md
396+
docs/SubjectSource.md
396397
docs/Subscription.md
397398
docs/SubscriptionApi.md
398399
docs/SubscriptionState.md
@@ -791,6 +792,7 @@ model_string_items_with_total.go
791792
model_sub_stream_list.go
792793
model_sub_stream_list_item.go
793794
model_subject_config.go
795+
model_subject_source.go
794796
model_subscription.go
795797
model_subscription_state.go
796798
model_suggestions.go

generated/stackstate_api/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ Class | Method | HTTP request | Description
567567
- [SubStreamList](docs/SubStreamList.md)
568568
- [SubStreamListItem](docs/SubStreamListItem.md)
569569
- [SubjectConfig](docs/SubjectConfig.md)
570+
- [SubjectSource](docs/SubjectSource.md)
570571
- [Subscription](docs/Subscription.md)
571572
- [SubscriptionState](docs/SubscriptionState.md)
572573
- [Suggestions](docs/Suggestions.md)

generated/stackstate_api/api/openapi.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3815,7 +3815,7 @@ paths:
38153815
tags:
38163816
- subject
38173817
get:
3818-
description: Describe a subject and its scope
3818+
description: Describe a subject
38193819
operationId: getSubject
38203820
parameters:
38213821
- in: path
@@ -10690,12 +10690,22 @@ components:
1069010690
SubjectConfig:
1069110691
example:
1069210692
handle: handle
10693+
source: null
1069310694
properties:
1069410695
handle:
1069510696
type: string
10697+
source:
10698+
$ref: '#/components/schemas/SubjectSource'
1069610699
required:
1069710700
- handle
10701+
- source
1069810702
type: object
10703+
SubjectSource:
10704+
enum:
10705+
- Static
10706+
- Observability
10707+
- Kubernetes
10708+
type: string
1069910709
CreateSubject:
1070010710
example:
1070110711
query: query

generated/stackstate_api/api_subject.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/stackstate_api/docs/SubjectConfig.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Handle** | **string** | |
8+
**Source** | [**SubjectSource**](SubjectSource.md) | |
89

910
## Methods
1011

1112
### NewSubjectConfig
1213

13-
`func NewSubjectConfig(handle string, ) *SubjectConfig`
14+
`func NewSubjectConfig(handle string, source SubjectSource, ) *SubjectConfig`
1415

1516
NewSubjectConfig instantiates a new SubjectConfig object
1617
This constructor will assign default values to properties that have it defined,
@@ -45,6 +46,26 @@ and a boolean to check if the value has been set.
4546
SetHandle sets Handle field to given value.
4647

4748

49+
### GetSource
50+
51+
`func (o *SubjectConfig) GetSource() SubjectSource`
52+
53+
GetSource returns the Source field if non-nil, zero value otherwise.
54+
55+
### GetSourceOk
56+
57+
`func (o *SubjectConfig) GetSourceOk() (*SubjectSource, bool)`
58+
59+
GetSourceOk returns a tuple with the Source field if it's non-nil, zero value otherwise
60+
and a boolean to check if the value has been set.
61+
62+
### SetSource
63+
64+
`func (o *SubjectConfig) SetSource(v SubjectSource)`
65+
66+
SetSource sets Source field to given value.
67+
68+
4869

4970
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
5071

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SubjectSource
2+
3+
## Enum
4+
5+
6+
* `STATIC` (value: `"Static"`)
7+
8+
* `OBSERVABILITY` (value: `"Observability"`)
9+
10+
* `KUBERNETES` (value: `"Kubernetes"`)
11+
12+
13+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
14+
15+

generated/stackstate_api/model_subject_config.go

Lines changed: 31 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/stackstate_api/model_subject_source.go

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)