* feat: default to using primary auth method with authenticating * Add ability to specify scope ID flag in authenticate method --------- Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
37 lines
770 B
Go
37 lines
770 B
Go
package common
|
|
|
|
// 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 {
|
|
WithSkipScopeIdFlag bool
|
|
}
|
|
|
|
func getDefaultOptions() *Options {
|
|
return &Options{}
|
|
}
|
|
|
|
// WithSkipScopeIdFlag tells a command to not create a scope ID flag (usually
|
|
// because it's already been defined)
|
|
func WithSkipScopeIdFlag(with bool) Option {
|
|
return func(o *Options) error {
|
|
o.WithSkipScopeIdFlag = with
|
|
return nil
|
|
}
|
|
}
|