Add authorized actions output on resources (#870)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2021-01-20 10:53:01 -05:00
1 parent ec6151d174
commit dcb15cffbd
93 files changed
+2475 -1038

No files matched your search

@@ -227,23 +227,29 @@ func (c *Command) Run(args []string) int {
}
if true {
output = append(output,
fmt.Sprintf(" ID: %s", m.Id),
fmt.Sprintf(" ID: %s", m.Id),
)
}
if m.Description != "" {
output = append(output,
fmt.Sprintf(" Description: %s", m.Description),
fmt.Sprintf(" Description: %s", m.Description),
)
}
if m.Name != "" {
output = append(output,
fmt.Sprintf(" Name: %s", m.Name),
fmt.Sprintf(" Name: %s", m.Name),
)
}
if true {
output = append(output,
fmt.Sprintf(" Type: %s", m.Type),
fmt.Sprintf(" Version: %d", m.Version),
fmt.Sprintf(" Type: %s", m.Type),
fmt.Sprintf(" Version: %d", m.Version),
)
}
if len(m.AuthorizedActions) > 0 {
output = append(output,
" Authorized Actions:",
base.WrapSlice(6, m.AuthorizedActions),
)
}
}
@@ -1,6 +1,8 @@
package authmethods
import (
"fmt"
"sort"
"time"
"github.com/hashicorp/boundary/api/authmethods"
@@ -47,6 +49,32 @@ func generateAuthMethodTableOutput(in *authmethods.AuthMethod) string {
base.ScopeInfoForOutput(in.Scope, maxLength),
}
if len(in.AuthorizedActions) > 0 {
ret = append(ret,
"",
" Authorized Actions:",
base.WrapSlice(4, in.AuthorizedActions),
)
}
if len(in.AuthorizedCollectionActions) > 0 {
keys := make([]string, 0, len(in.AuthorizedCollectionActions))
for k := range in.AuthorizedCollectionActions {
keys = append(keys, k)
}
sort.Strings(keys)
ret = append(ret,
"",
" Authorized Actions on Auth Method's Collections:",
)
for _, key := range keys {
ret = append(ret,
fmt.Sprintf(" %ss:", key),
base.WrapSlice(6, in.AuthorizedCollectionActions[key]),
)
}
}
if len(in.Attributes) > 0 {
ret = append(ret,
"",