Skip to content

Commit

Permalink
Stop using dot-imports in prouction code
Browse files Browse the repository at this point in the history
  • Loading branch information
aramprice committed Sep 7, 2023
1 parent 3976898 commit 2b445d0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions commandparser/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"path"

"github.com/cloudfoundry/stembuild/version"
. "github.com/google/subcommands"
"github.com/google/subcommands"
)

/*
Expand All @@ -20,11 +20,11 @@ line.

type stembuildHelp struct {
topLevelFlags *flag.FlagSet
commands *[]Command
commander *Commander
commands *[]subcommands.Command
commander *subcommands.Commander
}

func NewStembuildHelp(commander *Commander, topLevelFlags *flag.FlagSet, commands *[]Command) *stembuildHelp {
func NewStembuildHelp(commander *subcommands.Commander, topLevelFlags *flag.FlagSet, commands *[]subcommands.Command) *stembuildHelp {
var sh = stembuildHelp{}
sh.commander = commander
sh.topLevelFlags = topLevelFlags
Expand All @@ -49,11 +49,11 @@ func (h *stembuildHelp) Usage() string {
return h.commander.HelpCommand().Usage()
}

func (h *stembuildHelp) Execute(c context.Context, f *flag.FlagSet, args ...interface{}) ExitStatus {
func (h *stembuildHelp) Execute(c context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
switch f.NArg() {
case 0:
h.Explain(h.commander.Output)
return ExitSuccess
return subcommands.ExitSuccess

default:
return h.commander.HelpCommand().Execute(c, f, args)
Expand Down
10 changes: 5 additions & 5 deletions construct/factory/vmconstruct_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/cloudfoundry/stembuild/iaas_cli/iaas_clients"
"github.com/pkg/errors"

. "github.com/cloudfoundry/stembuild/remotemanager"
"github.com/cloudfoundry/stembuild/remotemanager"
)

type VMConstructFactory struct {
Expand Down Expand Up @@ -52,18 +52,18 @@ func (f *VMConstructFactory) VMPreparer(config config.SourceConfig, vCenterManag
}
versionGetter := version.NewVersionGetter()

winRmClientFactory := NewWinRmClientFactory(config.GuestVmIp, config.GuestVMUsername, config.GuestVMPassword)
remoteManager := NewWinRM(config.GuestVmIp, config.GuestVMUsername, config.GuestVMPassword, winRmClientFactory)
winRmClientFactory := remotemanager.NewWinRmClientFactory(config.GuestVmIp, config.GuestVMUsername, config.GuestVMPassword)
remoteManager := remotemanager.NewWinRM(config.GuestVmIp, config.GuestVMUsername, config.GuestVMPassword, winRmClientFactory)

vmConnectionValidator := &construct.WinRMConnectionValidator{
RemoteManager: remoteManager,
}

poller := &p.Poller{}

rebootChecker := NewRebootChecker(remoteManager)
rebootChecker := remotemanager.NewRebootChecker(remoteManager)

rebootWaiter := NewRebootWaiter(poller, rebootChecker)
rebootWaiter := remotemanager.NewRebootWaiter(poller, rebootChecker)

scriptExecutor := construct.NewScriptExecutor(remoteManager)

Expand Down
12 changes: 6 additions & 6 deletions construct/vmconstruct.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/cloudfoundry/stembuild/poller"

. "github.com/cloudfoundry/stembuild/remotemanager"
"github.com/cloudfoundry/stembuild/remotemanager"
)

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
Expand All @@ -25,7 +25,7 @@ type VersionGetter interface {

type VMConstruct struct {
ctx context.Context
remoteManager RemoteManager
remoteManager remotemanager.RemoteManager
Client IaasClient
guestManager GuestManager
vmInventoryPath string
Expand Down Expand Up @@ -54,7 +54,7 @@ const winRMPsScript = "BOSH.WinRM.psm1"

func NewVMConstruct(
ctx context.Context,
remoteManager RemoteManager,
remoteManager remotemanager.RemoteManager,
vmUsername,
vmPassword,
vmInventoryPath string,
Expand Down Expand Up @@ -282,10 +282,10 @@ func (c *VMConstruct) logOutUsers() error {
}

type ScriptExecutor struct {
remoteManager RemoteManager
remoteManager remotemanager.RemoteManager
}

func NewScriptExecutor(remoteManager RemoteManager) *ScriptExecutor {
func NewScriptExecutor(remoteManager remotemanager.RemoteManager) *ScriptExecutor {
return &ScriptExecutor{
remoteManager,
}
Expand All @@ -307,7 +307,7 @@ func (e *ScriptExecutor) ExecuteSetupScript(stembuildVersion string, setupFlags
func (e *ScriptExecutor) ExecutePostRebootScript(timeout time.Duration) error {
_, err := e.remoteManager.ExecuteCommandWithTimeout("powershell.exe "+stemcellAutomationPostRebootScript, timeout)

if err != nil && strings.Contains(err.Error(), PowershellExecutionErrorMessage) {
if err != nil && strings.Contains(err.Error(), remotemanager.PowershellExecutionErrorMessage) {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions construct/winrm_connection_validator.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package construct

import (
. "github.com/cloudfoundry/stembuild/remotemanager"
"github.com/cloudfoundry/stembuild/remotemanager"
)

type WinRMConnectionValidator struct {
RemoteManager RemoteManager
RemoteManager remotemanager.RemoteManager
}

func (v *WinRMConnectionValidator) Validate() error {
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"strings"

"github.com/cloudfoundry/stembuild/assets"
. "github.com/cloudfoundry/stembuild/commandparser"
"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"
"github.com/cloudfoundry/stembuild/version"
. "github.com/google/subcommands"
"github.com/google/subcommands"
)

func main() {
Expand All @@ -37,23 +37,23 @@ func main() {
os.Exit(1)
}

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

var commands = make([]Command, 0)
var commands = make([]subcommands.Command, 0)

fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
fs.BoolVar(&gf.Debug, "debug", false, "Print lots of debugging information")
fs.BoolVar(&gf.Color, "color", false, "Colorize debug output")
fs.BoolVar(&gf.ShowVersion, "version", false, "Show Stembuild version")
fs.BoolVar(&gf.ShowVersion, "v", false, "Stembuild version (shorthand)")

commander := NewCommander(fs, path.Base(os.Args[0]))
commander := subcommands.NewCommander(fs, path.Base(os.Args[0]))

sh := NewStembuildHelp(commander, fs, &commands)
sh := commandparser.NewStembuildHelp(commander, fs, &commands)
commander.Register(sh, "")
commands = append(commands, sh)

Expand Down

0 comments on commit 2b445d0

Please sign in to comment.