From 3fa46f42bba0c669c06e728277d29fdc609fb032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 30 Jul 2020 13:54:48 +0200 Subject: [PATCH] feat(rdb): add coloring for node-type availability and acl action (#1304) --- internal/namespaces/rdb/v1/custom.go | 2 ++ internal/namespaces/rdb/v1/custom_acl.go | 14 ++++++++++++++ internal/namespaces/rdb/v1/custom_node_type.go | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 internal/namespaces/rdb/v1/custom_acl.go create mode 100644 internal/namespaces/rdb/v1/custom_node_type.go diff --git a/internal/namespaces/rdb/v1/custom.go b/internal/namespaces/rdb/v1/custom.go index e681815707..5e908b7c9f 100644 --- a/internal/namespaces/rdb/v1/custom.go +++ b/internal/namespaces/rdb/v1/custom.go @@ -27,6 +27,8 @@ func GetCommands() *core.Commands { human.RegisterMarshalerFunc(rdb.InstanceStatus(0), human.EnumMarshalFunc(instanceStatusMarshalSpecs)) human.RegisterMarshalerFunc(rdb.DatabaseBackupStatus(0), human.EnumMarshalFunc(backupStatusMarshalSpecs)) human.RegisterMarshalerFunc(rdb.InstanceLogStatus(0), human.EnumMarshalFunc(logStatusMarshalSpecs)) + human.RegisterMarshalerFunc(rdb.NodeTypeStock(0), human.EnumMarshalFunc(nodeTypeStockMarshalSpecs)) + human.RegisterMarshalerFunc(rdb.ACLRuleAction(0), human.EnumMarshalFunc(aclRuleActionMarshalSpecs)) cmds.Merge(core.NewCommands( instanceWaitCommand(), diff --git a/internal/namespaces/rdb/v1/custom_acl.go b/internal/namespaces/rdb/v1/custom_acl.go new file mode 100644 index 0000000000..62585d6ce2 --- /dev/null +++ b/internal/namespaces/rdb/v1/custom_acl.go @@ -0,0 +1,14 @@ +package rdb + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/internal/human" + "github.com/scaleway/scaleway-sdk-go/api/rdb/v1" +) + +var ( + aclRuleActionMarshalSpecs = human.EnumMarshalSpecs{ + rdb.ACLRuleActionAllow: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "allow"}, + rdb.ACLRuleActionDeny: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "deny"}, + } +) diff --git a/internal/namespaces/rdb/v1/custom_node_type.go b/internal/namespaces/rdb/v1/custom_node_type.go new file mode 100644 index 0000000000..e7bb379179 --- /dev/null +++ b/internal/namespaces/rdb/v1/custom_node_type.go @@ -0,0 +1,16 @@ +package rdb + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/internal/human" + "github.com/scaleway/scaleway-sdk-go/api/rdb/v1" +) + +var ( + nodeTypeStockMarshalSpecs = human.EnumMarshalSpecs{ + rdb.NodeTypeStockAvailable: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "available"}, + rdb.NodeTypeStockUnknown: &human.EnumMarshalSpec{Attribute: color.Faint, Value: "unknown"}, + rdb.NodeTypeStockLowStock: &human.EnumMarshalSpec{Attribute: color.FgYellow, Value: "low stock"}, + rdb.NodeTypeStockOutOfStock: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "out of stock"}, + } +)