GODT-1779: Remove go-imap

This commit is contained in:
James Houlahan
2022-08-26 17:00:21 +02:00
parent 3b0bc1ca15
commit 39433fe707
593 changed files with 12725 additions and 91626 deletions

41
internal/vault/helper.go Normal file
View File

@ -0,0 +1,41 @@
package vault
import (
"encoding/json"
"errors"
"io/fs"
"os"
"path/filepath"
)
type Keychain struct {
Helper string
}
func GetHelper(vaultDir string) (string, error) {
var keychain Keychain
if _, err := os.Stat(filepath.Join(vaultDir, "keychain.json")); errors.Is(err, fs.ErrNotExist) {
return "", nil
}
b, err := os.ReadFile(filepath.Join(vaultDir, "keychain.json"))
if err != nil {
return "", err
}
if err := json.Unmarshal(b, &keychain); err != nil {
return "", err
}
return keychain.Helper, nil
}
func SetHelper(vaultDir, helper string) error {
b, err := json.MarshalIndent(Keychain{Helper: helper}, "", " ")
if err != nil {
return err
}
return os.WriteFile(filepath.Join(vaultDir, "keychain.json"), b, 0o600)
}