2023-01-03 22:03:42 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2022-09-01 15:25:14 -04:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
|
|
// getOpts iterates the inbound Options and returns 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 options{}, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return opts, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Option - how Options are passed as arguments
|
|
|
|
|
type Option func(*options) error
|
|
|
|
|
|
|
|
|
|
// options = how options are represented
|
|
|
|
|
type options struct {
|
|
|
|
|
withRegion string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getDefaultOptions() options {
|
|
|
|
|
return options{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithRegion contains the region to use
|
|
|
|
|
func WithRegion(with string) Option {
|
|
|
|
|
return func(o *options) error {
|
|
|
|
|
o.withRegion = with
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
}
|