Skip to content

Commit 5b41de8

Browse files
authored
Merge pull request #3746 from unsuman/fix/rm-sshlocalport
Fix: Pass `SSHLocalPort` in Instance to configure driver
2 parents d12a3b2 + a680340 commit 5b41de8

File tree

10 files changed

+34
-44
lines changed

10 files changed

+34
-44
lines changed

pkg/driver/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type Driver interface {
8080
Info() Info
8181

8282
// SetConfig sets the configuration for the instance.
83-
Configure(inst *store.Instance, sshLocalPort int) *ConfiguredDriver
83+
Configure(inst *store.Instance) *ConfiguredDriver
8484
}
8585

8686
type ConfiguredDriver struct {

pkg/driver/external/client/methods.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ func (d *DriverClient) Info() driver.Info {
281281
return info
282282
}
283283

284-
func (d *DriverClient) Configure(inst *store.Instance, sshLocalPort int) *driver.ConfiguredDriver {
285-
d.logger.Debugf("Setting config for instance %s with SSH local port %d", inst.Name, sshLocalPort)
284+
func (d *DriverClient) Configure(inst *store.Instance) *driver.ConfiguredDriver {
285+
d.logger.Debugf("Setting config for instance %s with SSH local port %d", inst.Name, inst.SSHLocalPort)
286286

287287
instJSON, err := inst.MarshalJSON()
288288
if err != nil {
@@ -295,7 +295,6 @@ func (d *DriverClient) Configure(inst *store.Instance, sshLocalPort int) *driver
295295

296296
_, err = d.DriverSvc.SetConfig(ctx, &pb.SetConfigRequest{
297297
InstanceConfigJson: instJSON,
298-
SshLocalPort: int64(sshLocalPort),
299298
})
300299
if err != nil {
301300
d.logger.Errorf("Failed to set config: %v", err)

pkg/driver/external/driver.pb.go

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/driver/external/driver.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ message StartResponse {
4242

4343
message SetConfigRequest {
4444
bytes instance_config_json = 1;
45-
int64 ssh_local_port = 3;
4645
}
4746

4847
message ChangeDisplayPasswordRequest {

pkg/driver/external/server/methods.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *DriverServer) SetConfig(_ context.Context, req *pb.SetConfigRequest) (*
6262
return &emptypb.Empty{}, err
6363
}
6464

65-
_ = s.driver.Configure(&inst, int(req.SshLocalPort))
65+
_ = s.driver.Configure(&inst)
6666

6767
return &emptypb.Empty{}, nil
6868
}

pkg/driver/qemu/qemu_driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ func New() *LimaQemuDriver {
6464
}
6565
}
6666

67-
func (l *LimaQemuDriver) Configure(inst *store.Instance, sshLocalPort int) *driver.ConfiguredDriver {
67+
func (l *LimaQemuDriver) Configure(inst *store.Instance) *driver.ConfiguredDriver {
6868
l.Instance = inst
69-
l.SSHLocalPort = sshLocalPort
69+
l.SSHLocalPort = inst.SSHLocalPort
7070

7171
return &driver.ConfiguredDriver{
7272
Driver: l,

pkg/driver/vz/vz_driver_darwin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ func New() *LimaVzDriver {
8787
}
8888
}
8989

90-
func (l *LimaVzDriver) Configure(inst *store.Instance, sshLocalPort int) *driver.ConfiguredDriver {
90+
func (l *LimaVzDriver) Configure(inst *store.Instance) *driver.ConfiguredDriver {
9191
l.Instance = inst
92-
l.SSHLocalPort = sshLocalPort
92+
l.SSHLocalPort = inst.SSHLocalPort
9393

9494
return &driver.ConfiguredDriver{
9595
Driver: l,

pkg/driver/wsl2/wsl_driver_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func New() *LimaWslDriver {
6868
}
6969
}
7070

71-
func (l *LimaWslDriver) Configure(inst *store.Instance, sshLocalPort int) *driver.ConfiguredDriver {
71+
func (l *LimaWslDriver) Configure(inst *store.Instance) *driver.ConfiguredDriver {
7272
l.Instance = inst
73-
l.SSHLocalPort = sshLocalPort
73+
l.SSHLocalPort = inst.SSHLocalPort
7474

7575
return &driver.ConfiguredDriver{
7676
Driver: l,

pkg/driverutil/instance.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func CreateConfiguredDriver(inst *store.Instance, sshLocalPort int) (*driver.Con
2222
return nil, fmt.Errorf("unknown or unsupported VM type: %s", *limaDriver)
2323
}
2424

25+
inst.SSHLocalPort = sshLocalPort
2526
if extDriver != nil {
2627
extDriver.Logger.Debugf("Using external driver %q", extDriver.Name)
2728
if extDriver.Client == nil || extDriver.Command == nil {
@@ -35,9 +36,9 @@ func CreateConfiguredDriver(inst *store.Instance, sshLocalPort int) (*driver.Con
3536
extDriver.InstanceName = inst.Name
3637
}
3738

38-
return extDriver.Client.Configure(inst, sshLocalPort), nil
39+
return extDriver.Client.Configure(inst), nil
3940
}
4041

4142
logrus.Debugf("Using internal driver %q", intDriver.Info().DriverName)
42-
return intDriver.Configure(inst, sshLocalPort), nil
43+
return intDriver.Configure(inst), nil
4344
}

pkg/registry/registry_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ func newMockDriver(name string) *mockDriver {
2727

2828
var _ driver.Driver = (*mockDriver)(nil)
2929

30-
func (m *mockDriver) Validate() error { return nil }
31-
func (m *mockDriver) Initialize(_ context.Context) error { return nil }
32-
func (m *mockDriver) CreateDisk(_ context.Context) error { return nil }
33-
func (m *mockDriver) Start(_ context.Context) (chan error, error) { return nil, nil }
34-
func (m *mockDriver) Stop(_ context.Context) error { return nil }
35-
func (m *mockDriver) RunGUI() error { return nil }
36-
func (m *mockDriver) ChangeDisplayPassword(_ context.Context, _ string) error { return nil }
37-
func (m *mockDriver) DisplayConnection(_ context.Context) (string, error) { return "", nil }
38-
func (m *mockDriver) CreateSnapshot(_ context.Context, _ string) error { return nil }
39-
func (m *mockDriver) ApplySnapshot(_ context.Context, _ string) error { return nil }
40-
func (m *mockDriver) DeleteSnapshot(_ context.Context, _ string) error { return nil }
41-
func (m *mockDriver) ListSnapshots(_ context.Context) (string, error) { return "", nil }
42-
func (m *mockDriver) Register(_ context.Context) error { return nil }
43-
func (m *mockDriver) Unregister(_ context.Context) error { return nil }
44-
func (m *mockDriver) ForwardGuestAgent() bool { return false }
45-
func (m *mockDriver) GuestAgentConn(_ context.Context) (net.Conn, string, error) { return nil, "", nil }
46-
func (m *mockDriver) Info() driver.Info { return driver.Info{DriverName: m.Name} }
47-
func (m *mockDriver) Configure(_ *store.Instance, _ int) *driver.ConfiguredDriver { return nil }
30+
func (m *mockDriver) Validate() error { return nil }
31+
func (m *mockDriver) Initialize(_ context.Context) error { return nil }
32+
func (m *mockDriver) CreateDisk(_ context.Context) error { return nil }
33+
func (m *mockDriver) Start(_ context.Context) (chan error, error) { return nil, nil }
34+
func (m *mockDriver) Stop(_ context.Context) error { return nil }
35+
func (m *mockDriver) RunGUI() error { return nil }
36+
func (m *mockDriver) ChangeDisplayPassword(_ context.Context, _ string) error { return nil }
37+
func (m *mockDriver) DisplayConnection(_ context.Context) (string, error) { return "", nil }
38+
func (m *mockDriver) CreateSnapshot(_ context.Context, _ string) error { return nil }
39+
func (m *mockDriver) ApplySnapshot(_ context.Context, _ string) error { return nil }
40+
func (m *mockDriver) DeleteSnapshot(_ context.Context, _ string) error { return nil }
41+
func (m *mockDriver) ListSnapshots(_ context.Context) (string, error) { return "", nil }
42+
func (m *mockDriver) Register(_ context.Context) error { return nil }
43+
func (m *mockDriver) Unregister(_ context.Context) error { return nil }
44+
func (m *mockDriver) ForwardGuestAgent() bool { return false }
45+
func (m *mockDriver) GuestAgentConn(_ context.Context) (net.Conn, string, error) { return nil, "", nil }
46+
func (m *mockDriver) Info() driver.Info { return driver.Info{DriverName: m.Name} }
47+
func (m *mockDriver) Configure(_ *store.Instance) *driver.ConfiguredDriver { return nil }
4848

4949
func TestRegister(t *testing.T) {
5050
BackupRegistry(t)

0 commit comments

Comments
 (0)