Add mappers to component at component creation phase
This commit is contained in:
parent
63c71b0a20
commit
c4cd5c599b
@ -552,10 +552,6 @@ type HasParents interface {
|
|||||||
Parent() (string, error)
|
Parent() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type HasMappers interface {
|
|
||||||
AppendMappers(...*argmapper.Func)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Basis) loadParentPlugin(p *plugin.Plugin, typ component.Type) (err error) {
|
func (b *Basis) loadParentPlugin(p *plugin.Plugin, typ component.Type) (err error) {
|
||||||
plg, err := p.InstanceOf(typ)
|
plg, err := p.InstanceOf(typ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -630,11 +626,7 @@ func (b *Basis) component(
|
|||||||
|
|
||||||
// TODO(spox): we need to add hooks
|
// TODO(spox): we need to add hooks
|
||||||
|
|
||||||
if cm, ok := c.Component.(HasMappers); ok {
|
|
||||||
cm.AppendMappers(c.Mappers...)
|
|
||||||
}
|
|
||||||
hooks := map[string][]*config.Hook{}
|
hooks := map[string][]*config.Hook{}
|
||||||
allMappers := append(b.mappers, p.Mappers...)
|
|
||||||
return &Component{
|
return &Component{
|
||||||
Value: c.Component,
|
Value: c.Component,
|
||||||
Info: &vagrant_server.Component{
|
Info: &vagrant_server.Component{
|
||||||
@ -643,7 +635,7 @@ func (b *Basis) component(
|
|||||||
ServerAddr: b.Client().ServerTarget(),
|
ServerAddr: b.Client().ServerTarget(),
|
||||||
},
|
},
|
||||||
hooks: hooks,
|
hooks: hooks,
|
||||||
mappers: allMappers,
|
mappers: append(b.mappers, p.Mappers...),
|
||||||
plugin: c,
|
plugin: c,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,6 +176,10 @@ func (p *Plugin) InstanceOf(
|
|||||||
c.SetCache(p.Cache)
|
c.SetCache(p.Cache)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cm, ok := raw.(HasMappers); ok {
|
||||||
|
cm.AppendMappers(p.Mappers...)
|
||||||
|
}
|
||||||
|
|
||||||
i = &Instance{
|
i = &Instance{
|
||||||
Component: raw,
|
Component: raw,
|
||||||
Broker: b.GRPCBroker(),
|
Broker: b.GRPCBroker(),
|
||||||
@ -188,6 +192,10 @@ func (p *Plugin) InstanceOf(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HasMappers interface {
|
||||||
|
AppendMappers(...*argmapper.Func)
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Plugin) SeedPlugin(typ component.Type, args ...interface{}) error {
|
func (p *Plugin) SeedPlugin(typ component.Type, args ...interface{}) error {
|
||||||
seedTarget := p.components[typ].Component
|
seedTarget := p.components[typ].Component
|
||||||
if s, ok := seedTarget.(core.Seeder); ok {
|
if s, ok := seedTarget.(core.Seeder); ok {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user