De-duplicate component type factory map

This commit is contained in:
sophia 2021-04-26 16:44:36 -05:00 committed by Paul Hinze
parent d004125712
commit 254c462add
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 9 additions and 30 deletions

View File

@ -169,18 +169,9 @@ func ProtoToFlagsMapper(input []*vagrant_server.Job_Flag) (opt []*option.Option,
// NewBasis creates a new Basis with the given options.
func NewBasis(ctx context.Context, opts ...BasisOption) (b *Basis, err error) {
b = &Basis{
logger: hclog.L(),
jobInfo: &component.JobInfo{},
factories: map[component.Type]*factory.Factory{
component.CommandType: plugin.BaseFactories[component.CommandType],
component.CommunicatorType: plugin.BaseFactories[component.CommunicatorType],
component.ConfigType: plugin.BaseFactories[component.ConfigType],
component.GuestType: plugin.BaseFactories[component.GuestType],
component.HostType: plugin.BaseFactories[component.HostType],
component.ProviderType: plugin.BaseFactories[component.ProviderType],
component.ProvisionerType: plugin.BaseFactories[component.ProvisionerType],
component.SyncedFolderType: plugin.BaseFactories[component.SyncedFolderType],
},
logger: hclog.L(),
jobInfo: &component.JobInfo{},
factories: plugin.BaseFactories,
}
for _, opt := range opts {

View File

@ -89,24 +89,12 @@ func New(opts ...Option) (*Runner, error) {
// Our default runner
runner := &Runner{
id: id,
logger: hclog.L(),
ctx: context.Background(),
runner: &vagrant_server.Runner{Id: id},
opConfig: &intcfg.Config{},
factories: map[component.Type]*factory.Factory{
component.MapperType: plugin.BaseFactories[component.MapperType],
component.CommandType: plugin.BaseFactories[component.CommandType],
component.CommunicatorType: plugin.BaseFactories[component.CommunicatorType],
component.ConfigType: plugin.BaseFactories[component.ConfigType],
component.GuestType: plugin.BaseFactories[component.GuestType],
component.HostType: plugin.BaseFactories[component.HostType],
component.LogPlatformType: plugin.BaseFactories[component.LogPlatformType],
component.LogViewerType: plugin.BaseFactories[component.LogViewerType],
component.ProviderType: plugin.BaseFactories[component.ProviderType],
component.ProvisionerType: plugin.BaseFactories[component.ProvisionerType],
component.SyncedFolderType: plugin.BaseFactories[component.SyncedFolderType],
},
id: id,
logger: hclog.L(),
ctx: context.Background(),
runner: &vagrant_server.Runner{Id: id},
opConfig: &intcfg.Config{},
factories: plugin.BaseFactories,
}
// Build our config