Get plugins from basis
This commit is contained in:
parent
9651e1a756
commit
f1dc606d11
@ -162,6 +162,37 @@ func (b *Basis) DataDir() (*datadir.Basis, error) {
|
||||
return b.dir, nil
|
||||
}
|
||||
|
||||
var StringComponentTypeMap = map[string]component.Type{
|
||||
"command": component.CommandType,
|
||||
"communicator": component.CommunicatorType,
|
||||
"guest": component.GuestType,
|
||||
"host": component.HostType,
|
||||
"provider": component.ProviderType,
|
||||
"provisioner": component.ProvisionerType,
|
||||
"synced_folder": component.SyncedFolderType,
|
||||
}
|
||||
|
||||
// Implements core.Basis
|
||||
// Returns all the registered plugins of the types specified
|
||||
func (b *Basis) Plugins(types ...string) (plugins []*core.NamedPlugin, err error) {
|
||||
plugins = []*core.NamedPlugin{}
|
||||
for _, pluginType := range types {
|
||||
typ := StringComponentTypeMap[pluginType]
|
||||
components, err := b.typeComponents(b.ctx, typ)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for name, h := range components {
|
||||
plugins = append(plugins, &core.NamedPlugin{
|
||||
Plugin: h.Value,
|
||||
Name: name,
|
||||
Type: pluginType,
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Generic function for providing ref to a scope
|
||||
func (b *Basis) Ref() interface{} {
|
||||
return &vagrant_plugin_sdk.Ref_Basis{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user