1
0
mirror of https://github.com/minio/mc.git synced 2025-11-25 08:23:07 +03:00

Show groups with their policy details while listing users (#4578)

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
Shubhendu
2023-05-23 22:45:19 +05:30
committed by GitHub
parent 8c06f54d8b
commit 7415469c72
3 changed files with 50 additions and 9 deletions

View File

@@ -18,6 +18,8 @@
package cmd
import (
"strings"
"github.com/fatih/color"
"github.com/minio/cli"
"github.com/minio/mc/pkg/probe"
@@ -76,11 +78,24 @@ func mainAdminUserList(ctx *cli.Context) error {
fatalIf(probe.NewError(e).Trace(args...), "Unable to list user")
for k, v := range users {
memberOf := []userGroup{}
for _, group := range v.MemberOf {
gd, e := client.GetGroupDescription(globalContext, group)
fatalIf(probe.NewError(e).Trace(args...), "Unable to fetch group info")
policies := []string{}
if gd.Policy != "" {
policies = strings.Split(gd.Policy, ",")
}
memberOf = append(memberOf, userGroup{
Name: gd.Name,
Policies: policies,
})
}
printMsg(userMessage{
op: ctx.Command.Name,
AccessKey: k,
PolicyName: v.PolicyName,
MemberOf: v.MemberOf,
MemberOf: memberOf,
UserStatus: string(v.Status),
})
}