Skip to content

Commit

Permalink
Merge pull request #37 from cloudfoundry/restructure-go-packages
Browse files Browse the repository at this point in the history
Restructure go packages
  • Loading branch information
rkoster authored Sep 5, 2024
2 parents b946056 + 81d49d5 commit 3991f37
Show file tree
Hide file tree
Showing 35 changed files with 227 additions and 534 deletions.
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

0 comments on commit 3991f37

Please sign in to comment.