Append mappers to a plugin component

This commit is contained in:
sophia 2021-10-26 17:09:53 -05:00 committed by Paul Hinze
parent 7595f1533f
commit 63c71b0a20
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -552,6 +552,10 @@ 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 {
@ -626,7 +630,11 @@ 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{
@ -635,7 +643,7 @@ func (b *Basis) component(
ServerAddr: b.Client().ServerTarget(),
},
hooks: hooks,
mappers: append(b.mappers, p.Mappers...),
mappers: allMappers,
plugin: c,
}, nil
}