config: improve and export helper func

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-12-19 23:22:05 +03:00
parent 035a84e696
commit 150e8ad698
4 changed files with 44 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ import (
)
type Options struct {
AllowFail bool
BeforeLoad []func(context.Context, Config) error
AfterLoad []func(context.Context, Config) error
BeforeSave []func(context.Context, Config) error
@@ -38,6 +39,12 @@ func NewOptions(opts ...Option) Options {
return options
}
func AllowFail(b bool) Option {
return func(o *Options) {
o.AllowFail = b
}
}
func BeforeLoad(fn ...func(context.Context, Config) error) Option {
return func(o *Options) {
o.BeforeLoad = fn