Skip to content

Commit

Permalink
machinedriver: Implement UpdateSSHConfig()
Browse files Browse the repository at this point in the history
This is a macadam-specific method. It's needed because crc generates a
new SSH key as part of its initial startup, and we need to update this
key in podman machine config.
  • Loading branch information
cfergeau committed Nov 27, 2024
1 parent 7cc42a0 commit 91fcf8f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/machinedriver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,18 @@ func (d *Driver) SSH() drivers.SSHConfig {
RemoteUsername: d.vmConfig.SSH.RemoteUsername,
}
}

func (d *Driver) UpdateSSHConfig(sshConfig drivers.SSHConfig) error {
d.vmConfig.Lock()
defer d.vmConfig.Unlock()

if err := d.vmConfig.Refresh(); err != nil {
return fmt.Errorf("reload config: %w", err)
}

d.vmConfig.SSH.Port = sshConfig.Port
d.vmConfig.SSH.IdentityPath = sshConfig.IdentityPath
d.vmConfig.SSH.RemoteUsername = sshConfig.RemoteUsername

return d.vmConfig.Write()
}

0 comments on commit 91fcf8f

Please sign in to comment.