2022-07-07 16:57:38 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
type Options struct {
|
|
|
|
ScanDir []string
|
|
|
|
BootCMDLineFile string
|
|
|
|
MergeBootCMDLine bool
|
2022-12-19 17:01:57 +01:00
|
|
|
NoLogs bool
|
2023-02-14 16:15:13 +01:00
|
|
|
StrictValidation bool
|
2022-07-07 16:57:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Option func(o *Options) error
|
|
|
|
|
2022-12-19 17:01:57 +01:00
|
|
|
var NoLogs Option = func(o *Options) error {
|
|
|
|
o.NoLogs = true
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-07-07 16:57:38 +00:00
|
|
|
func (o *Options) Apply(opts ...Option) error {
|
|
|
|
for _, oo := range opts {
|
|
|
|
if err := oo(o); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var MergeBootLine = func(o *Options) error {
|
|
|
|
o.MergeBootCMDLine = true
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithBootCMDLineFile(s string) Option {
|
|
|
|
return func(o *Options) error {
|
|
|
|
o.BootCMDLineFile = s
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func Directories(d ...string) Option {
|
|
|
|
return func(o *Options) error {
|
|
|
|
o.ScanDir = d
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
2023-02-14 16:15:13 +01:00
|
|
|
|
|
|
|
// StrictValidation sets the strict validation option to true or false.
|
|
|
|
func StrictValidation(b bool) Option {
|
|
|
|
return func(o *Options) error {
|
|
|
|
o.StrictValidation = b
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|