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