From 254c462adda7656989779dee844bb8af39e22a6f Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 26 Apr 2021 16:44:36 -0500 Subject: [PATCH] De-duplicate component type factory map --- internal/core/basis.go | 15 +++------------ internal/runner/runner.go | 24 ++++++------------------ 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/internal/core/basis.go b/internal/core/basis.go index d55930302..f01cafcbe 100644 --- a/internal/core/basis.go +++ b/internal/core/basis.go @@ -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 { diff --git a/internal/runner/runner.go b/internal/runner/runner.go index a82f24bc0..396c610d1 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -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