package config import ( "fmt" "strings" "filippo.io/age" "filippo.io/age/agessh" ) // ParseBackupRecipients reads backup_recipients: age recipients, or SSH // public keys. func ParseBackupRecipients(list []string) ([]age.Recipient, error) { var out []age.Recipient for i, s := range list { s = strings.TrimSpace(s) if strings.HasPrefix(s, "ssh-") { r, err := agessh.ParseRecipient(s) if err != nil { return nil, fmt.Errorf("backup_recipients[%d]: %w", i, err) } out = append(out, r) continue } rs, err := age.ParseRecipients(strings.NewReader(s)) if err != nil || len(rs) != 1 { return nil, fmt.Errorf("backup_recipients[%d] is not an age recipient (age1…) or an SSH public key", i) } out = append(out, rs[0]) } return out, nil }