Add recursive listing to roles (#881)

This also lays the framework for adding recursive listing to the rest of the resources.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2021-01-23 13:39:04 -05:00
1 parent 0629526319
commit 6b58a3317d
18 files changed
+430 -511

No files matched your search

+14
View File
@@ -1,6 +1,8 @@
package roles
import (
"strconv"
"github.com/hashicorp/boundary/api"
)
@@ -18,6 +20,7 @@ type options struct {
queryMap map[string]string
withAutomaticVersioning bool
withSkipCurlOutput bool
withRecursive bool
}
func getDefaultOptions() options {
@@ -36,6 +39,9 @@ func getOpts(opt ...Option) (options, []api.Option) {
if opts.withSkipCurlOutput {
apiOpts = append(apiOpts, api.WithSkipCurlOutput(true))
}
if opts.withRecursive {
opts.queryMap["recursive"] = strconv.FormatBool(opts.withRecursive)
}
return opts, apiOpts
}
@@ -57,6 +63,14 @@ func WithSkipCurlOutput(skip bool) Option {
}
}
// WithRecursive tells the API to use recursion for listing operations on this
// resource
func WithRecursive(recurse bool) Option {
return func(o *options) {
o.withRecursive = true
}
}
func WithDescription(inDescription string) Option {
return func(o *options) {
o.postMap["description"] = inDescription