Skip to content

Commit b0920a6

Browse files
authored
feat(iam): add color for logs action (#3515)
1 parent b259248 commit b0920a6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/namespaces/iam/v1alpha1/custom.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,29 @@ import (
77
"reflect"
88
"strings"
99

10+
"github.com/fatih/color"
1011
"github.com/scaleway/scaleway-cli/v2/internal/args"
1112
"github.com/scaleway/scaleway-cli/v2/internal/core"
13+
"github.com/scaleway/scaleway-cli/v2/internal/human"
1214
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
1315
iam "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1"
1416
"github.com/scaleway/scaleway-sdk-go/scw"
1517
)
1618

19+
var (
20+
logActionMarshalSpecs = human.EnumMarshalSpecs{
21+
iam.LogActionUnknownAction: &human.EnumMarshalSpec{Attribute: color.Faint},
22+
iam.LogActionCreated: &human.EnumMarshalSpec{Attribute: color.FgGreen},
23+
iam.LogActionUpdated: &human.EnumMarshalSpec{Attribute: color.FgBlue},
24+
iam.LogActionDeleted: &human.EnumMarshalSpec{Attribute: color.FgRed},
25+
}
26+
)
27+
1728
func GetCommands() *core.Commands {
1829
cmds := GetGeneratedCommands()
1930

31+
human.RegisterMarshalerFunc(iam.LogAction(""), human.EnumMarshalFunc(logActionMarshalSpecs))
32+
2033
cmds.Merge(core.NewCommands(
2134
initWithSSHCommand(),
2235
))

0 commit comments

Comments
 (0)