forked from ligato/vpp-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
43 lines (34 loc) · 952 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package nsplugin
import (
"github.com/ligato/cn-infra/config"
"github.com/ligato/cn-infra/logging"
"github.com/ligato/vpp-agent/plugins/kvscheduler"
)
// DefaultPlugin is a default instance of IfPlugin.
var DefaultPlugin = *NewPlugin()
// NewPlugin creates a new Plugin with the provides Options
func NewPlugin(opts ...Option) *NsPlugin {
p := &NsPlugin{}
p.PluginName = "linux-nsplugin"
p.KVScheduler = &kvscheduler.DefaultPlugin
for _, o := range opts {
o(p)
}
if p.Log == nil {
p.Log = logging.ForPlugin(p.String())
}
if p.Cfg == nil {
p.Cfg = config.ForPlugin(p.String(),
config.WithCustomizedFlag(config.FlagName(p.String()), "linux-nsplugin.conf"),
)
}
return p
}
// Option is a function that can be used in NewPlugin to customize Plugin.
type Option func(*NsPlugin)
// UseDeps returns Option that can inject custom dependencies.
func UseDeps(f func(*Deps)) Option {
return func(p *NsPlugin) {
f(&p.Deps)
}
}