Skip to content

Commit b00fbfc

Browse files
authored
feat(events): update description (#2329)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent 9467718 commit b00fbfc

File tree

50 files changed

+223
-104
lines changed

Some content is hidden

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

50 files changed

+223
-104
lines changed

app/controlplane/pkg/auditor/events/apitoken.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ func (a *APITokenCreated) ActionInfo() (json.RawMessage, error) {
8686

8787
func (a *APITokenCreated) Description() string {
8888
if a.ExpiresAt != nil {
89-
return fmt.Sprintf("{{ .ActorEmail }} has created the API token %s expiring at %s", a.APITokenName, a.ExpiresAt.Format(time.RFC3339))
89+
return fmt.Sprintf("%s has created the API token %s expiring at %s", auditor.GetActorIdentifier(), a.APITokenName, a.ExpiresAt.Format(time.RFC3339))
9090
}
91-
return fmt.Sprintf("{{ .ActorEmail }} has created the API token %s", a.APITokenName)
91+
return fmt.Sprintf("%s has created the API token %s", auditor.GetActorIdentifier(), a.APITokenName)
9292
}
9393

9494
type APITokenRevoked struct {
@@ -109,5 +109,5 @@ func (a *APITokenRevoked) ActionInfo() (json.RawMessage, error) {
109109
}
110110

111111
func (a *APITokenRevoked) Description() string {
112-
return fmt.Sprintf("{{ .ActorEmail }} has revoked the API token %s", a.APITokenName)
112+
return fmt.Sprintf("%s has revoked the API token %s", auditor.GetActorIdentifier(), a.APITokenName)
113113
}

app/controlplane/pkg/auditor/events/events_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var updateGolden bool
2525

2626
const (
2727
testEmail = "[email protected]"
28-
testName = "John Doe"
28+
testName = "John Connor"
2929
testAPITokenName = "test-token"
3030
)
3131

app/controlplane/pkg/auditor/events/group.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (g *GroupCreated) ActionInfo() (json.RawMessage, error) {
8888
}
8989

9090
func (g *GroupCreated) Description() string {
91-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has created the group %s", g.GroupName)
91+
return fmt.Sprintf("%s has created the group %s", auditor.GetActorIdentifier(), g.GroupName)
9292
}
9393

9494
// GroupUpdated represents an update to a group
@@ -113,9 +113,9 @@ func (g *GroupUpdated) ActionInfo() (json.RawMessage, error) {
113113

114114
func (g *GroupUpdated) Description() string {
115115
if g.OldName != nil && g.NewName != nil {
116-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has renamed the group from %s to %s", *g.OldName, *g.NewName)
116+
return fmt.Sprintf("%s has renamed the group from %s to %s", auditor.GetActorIdentifier(), *g.OldName, *g.NewName)
117117
}
118-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has updated the group %s", g.GroupName)
118+
return fmt.Sprintf("%s has updated the group %s", auditor.GetActorIdentifier(), g.GroupName)
119119
}
120120

121121
// GroupDeleted represents the deletion of a group
@@ -136,7 +136,7 @@ func (g *GroupDeleted) ActionInfo() (json.RawMessage, error) {
136136
}
137137

138138
func (g *GroupDeleted) Description() string {
139-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has deleted the group %s", g.GroupName)
139+
return fmt.Sprintf("%s has deleted the group %s", auditor.GetActorIdentifier(), g.GroupName)
140140
}
141141

142142
// GroupMemberAdded represents the addition of a member to a group
@@ -169,8 +169,8 @@ func (g *GroupMemberAdded) Description() string {
169169
maintainerStatus = " as a maintainer"
170170
}
171171

172-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has added user %s to the group %s%s",
173-
g.UserEmail, g.GroupName, maintainerStatus)
172+
return fmt.Sprintf("%s has added user %s to the group %s%s",
173+
auditor.GetActorIdentifier(), g.UserEmail, g.GroupName, maintainerStatus)
174174
}
175175

176176
// GroupMemberRemoved represents the removal of a member from a group
@@ -197,8 +197,8 @@ func (g *GroupMemberRemoved) ActionInfo() (json.RawMessage, error) {
197197
}
198198

199199
func (g *GroupMemberRemoved) Description() string {
200-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has removed user %s from the group %s",
201-
g.UserEmail, g.GroupName)
200+
return fmt.Sprintf("%s has removed user %s from the group %s",
201+
auditor.GetActorIdentifier(), g.UserEmail, g.GroupName)
202202
}
203203

204204
// GroupMemberUpdated represents the update of a group member
@@ -227,6 +227,6 @@ func (g *GroupMemberUpdated) ActionInfo() (json.RawMessage, error) {
227227
}
228228

229229
func (g *GroupMemberUpdated) Description() string {
230-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has updated user %s in the group %s",
231-
g.UserEmail, g.GroupName)
230+
return fmt.Sprintf("%s has updated user %s in the group %s",
231+
auditor.GetActorIdentifier(), g.UserEmail, g.GroupName)
232232
}

