From d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 25 Apr 2022 08:30:43 -0500 Subject: refactor: refactor pgp implementation This commit refactors the internal PGP implementation to make way for GPG integration. Signed-off-by: Tim Culverhouse Acked-by: Koni Marti Acked-by: Robin Jarry --- config/config.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'config') 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") -- cgit