Skip to content

Commit 4df2812

Browse files
committed
refactor: simplify deployer manager methods by removing unnecessary deploy package references
1 parent 2def434 commit 4df2812

File tree

1 file changed

+12
-58
lines changed

1 file changed

+12
-58
lines changed

internal/core/deploy_adapter.go

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,78 +40,32 @@ func NewBootstrapDeployer(hostname, username, privateKey, expectedHostKey string
4040
type builtinDeployerManager struct{}
4141

4242
func (builtinDeployerManager) DeployForAccount(account model.Account, keepFile bool) error {
43-
return deploy.RunDeploymentForAccount(account, keepFile)
43+
return RunDeploymentForAccount(account, keepFile)
4444
}
4545

4646
func (builtinDeployerManager) AuditSerial(account model.Account) error {
47-
return deploy.AuditAccountSerial(account)
47+
return AuditAccountSerial(account)
4848
}
4949
func (builtinDeployerManager) AuditStrict(account model.Account) error {
50-
return deploy.AuditAccountStrict(account)
50+
return AuditAccountStrict(account)
5151
}
5252

5353
func (builtinDeployerManager) DecommissionAccount(account model.Account, systemPrivateKey string, options interface{}) (DecommissionResult, error) {
54-
var opts deploy.DecommissionOptions
55-
if o, ok := options.(deploy.DecommissionOptions); ok {
54+
var opts DecommissionOptions
55+
if o, ok := options.(DecommissionOptions); ok {
5656
opts = o
57-
} else if o2, ok := options.(DecommissionOptions); ok {
58-
opts = deploy.DecommissionOptions{
59-
SkipRemoteCleanup: o2.SkipRemoteCleanup,
60-
KeepFile: o2.KeepFile,
61-
Force: o2.Force,
62-
DryRun: o2.DryRun,
63-
SelectiveKeys: o2.SelectiveKeys,
64-
}
6557
}
66-
r := deploy.DecommissionAccount(account, systemPrivateKey, opts)
67-
return DecommissionResult{
68-
Account: account,
69-
AccountID: r.AccountID,
70-
AccountString: r.AccountString,
71-
RemoteCleanupDone: r.RemoteCleanupDone,
72-
RemoteCleanupError: r.RemoteCleanupError,
73-
DatabaseDeleteDone: r.DatabaseDeleteDone,
74-
DatabaseDeleteError: r.DatabaseDeleteError,
75-
BackupPath: r.BackupPath,
76-
Skipped: r.Skipped,
77-
SkipReason: r.SkipReason,
78-
}, nil
58+
r := DecommissionAccount(account, systemPrivateKey, opts)
59+
return r, nil
7960
}
8061

8162
func (builtinDeployerManager) BulkDecommissionAccounts(accounts []model.Account, systemPrivateKey string, options interface{}) ([]DecommissionResult, error) {
82-
var opts deploy.DecommissionOptions
83-
if o, ok := options.(deploy.DecommissionOptions); ok {
63+
var opts DecommissionOptions
64+
if o, ok := options.(DecommissionOptions); ok {
8465
opts = o
85-
} else if o2, ok := options.(DecommissionOptions); ok {
86-
opts = deploy.DecommissionOptions{
87-
SkipRemoteCleanup: o2.SkipRemoteCleanup,
88-
KeepFile: o2.KeepFile,
89-
Force: o2.Force,
90-
DryRun: o2.DryRun,
91-
SelectiveKeys: o2.SelectiveKeys,
92-
}
93-
}
94-
res := deploy.BulkDecommissionAccounts(accounts, systemPrivateKey, opts)
95-
out := make([]DecommissionResult, 0, len(res))
96-
for i, r := range res {
97-
var acc model.Account
98-
if i < len(accounts) {
99-
acc = accounts[i]
100-
}
101-
out = append(out, DecommissionResult{
102-
Account: acc,
103-
AccountID: r.AccountID,
104-
AccountString: r.AccountString,
105-
RemoteCleanupDone: r.RemoteCleanupDone,
106-
RemoteCleanupError: r.RemoteCleanupError,
107-
DatabaseDeleteDone: r.DatabaseDeleteDone,
108-
DatabaseDeleteError: r.DatabaseDeleteError,
109-
BackupPath: r.BackupPath,
110-
Skipped: r.Skipped,
111-
SkipReason: r.SkipReason,
112-
})
11366
}
114-
return out, nil
67+
res := BulkDecommissionAccounts(accounts, systemPrivateKey, opts)
68+
return res, nil
11569
}
11670

11771
func (builtinDeployerManager) CanonicalizeHostPort(host string) string {
@@ -157,7 +111,7 @@ func (builtinDeployerManager) FetchAuthorizedKeys(account model.Account) ([]byte
157111
}
158112
}()
159113

160-
deployer, err := deploy.NewDeployerFunc(account.Hostname, account.Username, privateKey, passphrase)
114+
deployer, err := NewDeployerFactory(account.Hostname, account.Username, privateKey, passphrase)
161115
if err != nil {
162116
return nil, err
163117
}

0 commit comments

Comments
 (0)