Files
threshold/internal/credential/options.go
T
Jeff Mitchell cede1aec93 Add initial templating support to Vault credential libraries (#2569) (#2575)
Add initial templating support to Vault credential libraries

This adds support for templating various account and user values into
Vault dynamic credential library POST bodies and GET/POST paths.

It also unifies how parameters are used in grants, with backwards
compatibility.
2022-10-27 09:01:05 -04:00

40 lines
800 B
Go

package credential
import (
"github.com/hashicorp/boundary/internal/util/template"
)
// GetOpts - iterate the inbound Options and return a struct
func GetOpts(opt ...Option) (*options, error) {
opts := getDefaultOptions()
for _, o := range opt {
if o == nil {
continue
}
if err := o(opts); err != nil {
return nil, err
}
}
return opts, nil
}
// Option - how Options are passed as arguments.
type Option func(*options) error
// options = how options are represented
type options struct {
WithTemplateData template.Data
}
func getDefaultOptions() *options {
return &options{}
}
// WithTemplateData provides a way to pass in template information
func WithTemplateData(with template.Data) Option {
return func(o *options) error {
o.WithTemplateData = with
return nil
}
}