Creates pgp dir if it doesn't exist

This commit is contained in:
Stephen McQuay 2018-02-25 01:52:57 -08:00
parent 4d8f3f0e79
commit b22d99bf53
Signed by untrusted user: sm
GPG Key ID: 4E4B72F479BA3CE5

View File

@ -2,12 +2,23 @@ package keyring
import (
"log"
"os"
"path/filepath"
"github.com/pkg/errors"
"golang.org/x/crypto/openpgp"
"mcquay.me/fs"
)
func NewKeyPair(root, name, email string) error {
pgpDir := filepath.Join(root, "var", "lib", "pm", "pgp")
if !fs.Exists(pgpDir) {
if err := os.MkdirAll(pgpDir, 0755); err != nil {
return errors.Wrap(err, "mk pgp dir")
}
}
e, err := openpgp.NewEntity(name, "pm", email, nil)
if err != nil {
errors.Wrap(err, "new entity")