Skip to content

Commit 76bdc1e

Browse files
remyleonedevtools-ci-cdLaure-di
authored
feat(audit-trail): improve visualization for event list (#4579)
Co-authored-by: devtools-ci-cd <[email protected]> Co-authored-by: Laure-di <[email protected]>
1 parent 7bce89d commit 76bdc1e

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

internal/namespaces/audit_trail/v1alpha1/custom.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ import (
77
func GetCommands() *core.Commands {
88
cmds := GetGeneratedCommands()
99

10+
cmds.MustFind("audit-trail", "event", "list").Override(eventListBuilder)
11+
1012
return cmds
1113
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package audit_trail
2+
3+
import (
4+
"context"
5+
6+
"github.com/scaleway/scaleway-cli/v2/core"
7+
audit_trail "github.com/scaleway/scaleway-sdk-go/api/audit_trail/v1alpha1"
8+
)
9+
10+
func eventListBuilder(c *core.Command) *core.Command {
11+
c.View = &core.View{
12+
Fields: []*core.ViewField{
13+
{
14+
Label: "Recorded At",
15+
FieldName: "RecordedAt",
16+
},
17+
{
18+
Label: "Name",
19+
FieldName: "Resource.Name",
20+
},
21+
{
22+
Label: "StatusCode",
23+
FieldName: "StatusCode",
24+
},
25+
{
26+
Label: "MethodName",
27+
FieldName: "MethodName",
28+
},
29+
{
30+
Label: "Principal",
31+
FieldName: "Principal.ID",
32+
},
33+
{
34+
Label: "SourceIP",
35+
FieldName: "SourceIP",
36+
},
37+
{
38+
Label: "ProjectID",
39+
FieldName: "ProjectID",
40+
},
41+
{
42+
Label: "ProductName",
43+
FieldName: "ProductName",
44+
},
45+
{
46+
Label: "RequestBody",
47+
FieldName: "RequestBody",
48+
},
49+
{
50+
Label: "RequestID",
51+
FieldName: "RequestID",
52+
},
53+
{
54+
Label: "User-Agent",
55+
FieldName: "UserAgent",
56+
},
57+
{
58+
Label: "ID",
59+
FieldName: "ID",
60+
},
61+
{
62+
Label: "ServiceName",
63+
FieldName: "ServiceName",
64+
},
65+
{
66+
Label: "Type",
67+
FieldName: "Resource.Type",
68+
},
69+
{
70+
Label: "ResourceID",
71+
FieldName: "Resource.ID",
72+
},
73+
{
74+
Label: "Resource Created At",
75+
FieldName: "Resource.CreatedAt",
76+
},
77+
{
78+
Label: "Resource Updated At",
79+
FieldName: "Resource.UpdatedAt",
80+
},
81+
},
82+
}
83+
84+
c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) {
85+
originalRes, err := runner(ctx, argsI)
86+
if err != nil {
87+
return nil, err
88+
}
89+
90+
eventsResponse := originalRes.(*audit_trail.ListEventsResponse)
91+
92+
return eventsResponse.Events, nil
93+
})
94+
95+
return c
96+
}

0 commit comments

Comments
 (0)