Skip to content

Commit

Permalink
Replace snake_case using go conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
aramprice committed Sep 7, 2023
1 parent 8af707e commit 51e06f3
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 57 deletions.
10 changes: 5 additions & 5 deletions commandparser/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"strings"

vcenter_client_factory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
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"
"github.com/vmware/govmomi/guest"
Expand Down Expand Up @@ -41,7 +41,7 @@ type VMPreparerFactory interface {
//counterfeiter:generate . ManagerFactory
type ManagerFactory interface {
VCenterManager(ctx context.Context) (*vcenter_manager.VCenterManager, error)
SetConfig(config vcenter_client_factory.FactoryConfig)
SetConfig(config vcenterclientfactory.FactoryConfig)
}

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

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

Expand Down
8 changes: 4 additions & 4 deletions commandparser/package_stemcell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ var _ = Describe("package_stemcell", func() {
})

It("packager is instantiated with expected vmdk source config", func() {
vmdk_args := []string{"-vmdk", "some_vmdk_file"}
vmdkArgs := []string{"-vmdk", "some_vmdk_file"}

err := f.Parse(vmdk_args)
err := f.Parse(vmdkArgs)
Expect(err).ToNot(HaveOccurred())

exitStatus := PkgCmd.Execute(context.Background(), f)
Expand All @@ -68,15 +68,15 @@ var _ = Describe("package_stemcell", func() {
})

It("packager is instantiated with expected vcenter source config", func() {
vcenter_args := []string{
vcenterArgs := []string{
"-vcenter-url", "https://vcenter.test",
"-vcenter-username", "test-user",
"-vcenter-password", "verysecure",
"-vcenter-ca-certs", "/path/to/cert/file",
"-vm-inventory-path", "/path/to/vm",
}

err := f.Parse(vcenter_args)
err := f.Parse(vcenterArgs)
Expect(err).ToNot(HaveOccurred())

exitStatus := PkgCmd.Execute(context.Background(), f)
Expand Down
12 changes: 6 additions & 6 deletions iaas_cli/iaas_clients/factory/vcenter_manager_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/vim25"

vcenter_client_factory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
vcenterclientfactory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory/factoryfakes"
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/vcenter_manager"
. "github.com/onsi/ginkgo/v2"
Expand All @@ -18,11 +18,11 @@ import (
var _ = Describe("VcenterManagerFactory", func() {

var (
managerFactory *vcenter_client_factory.ManagerFactory
managerFactory *vcenterclientfactory.ManagerFactory
)

BeforeEach(func() {
managerFactory = &vcenter_client_factory.ManagerFactory{}
managerFactory = &vcenterclientfactory.ManagerFactory{}
})

Context("VCenterManager", func() {
Expand All @@ -37,7 +37,7 @@ var _ = Describe("VcenterManagerFactory", func() {
fakeFinderCreator := &factoryfakes.FakeFinderCreator{}
fakeFinderCreator.NewFinderReturns(fakeFinder)

managerFactory.SetConfig(vcenter_client_factory.FactoryConfig{
managerFactory.SetConfig(vcenterclientfactory.FactoryConfig{
VCenterServer: "example.com",
Username: "user",
Password: "pass",
Expand All @@ -56,7 +56,7 @@ var _ = Describe("VcenterManagerFactory", func() {
It("returns an error if the vcenter server cannot be parsed", func() {
fakeClientCreator := &factoryfakes.FakeVim25ClientCreator{}

managerFactory.SetConfig(vcenter_client_factory.FactoryConfig{
managerFactory.SetConfig(vcenterclientfactory.FactoryConfig{
VCenterServer: " :", // make soap.ParseURL fail with
Username: "user",
Password: "pass",
Expand All @@ -75,7 +75,7 @@ var _ = Describe("VcenterManagerFactory", func() {
fakeClientCreator := &factoryfakes.FakeVim25ClientCreator{}
fakeClientCreator.NewClientReturns(nil, clientErr)

managerFactory.SetConfig(vcenter_client_factory.FactoryConfig{
managerFactory.SetConfig(vcenterclientfactory.FactoryConfig{
VCenterServer: "example.com",
Username: "user",
Password: "pass",
Expand Down
8 changes: 4 additions & 4 deletions iaas_cli/iaas_clients/iaas_clients_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

vcenter_client_factory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
vcenterclientfactory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
"github.com/google/uuid"
"github.com/vmware/govmomi/object"

Expand Down Expand Up @@ -35,12 +35,12 @@ var VM *object.VirtualMachine
var CTX context.Context
var _ = BeforeSuite(func() {

managerFactory := &vcenter_client_factory.ManagerFactory{Config: vcenter_client_factory.FactoryConfig{
managerFactory := &vcenterclientfactory.ManagerFactory{Config: vcenterclientfactory.FactoryConfig{
VCenterServer: envMustExist(VcenterUrl),
Username: envMustExist(VcenterUsername),
Password: envMustExist(VcenterPassword),
ClientCreator: &vcenter_client_factory.ClientCreator{},
FinderCreator: &vcenter_client_factory.GovmomiFinderCreator{},
ClientCreator: &vcenterclientfactory.ClientCreator{},
FinderCreator: &vcenterclientfactory.GovmomiFinderCreator{},
},
}

Expand Down
11 changes: 6 additions & 5 deletions iaas_cli/iaas_clients/vcenter_client_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"time"

"github.com/cloudfoundry/stembuild/iaas_cli"
vcenter_client_factory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
vcenterclientfactory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -61,16 +62,16 @@ var _ = Describe("VcenterManager", func() {
Skip("windows cannot run a vcsim server")
}

factoryConfig := &vcenter_client_factory.FactoryConfig{
factoryConfig := &vcenterclientfactory.FactoryConfig{
VCenterServer: vCenterUrl,
Username: vCenterUsername,
Password: vCenterPassword,
ClientCreator: &vcenter_client_factory.ClientCreator{},
FinderCreator: &vcenter_client_factory.GovmomiFinderCreator{},
ClientCreator: &vcenterclientfactory.ClientCreator{},
FinderCreator: &vcenterclientfactory.GovmomiFinderCreator{},
RootCACertPath: certPath,
}

managerFactory := &vcenter_client_factory.ManagerFactory{
managerFactory := &vcenterclientfactory.ManagerFactory{
Config: *factoryConfig,
}

Expand Down
27 changes: 13 additions & 14 deletions iaas_cli/iaas_clients/vcenter_govmomi_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"path/filepath"
"time"

vcenterclientfactory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/guest_manager"

vcenter_client_factory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
Expand All @@ -29,21 +28,21 @@ var _ = Describe("VcenterClient", func() {
Describe("StartProgram", func() {

var (
managerFactory *vcenter_client_factory.ManagerFactory
factoryConfig *vcenter_client_factory.FactoryConfig
managerFactory *vcenterclientfactory.ManagerFactory
factoryConfig *vcenterclientfactory.FactoryConfig
)

BeforeEach(func() {

factoryConfig = &vcenter_client_factory.FactoryConfig{
factoryConfig = &vcenterclientfactory.FactoryConfig{
VCenterServer: envMustExist(VcenterUrl),
Username: envMustExist(VcenterUsername),
Password: envMustExist(VcenterPassword),
ClientCreator: &vcenter_client_factory.ClientCreator{},
FinderCreator: &vcenter_client_factory.GovmomiFinderCreator{},
ClientCreator: &vcenterclientfactory.ClientCreator{},
FinderCreator: &vcenterclientfactory.GovmomiFinderCreator{},
}

managerFactory = &vcenter_client_factory.ManagerFactory{}
managerFactory = &vcenterclientfactory.ManagerFactory{}
})

ExpectProgramToStartAndExitSuccessfully := func() {
Expand Down Expand Up @@ -127,22 +126,22 @@ var _ = Describe("VcenterClient", func() {

Describe("DownloadFileFromGuest", func() {
var (
managerFactory *vcenter_client_factory.ManagerFactory
factoryConfig *vcenter_client_factory.FactoryConfig
managerFactory *vcenterclientfactory.ManagerFactory
factoryConfig *vcenterclientfactory.FactoryConfig
fileToDownload string
expectedContents string
guestManager *guest_manager.GuestManager
)

BeforeEach(func() {
factoryConfig = &vcenter_client_factory.FactoryConfig{
factoryConfig = &vcenterclientfactory.FactoryConfig{
VCenterServer: envMustExist(VcenterUrl),
Username: envMustExist(VcenterUsername),
Password: envMustExist(VcenterPassword),
ClientCreator: &vcenter_client_factory.ClientCreator{},
FinderCreator: &vcenter_client_factory.GovmomiFinderCreator{},
ClientCreator: &vcenterclientfactory.ClientCreator{},
FinderCreator: &vcenterclientfactory.GovmomiFinderCreator{},
}
managerFactory = &vcenter_client_factory.ManagerFactory{}
managerFactory = &vcenterclientfactory.ManagerFactory{}
factoryConfig.RootCACertPath = ""
managerFactory.SetConfig(*factoryConfig)

Expand Down
15 changes: 7 additions & 8 deletions iaas_cli/iaas_clients/vcenter_manager/vcenter_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"errors"
"runtime"

vcenter_client_factory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"

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"
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/vcenter_manager/vcenter_managerfakes"
"github.com/vmware/govmomi/guest"
"github.com/vmware/govmomi/object"

"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/vcenter_manager"
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/vcenter_manager/vcenter_managerfakes"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/vmware/govmomi/vim25"
Expand Down Expand Up @@ -137,16 +136,16 @@ var _ = Describe("VcenterManager", func() {
inventoryPath := "/DC0/vm/DC0_H0_VM0"
clonePath := "/DC0/vm/DC0_H0_VM0_NewClone"

factoryConfig := &vcenter_client_factory.FactoryConfig{
factoryConfig := &vcenterclientfactory.FactoryConfig{
VCenterServer: "https://user:[email protected]:8989/sdk",
Username: "user",
Password: "pass",
ClientCreator: &vcenter_client_factory.ClientCreator{},
FinderCreator: &vcenter_client_factory.GovmomiFinderCreator{},
ClientCreator: &vcenterclientfactory.ClientCreator{},
FinderCreator: &vcenterclientfactory.GovmomiFinderCreator{},
RootCACertPath: CertPath,
}

managerFactory := &vcenter_client_factory.ManagerFactory{
managerFactory := &vcenterclientfactory.ManagerFactory{
Config: *factoryConfig,
}

Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

"github.com/cloudfoundry/stembuild/assets"
"github.com/cloudfoundry/stembuild/commandparser"
vmconstruct_factory "github.com/cloudfoundry/stembuild/construct/factory"
vcenter_client_factory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
packager_factory "github.com/cloudfoundry/stembuild/package_stemcell/factory"
vmconstructfactory "github.com/cloudfoundry/stembuild/construct/factory"
vcenterclientfactory "github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients/factory"
packagerfactory "github.com/cloudfoundry/stembuild/package_stemcell/factory"
"github.com/cloudfoundry/stembuild/version"
"github.com/google/subcommands"
)
Expand All @@ -38,9 +38,9 @@ func main() {
}

var gf commandparser.GlobalFlags
packageCmd := commandparser.NewPackageCommand(version.NewVersionGetter(), &packager_factory.PackagerFactory{}, &commandparser.PackageMessenger{Output: os.Stderr})
packageCmd := commandparser.NewPackageCommand(version.NewVersionGetter(), &packagerfactory.PackagerFactory{}, &commandparser.PackageMessenger{Output: os.Stderr})
packageCmd.GlobalFlags = &gf
constructCmd := commandparser.NewConstructCmd(context.Background(), &vmconstruct_factory.VMConstructFactory{}, &vcenter_client_factory.ManagerFactory{}, &commandparser.ConstructValidator{}, &commandparser.ConstructCmdMessenger{OutputChannel: os.Stderr})
constructCmd := commandparser.NewConstructCmd(context.Background(), &vmconstructfactory.VMConstructFactory{}, &vcenterclientfactory.ManagerFactory{}, &commandparser.ConstructValidator{}, &commandparser.ConstructCmdMessenger{OutputChannel: os.Stderr})
constructCmd.GlobalFlags = &gf

var commands = make([]subcommands.Command, 0)
Expand Down
12 changes: 6 additions & 6 deletions package_stemcell/packagers/vmdk_packager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path/filepath"

mock_filesystem "github.com/cloudfoundry/stembuild/filesystem/mock"
mockfilesystem "github.com/cloudfoundry/stembuild/filesystem/mock"
"github.com/cloudfoundry/stembuild/package_stemcell/package_parameters"
"github.com/cloudfoundry/stembuild/package_stemcell/packagers"
"github.com/cloudfoundry/stembuild/test/helpers"
Expand Down Expand Up @@ -123,15 +123,15 @@ var _ = Describe("VmdkPackager", func() {
Describe("ValidateFreeSpaceForPackage", func() {
var (
mockCtrl *gomock.Controller
mockFileSystem *mock_filesystem.MockFileSystem
mockFileSystem *mockfilesystem.MockFileSystem
)

Context("When VMDK file is invalid", func() {
It("returns an error", func() {
c.BuildOptions.VMDKFile = ""

mockCtrl = gomock.NewController(GinkgoT())
mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl)
mockFileSystem = mockfilesystem.NewMockFileSystem(mockCtrl)

err := c.ValidateFreeSpaceForPackage(mockFileSystem)
Expect(err).To(HaveOccurred())
Expand All @@ -145,7 +145,7 @@ var _ = Describe("VmdkPackager", func() {
c.BuildOptions.VMDKFile = filepath.Join("..", "..", "test", "data", "expected.vmdk")

mockCtrl = gomock.NewController(GinkgoT())
mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl)
mockFileSystem = mockfilesystem.NewMockFileSystem(mockCtrl)

vmdkFile, err := os.Stat(c.BuildOptions.VMDKFile)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -166,7 +166,7 @@ var _ = Describe("VmdkPackager", func() {
c.BuildOptions.VMDKFile = filepath.Join("..", "..", "test", "data", "expected.vmdk")

mockCtrl = gomock.NewController(GinkgoT())
mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl)
mockFileSystem = mockfilesystem.NewMockFileSystem(mockCtrl)

vmdkFile, err := os.Stat(c.BuildOptions.VMDKFile)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -191,7 +191,7 @@ var _ = Describe("VmdkPackager", func() {
c.BuildOptions.VMDKFile = filepath.Join("..", "..", "test", "data", "expected.vmdk")

mockCtrl = gomock.NewController(GinkgoT())
mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl)
mockFileSystem = mockfilesystem.NewMockFileSystem(mockCtrl)

directoryPath := filepath.Dir(c.BuildOptions.VMDKFile)
mockFileSystem.EXPECT().GetAvailableDiskSpace(directoryPath).Return(uint64(4), errors.New("some error")).AnyTimes()
Expand Down

0 comments on commit 51e06f3

Please sign in to comment.