app/controlplane/pkg/auditor/events/organization.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (p *OrgCreated) ActionType() string {
7373
}
7474

7575
func (p *OrgCreated) Description() string {
76-
return fmt.Sprintf("{{ .ActorEmail }} has created the organization %s", p.OrgName)
76+
return fmt.Sprintf("%s has created the organization %s", auditor.GetActorIdentifier(), p.OrgName)
7777
}
7878

7979
// user joined the organization
@@ -92,7 +92,7 @@ func (p *OrgUserJoined) ActionType() string {
9292
}
9393

9494
func (p *OrgUserJoined) Description() string {
95-
return fmt.Sprintf("{{ .ActorEmail }} has joined the organization %s", p.OrgName)
95+
return fmt.Sprintf("%s has joined the organization %s", auditor.GetActorIdentifier(), p.OrgName)
9696
}
9797

9898
func (p *OrgUserJoined) ActionInfo() (json.RawMessage, error) {
@@ -113,7 +113,7 @@ func (p *OrgUserLeft) ActionType() string {
113113
}
114114

115115
func (p *OrgUserLeft) Description() string {
116-
return fmt.Sprintf("{{ .ActorEmail }} has left the organization %s", p.OrgName)
116+
return fmt.Sprintf("%s has left the organization %s", auditor.GetActorIdentifier(), p.OrgName)
117117
}
118118

119119
// user got invited to the organization
@@ -128,7 +128,7 @@ func (p *OrgUserInvited) ActionType() string {
128128
}
129129

130130
func (p *OrgUserInvited) Description() string {
131-
return fmt.Sprintf("{{ .ActorEmail }} has invited %s to the organization %s with role %s", p.ReceiverEmail, p.OrgName, p.Role)
131+
return fmt.Sprintf("%s has invited %s to the organization %s with role %s", auditor.GetActorIdentifier(), p.ReceiverEmail, p.OrgName, p.Role)
132132
}
133133

134134
func (p *OrgUserInvited) ActionInfo() (json.RawMessage, error) {

app/controlplane/pkg/auditor/events/project.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ func (p *ProjectMemberRoleUpdated) ActionInfo() (json.RawMessage, error) {
109109
func (p *ProjectMemberRoleUpdated) Description() string {
110110
if p.UserID != nil {
111111
// User role update
112-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has updated user '%s' role in project '%s' from '%s' to '%s'",
113-
p.UserEmail, p.ProjectName, prettyRole(p.OldRole), prettyRole(p.NewRole))
112+
return fmt.Sprintf("%s has updated user '%s' role in project '%s' from '%s' to '%s'",
113+
auditor.GetActorIdentifier(), p.UserEmail, p.ProjectName, prettyRole(p.OldRole), prettyRole(p.NewRole))
114114
}
115115

116116
// Group role update
117-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has updated group '%s' role in project '%s' from '%s' to '%s'",
118-
p.GroupName, p.ProjectName, prettyRole(p.OldRole), prettyRole(p.NewRole))
117+
return fmt.Sprintf("%s has updated group '%s' role in project '%s' from '%s' to '%s'",
118+
auditor.GetActorIdentifier(), p.GroupName, p.ProjectName, prettyRole(p.OldRole), prettyRole(p.NewRole))
119119
}
120120

121121
// ProjectMembershipAdded represents the addition of a member (user or group) to a project
@@ -156,13 +156,13 @@ func (p *ProjectMembershipAdded) Description() string {
156156

157157
if p.UserID != nil {
158158
// User addition
159-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has added user '%s' to the project '%s'%s",
160-
p.UserEmail, p.ProjectName, roleDesc)
159+
return fmt.Sprintf("%s has added user '%s' to the project '%s'%s",
160+
auditor.GetActorIdentifier(), p.UserEmail, p.ProjectName, roleDesc)
161161
}
162162

163163
// Group addition
164-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has added group '%s' to the project '%s'%s",
165-
p.GroupName, p.ProjectName, roleDesc)
164+
return fmt.Sprintf("%s has added group '%s' to the project '%s'%s",
165+
auditor.GetActorIdentifier(), p.GroupName, p.ProjectName, roleDesc)
166166
}
167167

