Merge remote-tracking branch 'origin/main' into llb-byow
This commit is contained in:
commit
5d3facf561
56 files changed
+1455
-320
No files matched your search
@@ -10,17 +10,48 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
)
|
||||
|
||||
const (
|
||||
flagIncludeTerminated = "include-terminated"
|
||||
)
|
||||
|
||||
func init() {
|
||||
extraActionsFlagsMapFunc = extraActionsFlagsMapFuncImpl
|
||||
extraFlagsFunc = extraFlagsFuncImpl
|
||||
extraFlagsHandlingFunc = extraFlagsHandlingFuncImpl
|
||||
executeExtraActions = executeExtraActionsImpl
|
||||
}
|
||||
|
||||
func extraActionsFlagsMapFuncImpl() map[string][]string {
|
||||
return map[string][]string{
|
||||
"cancel": {"id"},
|
||||
"list": {flagIncludeTerminated},
|
||||
}
|
||||
}
|
||||
|
||||
type extraCmdVars struct {
|
||||
flagIncludeTerminated bool
|
||||
}
|
||||
|
||||
func extraFlagsFuncImpl(c *Command, set *base.FlagSets, f *base.FlagSet) {
|
||||
for _, name := range flagsMap[c.Func] {
|
||||
switch name {
|
||||
case flagIncludeTerminated:
|
||||
f.BoolVar(&base.BoolVar{
|
||||
Name: flagIncludeTerminated,
|
||||
Target: &c.flagIncludeTerminated,
|
||||
Usage: "If set, terminated sessions will be included in the results.",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func extraFlagsHandlingFuncImpl(c *Command, _ *base.FlagSets, opts *[]sessions.Option) bool {
|
||||
if c.flagIncludeTerminated {
|
||||
*opts = append(*opts, sessions.WithIncludeTerminated(c.flagIncludeTerminated))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Command) extraHelpFunc(helpMap map[string]func() string) string {
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
|
||||
@@ -35,6 +35,8 @@ type Command struct {
|
||||
Func string
|
||||
|
||||
plural string
|
||||
|
||||
extraCmdVars
|
||||
}
|
||||
|
||||
func (c *Command) AutocompleteArgs() complete.Predictor {
|
||||
|
||||
@@ -702,23 +702,6 @@ func printItemTable(result api.GenericResult) string {
|
||||
}
|
||||
|
||||
var credentialSourceMaps map[credential.Purpose][]map[string]interface{}
|
||||
if len(item.ApplicationCredentialSources) > 0 {
|
||||
if credentialSourceMaps == nil {
|
||||
credentialSourceMaps = make(map[credential.Purpose][]map[string]interface{})
|
||||
}
|
||||
var applicationCredentialSourceMaps []map[string]interface{}
|
||||
for _, lib := range item.ApplicationCredentialSources {
|
||||
m := map[string]interface{}{
|
||||
"ID": lib.Id,
|
||||
"Credential Store ID": lib.CredentialStoreId,
|
||||
}
|
||||
applicationCredentialSourceMaps = append(applicationCredentialSourceMaps, m)
|
||||
}
|
||||
credentialSourceMaps[credential.ApplicationPurpose] = applicationCredentialSourceMaps
|
||||
if l := len("Credential Store ID"); l > maxLength {
|
||||
maxLength = l
|
||||
}
|
||||
}
|
||||
if len(item.ApplicationCredentialLibraries) > 0 {
|
||||
if credentialSourceMaps == nil {
|
||||
credentialSourceMaps = make(map[credential.Purpose][]map[string]interface{})
|
||||
@@ -736,6 +719,40 @@ func printItemTable(result api.GenericResult) string {
|
||||
maxLength = l
|
||||
}
|
||||
}
|
||||
if len(item.ApplicationCredentialSources) > 0 {
|
||||
if credentialSourceMaps == nil {
|
||||
credentialSourceMaps = make(map[credential.Purpose][]map[string]interface{})
|
||||
}
|
||||
var applicationCredentialSourceMaps []map[string]interface{}
|
||||
for _, source := range item.ApplicationCredentialSources {
|
||||
m := map[string]interface{}{
|
||||
"ID": source.Id,
|
||||
"Credential Store ID": source.CredentialStoreId,
|
||||
}
|
||||
applicationCredentialSourceMaps = append(applicationCredentialSourceMaps, m)
|
||||
}
|
||||
credentialSourceMaps[credential.ApplicationPurpose] = applicationCredentialSourceMaps
|
||||
if l := len("Credential Store ID"); l > maxLength {
|
||||
maxLength = l
|
||||
}
|
||||
}
|
||||
if len(item.EgressCredentialSources) > 0 {
|
||||
if credentialSourceMaps == nil {
|
||||
credentialSourceMaps = make(map[credential.Purpose][]map[string]interface{})
|
||||
}
|
||||
var egressCredentialSourceMaps []map[string]interface{}
|
||||
for _, source := range item.EgressCredentialSources {
|
||||
m := map[string]interface{}{
|
||||
"ID": source.Id,
|
||||
"Credential Store ID": source.CredentialStoreId,
|
||||
}
|
||||
egressCredentialSourceMaps = append(egressCredentialSourceMaps, m)
|
||||
}
|
||||
credentialSourceMaps[credential.EgressPurpose] = egressCredentialSourceMaps
|
||||
if l := len("Credential Store ID"); l > maxLength {
|
||||
maxLength = l
|
||||
}
|
||||
}
|
||||
|
||||
ret := []string{
|
||||
"",
|
||||
@@ -775,17 +792,22 @@ func printItemTable(result api.GenericResult) string {
|
||||
}
|
||||
}
|
||||
|
||||
if len(credentialSourceMaps) > 0 {
|
||||
if appMap := credentialSourceMaps[credential.ApplicationPurpose]; len(appMap) > 0 {
|
||||
for purpose, sources := range credentialSourceMaps {
|
||||
switch purpose {
|
||||
case credential.ApplicationPurpose:
|
||||
ret = append(ret,
|
||||
" Application Credential Sources:",
|
||||
)
|
||||
for _, m := range appMap {
|
||||
ret = append(ret,
|
||||
base.WrapMap(4, maxLength, m),
|
||||
"",
|
||||
)
|
||||
}
|
||||
case credential.EgressPurpose:
|
||||
ret = append(ret,
|
||||
" Egress Credential Sources:",
|
||||
)
|
||||
}
|
||||
for _, m := range sources {
|
||||
ret = append(ret,
|
||||
base.WrapMap(4, maxLength, m),
|
||||
"",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -951,8 +973,8 @@ func exampleOutput() string {
|
||||
HostCatalogId: "hcst_1234567890",
|
||||
},
|
||||
},
|
||||
ApplicationCredentialLibraryIds: []string{"clvlt_1234567890", "clvlt_0987654321"},
|
||||
ApplicationCredentialLibraries: []*targets.CredentialLibrary{
|
||||
ApplicationCredentialSourceIds: []string{"clvlt_1234567890", "clvlt_0987654321"},
|
||||
ApplicationCredentialSources: []*targets.CredentialSource{
|
||||
{
|
||||
Id: "clvlt_1234567890",
|
||||
CredentialStoreId: "csvlt_1234567890",
|
||||
|
||||
@@ -400,13 +400,14 @@ var inputStructs = map[string][]*cmdInfo{
|
||||
},
|
||||
"sessions": {
|
||||
{
|
||||
ResourceType: resource.Session.String(),
|
||||
Pkg: "sessions",
|
||||
StdActions: []string{"read", "list"},
|
||||
Container: "Scope",
|
||||
HasExtraHelpFunc: true,
|
||||
HasId: true,
|
||||
VersionedActions: []string{"cancel"},
|
||||
ResourceType: resource.Session.String(),
|
||||
Pkg: "sessions",
|
||||
StdActions: []string{"read", "list"},
|
||||
Container: "Scope",
|
||||
HasExtraCommandVars: true,
|
||||
HasExtraHelpFunc: true,
|
||||
HasId: true,
|
||||
VersionedActions: []string{"cancel"},
|
||||
},
|
||||
},
|
||||
"targets": {
|
||||
|
||||
Reference in new issue
Block a user