go.ligato.io/vpp-agent/v3@v3.5.0/plugins/netalloc/options.go (about) 1 package netalloc 2 3 import ( 4 "go.ligato.io/cn-infra/v2/logging" 5 6 "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" 7 ) 8 9 // DefaultPlugin is a default instance of netalloc plugin. 10 var DefaultPlugin = *NewPlugin() 11 12 // NewPlugin creates a new Plugin with the provides Options 13 func NewPlugin(opts ...Option) *Plugin { 14 p := &Plugin{} 15 16 p.PluginName = "netalloc" 17 p.KVScheduler = &kvscheduler.DefaultPlugin 18 19 for _, o := range opts { 20 o(p) 21 } 22 23 if p.Log == nil { 24 p.Log = logging.ForPlugin(p.String()) 25 } 26 27 return p 28 } 29 30 // Option is a function that can be used in NewPlugin to customize Plugin. 31 type Option func(plugin *Plugin) 32 33 // UseDeps returns Option that can inject custom dependencies. 34 func UseDeps(f func(*Deps)) Option { 35 return func(p *Plugin) { 36 f(&p.Deps) 37 } 38 }