168168
// ProjectMembershipRemoved represents the removal of a member (user or group) from a project
@@ -196,11 +196,11 @@ func (p *ProjectMembershipRemoved) ActionInfo() (json.RawMessage, error) {
196196
func (p *ProjectMembershipRemoved) Description() string {
197197
if p.UserID != nil {
198198
// User removal
199-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has removed user '%s' from the project '%s'",
200-
p.UserEmail, p.ProjectName)
199+
return fmt.Sprintf("%s has removed user '%s' from the project '%s'",
200+
auditor.GetActorIdentifier(), p.UserEmail, p.ProjectName)
201201
}
202202

203203
// Group removal
204-
return fmt.Sprintf("{{ if .ActorEmail }}{{ .ActorEmail }}{{ else }}[email protected]{{ end }} has removed group '%s' from the project '%s'",
205-
p.GroupName, p.ProjectName)
204+
return fmt.Sprintf("%s has removed group '%s' from the project '%s'",
205+
auditor.GetActorIdentifier(), p.GroupName, p.ProjectName)
206206
}

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_created.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8-
"ActorName": "John Doe",
8+
"ActorName": "John Connor",
99
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
10-
"Description": "[email protected] has created the API token test-token",
10+
"Description": "John Connor has created the API token test-token",
1111
"Info": {
1212
"api_token_id": "2089bb36-e27b-428b-8009-d015c8737c55",
1313
"api_token_name": "test-token"

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_created_with_description.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8-
"ActorName": "John Doe",
8+
"ActorName": "John Connor",
99
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
10-
"Description": "[email protected] has created the API token test-token",
10+
"Description": "John Connor has created the API token test-token",
1111
"Info": {
1212
"api_token_id": "2089bb36-e27b-428b-8009-d015c8737c55",
1313
"api_token_name": "test-token",

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_created_with_expiration_date.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8-
"ActorName": "John Doe",
8+
"ActorName": "John Connor",
99
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
10-
"Description": "[email protected] has created the API token test-token expiring at 2025-01-01T00:00:00Z",
10+
"Description": "John Connor has created the API token test-token expiring at 2025-01-01T00:00:00Z",
1111
"Info": {
1212
"api_token_id": "2089bb36-e27b-428b-8009-d015c8737c55",
1313
"api_token_name": "test-token",

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_revoked.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"ActorEmail": "",
88
"ActorName": "test-token",
99
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
10-
"Description": " has revoked the API token test-token",
10+
"Description": "test-token has revoked the API token test-token",
1111
"Info": {
1212
"api_token_id": "2089bb36-e27b-428b-8009-d015c8737c55",
1313
"api_token_name": "test-token"

app/controlplane/pkg/auditor/events/testdata/groups/group_created.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8-
"ActorName": "John Doe",
8+
"ActorName": "John Connor",
99
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
10-
"Description": "[email protected] has created the group test-group",
10+
"Description": "John Connor has created the group test-group",
1111
"Info": {
1212
"group_id": "3089bb36-e27b-428b-8009-d015c8737c56",
1313
"group_name": "test-group",

0 commit comments

Comments
 (0)