svcacct: Colorize svcacct output (#3806)
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
@@ -96,7 +97,7 @@ const (
|
||||
|
||||
func (u svcAcctMessage) String() string {
|
||||
switch u.op {
|
||||
case "ls":
|
||||
case "list":
|
||||
// Create a new pretty table with cols configuration
|
||||
return newPrettyTable(" ",
|
||||
Field{"AccessKey", accessFieldMaxLen},
|
||||
@@ -108,7 +109,7 @@ func (u svcAcctMessage) String() string {
|
||||
} else {
|
||||
policyField = "embedded"
|
||||
}
|
||||
return console.Colorize("UserMessage", strings.Join(
|
||||
return console.Colorize("SVCMessage", strings.Join(
|
||||
[]string{
|
||||
fmt.Sprintf("AccessKey: %s", u.AccessKey),
|
||||
fmt.Sprintf("ParentUser: %s", u.ParentUser),
|
||||
@@ -116,16 +117,16 @@ func (u svcAcctMessage) String() string {
|
||||
fmt.Sprintf("Policy: %s", policyField),
|
||||
}, "\n"))
|
||||
case "rm":
|
||||
return console.Colorize("UserMessage", "Removed service account `"+u.AccessKey+"` successfully.")
|
||||
return console.Colorize("SVCMessage", "Removed service account `"+u.AccessKey+"` successfully.")
|
||||
case "disable":
|
||||
return console.Colorize("UserMessage", "Disabled service account `"+u.AccessKey+"` successfully.")
|
||||
return console.Colorize("SVCMessage", "Disabled service account `"+u.AccessKey+"` successfully.")
|
||||
case "enable":
|
||||
return console.Colorize("UserMessage", "Enabled service account `"+u.AccessKey+"` successfully.")
|
||||
return console.Colorize("SVCMessage", "Enabled service account `"+u.AccessKey+"` successfully.")
|
||||
case "add":
|
||||
return console.Colorize("UserMessage",
|
||||
return console.Colorize("SVCMessage",
|
||||
fmt.Sprintf("Access Key: %s\nSecret Key: %s", u.AccessKey, u.SecretKey))
|
||||
case "set":
|
||||
return console.Colorize("UserMessage", "Edited service account `"+u.AccessKey+"` successfully.")
|
||||
return console.Colorize("SVCMessage", "Edited service account `"+u.AccessKey+"` successfully.")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -142,6 +143,8 @@ func (u svcAcctMessage) JSON() string {
|
||||
func mainAdminUserSvcAcctAdd(ctx *cli.Context) error {
|
||||
checkAdminUserSvcAcctAddSyntax(ctx)
|
||||
|
||||
console.SetColor("SVCMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminUserSvcAcctDisableCmd = cli.Command{
|
||||
@@ -57,6 +59,8 @@ func checkAdminUserSvcAcctDisableSyntax(ctx *cli.Context) {
|
||||
func mainAdminUserSvcAcctDisable(ctx *cli.Context) error {
|
||||
checkAdminUserSvcAcctDisableSyntax(ctx)
|
||||
|
||||
console.SetColor("SVCMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminUserSvcAcctEnableCmd = cli.Command{
|
||||
@@ -57,6 +59,8 @@ func checkAdminUserSvcAcctEnableSyntax(ctx *cli.Context) {
|
||||
func mainAdminUserSvcAcctEnable(ctx *cli.Context) error {
|
||||
checkAdminUserSvcAcctEnableSyntax(ctx)
|
||||
|
||||
console.SetColor("SVCMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
@@ -20,8 +20,10 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminUserSvcAcctInfoFlags = []cli.Flag{
|
||||
@@ -65,6 +67,8 @@ func checkAdminUserSvcAcctInfoSyntax(ctx *cli.Context) {
|
||||
func mainAdminUserSvcAcctInfo(ctx *cli.Context) error {
|
||||
checkAdminUserSvcAcctInfoSyntax(ctx)
|
||||
|
||||
console.SetColor("SVCMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminUserSvcAcctListCmd = cli.Command{
|
||||
Name: "ls",
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "List services accounts",
|
||||
Action: mainAdminUserSvcAcctList,
|
||||
OnUsageError: onUsageError,
|
||||
@@ -59,6 +62,9 @@ func checkAdminUserSvcAcctListSyntax(ctx *cli.Context) {
|
||||
func mainAdminUserSvcAcctList(ctx *cli.Context) error {
|
||||
checkAdminUserSvcAcctListSyntax(ctx)
|
||||
|
||||
console.SetColor("SVCMessage", color.New(color.FgGreen))
|
||||
console.SetColor("AccessKey", color.New(color.FgBlue))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
@@ -73,7 +79,7 @@ func mainAdminUserSvcAcctList(ctx *cli.Context) error {
|
||||
|
||||
for _, svc := range svcList.Accounts {
|
||||
printMsg(svcAcctMessage{
|
||||
op: "ls",
|
||||
op: "list",
|
||||
AccessKey: svc,
|
||||
})
|
||||
}
|
||||
@@ -345,7 +345,7 @@ var completeCmds = map[string]complete.Predictor{
|
||||
"/admin/user/policy": aliasCompleter,
|
||||
|
||||
"/admin/user/svcacct/add": aliasCompleter,
|
||||
"/admin/user/svcacct/ls": aliasCompleter,
|
||||
"/admin/user/svcacct/list": aliasCompleter,
|
||||
"/admin/user/svcacct/rm": aliasCompleter,
|
||||
"/admin/user/svcacct/info": aliasCompleter,
|
||||
"/admin/user/svcacct/set": aliasCompleter,
|
||||
|
||||
Reference in New Issue
Block a user