Avoid empty SSH keys on applehv

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2023-11-13 13:07:35 -06:00
parent 24bf08e97e
commit ea89eaa1c1

@ -251,6 +251,14 @@ func (m *MacMachine) Init(opts machine.InitOptions) (bool, error) {
return false, err return false, err
} }
if len(opts.IgnitionPath) < 1 {
key, err = machine.CreateSSHKeys(m.IdentityPath)
if err != nil {
return false, err
}
callbackFuncs.Add(m.removeSSHKeys)
}
builder := machine.NewIgnitionBuilder(machine.DynamicIgnition{ builder := machine.NewIgnitionBuilder(machine.DynamicIgnition{
Name: opts.Username, Name: opts.Username,
Key: key, Key: key,
@ -262,14 +270,6 @@ func (m *MacMachine) Init(opts machine.InitOptions) (bool, error) {
Rootful: m.Rootful, Rootful: m.Rootful,
}) })
if len(opts.IgnitionPath) < 1 {
key, err = machine.CreateSSHKeys(m.IdentityPath)
if err != nil {
return false, err
}
callbackFuncs.Add(m.removeSSHKeys)
}
if len(opts.IgnitionPath) > 0 { if len(opts.IgnitionPath) > 0 {
return false, builder.BuildWithIgnitionFile(opts.IgnitionPath) return false, builder.BuildWithIgnitionFile(opts.IgnitionPath)
} }