Skip to content

Commit 68eaf11

Browse files
committed
refactor: pass key to loadAgeSSHIdentities
Signed-off-by: Nate Scherer <376408+natescherer@users.noreply.github.com>
1 parent c75577f commit 68eaf11

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

age/keysource.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func getOutputFromCmd(cmdString string, envVars []string) ([]byte, error) {
321321
// SopsAgeSshPrivateKeyCmdEnv environment variable
322322
// 3. `~/.ssh/id_ed25519` or `~/.ssh/id_rsa`.
323323
// If no age SSH identity is found, it will return nil.
324-
func loadAgeSSHIdentities() ([]age.Identity, []string, errSet) {
324+
func loadAgeSSHIdentities(key *MasterKey) ([]age.Identity, []string, errSet) {
325325
var identities []age.Identity
326326
var unusedLocations []string
327327
var errs errSet
@@ -340,8 +340,7 @@ func loadAgeSSHIdentities() ([]age.Identity, []string, errSet) {
340340

341341
sshKeyCmd, ok := os.LookupEnv(SopsAgeSshPrivateKeyCmdEnv)
342342
if ok {
343-
ageRecipient, _ := os.LookupEnv(SopsAgeRecipientEnv)
344-
out, err := getOutputFromCmd(sshKeyCmd, []string{fmt.Sprintf("%s=%s", SopsAgeRecipientEnv, ageRecipient)})
343+
out, err := getOutputFromCmd(sshKeyCmd, []string{fmt.Sprintf("%s=%s", SopsAgeRecipientEnv, key.Recipient)})
345344
if err != nil {
346345
errs = append(errs, err)
347346
} else {
@@ -404,7 +403,7 @@ func getUserConfigDir() (string, error) {
404403
// SopsAgeSshPrivateKeyFileEnv, SopsAgeKeyUserConfigPath). It will load all
405404
// found references, and expects at least one configuration to be present.
406405
func (key *MasterKey) loadIdentities() (ParsedIdentities, []string, errSet) {
407-
identities, unusedLocations, errs := loadAgeSSHIdentities()
406+
identities, unusedLocations, errs := loadAgeSSHIdentities(key)
408407

409408
var readers = make(map[string]io.Reader, 0)
410409

0 commit comments

Comments
 (0)