feat(session): Add include_termianted option to list endpoint

This commit is contained in:
Timothy Messier committed 2022-06-09 19:28:04 +00:00
1 parent d741034829
commit e79714e93f
8 files changed
+145 -66

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 {
+8 -7
View File
@@ -408,13 +408,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": {