diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-04-25 08:30:43 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-04-27 09:46:11 +0200 |
commit | d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa (patch) | |
tree | 5f0ec8c9ad11a0f638c25dbd896a518e983dc779 /config | |
parent | afe35839eddfaf43be0f791e97a926a15d91fc02 (diff) | |
download | aerc-d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa.tar.gz |
refactor: refactor pgp implementation
This commit refactors the internal PGP implementation to make way for
GPG integration.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go index 048dd238..0c9a40fd 100644 --- a/config/config.go +++ b/config/config.go @@ -27,6 +27,7 @@ import ( type GeneralConfig struct { DefaultSavePath string `ini:"default-save-path"` + PgpProvider string `ini:"pgp-provider"` UnsafeAccountsConf bool `ini:"unsafe-accounts-conf"` } @@ -579,6 +580,21 @@ func validateBorderChars(section *ini.Section, config *UIConfig) error { return nil } +func validatePgpProvider(section *ini.Section) error { + m := map[string]bool{ + "internal": true, + } + for key, val := range section.KeysHash() { + switch key { + case "pgp-provider": + if !m[strings.ToLower(val)] { + return fmt.Errorf("%v must be 'internal'", key) + } + } + } + return nil +} + func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) { if root == nil { _root := path.Join(xdg.ConfigHome(), "aerc") @@ -618,6 +634,7 @@ func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) { Ini: file, General: GeneralConfig{ + PgpProvider: "internal", UnsafeAccountsConf: false, }, @@ -704,6 +721,9 @@ func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) { if err := ui.MapTo(&config.General); err != nil { return nil, err } + if err := validatePgpProvider(ui); err != nil { + return nil, err + } } filename = path.Join(*root, "accounts.conf") |