PR suggestions
This commit is contained in:
parent
4a8047ed61
commit
bb6db4b309
1 changed files with 11 additions and 14 deletions
|
|
@ -277,23 +277,20 @@ func selectSSHKeys(
|
|||
return autoKeyPair, true, nil
|
||||
}
|
||||
|
||||
configKeyPair, err := firstConfiguredKeyPair(ctx, customConfigPath, opts.profile)
|
||||
if err != nil && !errors.Is(err, errKeyFileNotFound) {
|
||||
return nil, false, fmt.Errorf("checking configured keys: %w", err)
|
||||
}
|
||||
|
||||
// Even if there was no error, there may simply be no configured keys, so still check for nil here
|
||||
if configKeyPair != nil {
|
||||
return configKeyPair, true, nil
|
||||
}
|
||||
|
||||
// Finally, fall back to generating new automatic keys
|
||||
autoKeyPair, err := generateAutomaticSSHKeys(sshContext)
|
||||
keyPair, err := firstConfiguredKeyPair(ctx, customConfigPath, opts.profile)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("generating automatic keypair: %w", err)
|
||||
if !errors.Is(err, errKeyFileNotFound) {
|
||||
return nil, false, fmt.Errorf("checking configured keys: %w", err)
|
||||
}
|
||||
|
||||
// no valid key in ssh config, generate one
|
||||
keyPair, err = generateAutomaticSSHKeys(sshContext)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("generating automatic keypair: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return autoKeyPair, true, nil
|
||||
return keyPair, true, nil
|
||||
}
|
||||
|
||||
// automaticSSHKeyPair returns the paths to the automatic key pair files, if they both exist
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue