package cmd import ( "fmt" "os" "filippo.io/age" "filippo.io/age/agessh" "gopkg.in/yaml.v3" ) // Config is the configuration for git-age type Config map[string]Recipients type Recipients []string // Recipients parses age recipients from recipient strings func (r Recipients) Recipients() ([]age.Recipient, error) { var recipients []age.Recipient for _, rstr := range r { var rec age.Recipient rec, err := age.ParseX25519Recipient(rstr) if err != nil { if debug { fmt.Fprintf(os.Stderr, "could not parse recipient %q with age, trying ssh next: %v\n", rstr, err) } rec, err = agessh.ParseRecipient(rstr) if err != nil { return recipients, err } } recipients = append(recipients, rec) } return recipients, nil } // LoadConfig decodes .git-age.yaml into an AgeConfig func LoadConfig() (Config, error) { var cfg Config fi, err := os.Open(".git-age.yaml") if err != nil { return cfg, err } defer fi.Close() return cfg, yaml.NewDecoder(fi).Decode(&cfg) }