Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure go packages #37

Merged
merged 6 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions commandparser/commandparserfakes/fake_manager_factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 39 additions & 39 deletions commandparser/commandparserfakes/fake_packager_factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 39 additions & 39 deletions commandparser/commandparserfakes/fake_vmpreparer_factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions commandparser/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/vmware/govmomi/object"

"github.com/cloudfoundry/stembuild/construct/config"
vcenterclientfactory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/guest_manager"
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/vcenter_manager"
)
Expand All @@ -35,13 +34,13 @@ type VCenterManager interface {

//counterfeiter:generate . VMPreparerFactory
type VMPreparerFactory interface {
VMPreparer(config config.SourceConfig, vCenterManager VCenterManager) (VmConstruct, error)
New(config config.SourceConfig, vCenterManager VCenterManager) (VmConstruct, error)
}

//counterfeiter:generate . ManagerFactory
type ManagerFactory interface {
VCenterManager(ctx context.Context) (*vcenter_manager.VCenterManager, error)
SetConfig(config vcenterclientfactory.FactoryConfig)
SetConfig(config vcenter_manager.FactoryConfig)
}

//counterfeiter:generate . ConstructCmdValidator
Expand Down Expand Up @@ -139,12 +138,12 @@ func (p *ConstructCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfac
return subcommands.ExitFailure
}

p.managerFactory.SetConfig(vcenterclientfactory.FactoryConfig{
p.managerFactory.SetConfig(vcenter_manager.FactoryConfig{
VCenterServer: p.sourceConfig.VCenterUrl,
Username: p.sourceConfig.VCenterUsername,
Password: p.sourceConfig.VCenterPassword,
ClientCreator: &vcenterclientfactory.ClientCreator{},
FinderCreator: &vcenterclientfactory.GovmomiFinderCreator{},
ClientCreator: &vcenter_manager.ClientCreator{},
FinderCreator: &vcenter_manager.GovmomiFinderCreator{},
RootCACertPath: p.sourceConfig.CaCertFile,
})

Expand All @@ -154,7 +153,7 @@ func (p *ConstructCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfac
return subcommands.ExitFailure
}

vmConstruct, err := p.prepFactory.VMPreparer(p.sourceConfig, vCenterManager)
vmConstruct, err := p.prepFactory.New(p.sourceConfig, vCenterManager)
if err != nil {
p.messenger.CannotPrepareVM(err)
return subcommands.ExitFailure
Expand Down
2 changes: 1 addition & 1 deletion commandparser/construct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ var _ = Describe("construct", func() {
fakeValidator = &commandparserfakes.FakeConstructCmdValidator{}
fakeMessenger = &commandparserfakes.FakeConstructMessenger{}
fakeManagerFactory = &commandparserfakes.FakeManagerFactory{}
fakeFactory.VMPreparerReturns(fakeVmConstruct, nil)
fakeFactory.NewReturns(fakeVmConstruct, nil)

ConstrCmd = commandparser.NewConstructCmd(context.Background(), fakeFactory, fakeManagerFactory, fakeValidator, fakeMessenger)
ConstrCmd.SetFlags(f)
Expand Down
4 changes: 2 additions & 2 deletions commandparser/package_stemcell.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type OSAndVersionGetter interface {

//counterfeiter:generate . PackagerFactory
type PackagerFactory interface {
Packager(sourceConfig config.SourceConfig, outputConfig config.OutputConfig, logger colorlogger.Logger) (Packager, error)
NewPackager(sourceConfig config.SourceConfig, outputConfig config.OutputConfig, logger colorlogger.Logger) (Packager, error)
}

//counterfeiter:generate . Packager
Expand Down Expand Up @@ -130,7 +130,7 @@ func (p *PackageCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{
}

logger := colorlogger.New(logLevel, p.GlobalFlags.Color, os.Stderr)
packager, err := p.packagerFactory.Packager(p.sourceConfig, p.outputConfig, logger)
packager, err := p.packagerFactory.NewPackager(p.sourceConfig, p.outputConfig, logger)
if err != nil {
p.packagerMessenger.CannotCreatePackager(err)
return subcommands.ExitFailure
Expand Down
Loading