osbase/net/sshtakeover: refactor package
This is an extensive refactoring of the sshtakeover package.
The package is renamed from //go/net/ssh to //osbase/net/sshtakeover,
to make it more clear what the package is for and avoid clashes with
golang.org/x/crypto/ssh.
The previous Client type was removed, and Dial is now a top-level
function which takes an ssh.ClientConfig. The previous Connection type
was renamed to Client, which makes the naming match ssh.Client.
The Client interface type was moved to //cloud/shepherd/manager. This
allows us to add more functions to sshtakeover.Client without breaking
consumers of the package, which would need to add dummy implementations
for functions which they don't need.
The Upload function was renamed to UploadExecutable, and the new Upload
function can be used for files that don't need to be executable.
The sftp client is now created at the same time as the client, instead
of creating a new one for each uploaded file.
Change-Id: I3be9c346713cb4e5c2b33f9c8c9a6f11ca569a75
Reviewed-on: https://review.monogon.dev/c/monogon/+/4047
Tested-by: Jenkins CI
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
diff --git a/cloud/shepherd/manager/initializer_test.go b/cloud/shepherd/manager/initializer_test.go
index 3c95527..3b41044 100644
--- a/cloud/shepherd/manager/initializer_test.go
+++ b/cloud/shepherd/manager/initializer_test.go
@@ -8,6 +8,7 @@
"testing"
"time"
+ "golang.org/x/crypto/ssh"
"golang.org/x/time/rate"
"source.monogon.dev/cloud/bmaas/bmdb"
@@ -24,14 +25,17 @@
ControlLoopConfig: ControlLoopConfig{
DBQueryLimiter: rate.NewLimiter(rate.Every(time.Second), 10),
},
- Executable: []byte("beep boop i'm a real program"),
- TargetPath: "/fake/path",
- Endpoint: "example.com:1234",
- SSHConnectTimeout: time.Second,
- SSHExecTimeout: time.Second,
+ Executable: []byte("beep boop i'm a real program"),
+ TargetPath: "/fake/path",
+ Endpoint: "example.com:1234",
+ SSHConfig: ssh.ClientConfig{
+ Timeout: time.Second,
+ },
+ SSHExecTimeout: time.Second,
+ DialSSH: provider.FakeSSHDial,
}
- i, err := NewInitializer(provider, provider.sshClient(), ic)
+ i, err := NewInitializer(provider, ic)
if err != nil {
t.Fatalf("Could not create Initializer: %v", err)
}