Skip to content

Commit df0bcba

Browse files
authored
Addition of json omitempty for ACLToken name field and its related structs (#23484)
* Addition of json omitempty for ACLToken name field * Fix testdata files
1 parent 329127d commit df0bcba

8 files changed

Lines changed: 4 additions & 10 deletions

File tree

agent/structs/acl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ func (t *ACLToken) EstimateSize() int {
577577
type ACLTokens []*ACLToken
578578

579579
type ACLTokenListStub struct {
580-
Name string
580+
Name string `json:",omitempty"`
581581
AccessorID string
582582
SecretID string
583583
Description string
@@ -1165,7 +1165,7 @@ func (rules ACLBindingRules) Sort() {
11651165

11661166
// Note: this is a subset of ACLAuthMethod's fields
11671167
type ACLAuthMethodListStub struct {
1168-
Name string
1168+
Name string `json:",omitempty"`
11691169
Type string
11701170
DisplayName string `json:",omitempty"`
11711171
Description string `json:",omitempty"`

api/acl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type ACLTokenRoleLink = ACLLink
4141
type ACLToken struct {
4242
CreateIndex uint64
4343
ModifyIndex uint64
44-
Name string
44+
Name string `json:",omitempty"`
4545
AccessorID string
4646
SecretID string
4747
Description string
@@ -89,7 +89,7 @@ type ACLTokenExpanded struct {
8989
}
9090

9191
type ACLTokenListEntry struct {
92-
Name string
92+
Name string `json:",omitempty"`
9393
CreateIndex uint64
9494
ModifyIndex uint64
9595
AccessorID string

command/acl/token/testdata/FormatToken/basic.json.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"CreateIndex": 42,
33
"ModifyIndex": 100,
4-
"Name": "",
54
"AccessorID": "fbd2447f-7479-4329-ad13-b021d74f86ba",
65
"SecretID": "869c6e91-4de9-4dab-b56e-87548435f9c6",
76
"Description": "test token",

command/acl/token/testdata/FormatToken/complex.json.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"CreateIndex": 5,
33
"ModifyIndex": 10,
4-
"Name": "",
54
"AccessorID": "fbd2447f-7479-4329-ad13-b021d74f86ba",
65
"SecretID": "869c6e91-4de9-4dab-b56e-87548435f9c6",
76
"Description": "test token",

command/acl/token/testdata/FormatTokenExpanded/ce/basic.json.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"ResolvedByAgent": "leader",
3030
"CreateIndex": 42,
3131
"ModifyIndex": 100,
32-
"Name": "",
3332
"AccessorID": "fbd2447f-7479-4329-ad13-b021d74f86ba",
3433
"SecretID": "869c6e91-4de9-4dab-b56e-87548435f9c6",
3534
"Description": "test token",

command/acl/token/testdata/FormatTokenExpanded/ce/complex.json.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144
"ResolvedByAgent": "server-1",
145145
"CreateIndex": 5,
146146
"ModifyIndex": 10,
147-
"Name": "",
148147
"AccessorID": "fbd2447f-7479-4329-ad13-b021d74f86ba",
149148
"SecretID": "869c6e91-4de9-4dab-b56e-87548435f9c6",
150149
"Description": "test token",

command/acl/token/testdata/FormatTokenList/basic.json.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"Name": "",
43
"CreateIndex": 42,
54
"ModifyIndex": 100,
65
"AccessorID": "fbd2447f-7479-4329-ad13-b021d74f86ba",

command/acl/token/testdata/FormatTokenList/complex.json.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"Name": "",
43
"CreateIndex": 5,
54
"ModifyIndex": 10,
65
"AccessorID": "fbd2447f-7479-4329-ad13-b021d74f86ba",

0 commit comments

Comments
 (0)