Skip to content

Commit b79435a

Browse files
authored
feat(lb): add human marshaller for LBStatus (#1283)
1 parent ef7ab09 commit b79435a

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

internal/namespaces/lb/v1/custom.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
func GetCommands() *core.Commands {
1010
human.RegisterMarshalerFunc(lb.LBTypeStock(0), human.EnumMarshalFunc(lbTypeStockMarshalSpecs))
11+
human.RegisterMarshalerFunc(lb.LBStatus(0), human.EnumMarshalFunc(lbStatusMarshalSpecs))
1112
human.RegisterMarshalerFunc(lb.CertificateStatus(0), human.EnumMarshalFunc(certificateStatusMarshalSpecs))
1213
human.RegisterMarshalerFunc(lb.ACLActionType(0), human.EnumMarshalFunc(aclMarshalSpecs))
1314

internal/namespaces/lb/v1/custom_lb.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,25 @@ import (
44
"context"
55
"reflect"
66

7+
"github.com/fatih/color"
78
"github.com/scaleway/scaleway-cli/internal/core"
9+
"github.com/scaleway/scaleway-cli/internal/human"
810
"github.com/scaleway/scaleway-sdk-go/api/lb/v1"
911
"github.com/scaleway/scaleway-sdk-go/scw"
1012
)
1113

14+
var (
15+
lbStatusMarshalSpecs = human.EnumMarshalSpecs{
16+
lb.LBStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "error"},
17+
lb.LBStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "locked"},
18+
lb.LBStatusMigrating: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "migrating"},
19+
lb.LBStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "pending"},
20+
lb.LBStatusReady: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "ready"},
21+
lb.LBStatusStopped: &human.EnumMarshalSpec{Attribute: color.Faint, Value: "stopped"},
22+
lb.LBStatusUnknown: &human.EnumMarshalSpec{Attribute: color.Faint, Value: "unknown"},
23+
}
24+
)
25+
1226
func lbWaitCommand() *core.Command {
1327
return &core.Command{
1428
Short: `Wait for a load balancer to reach a stable state`,

0 commit comments

Comments
 (0)