Creates pgp dir if it doesn't exist
This commit is contained in:
parent
4d8f3f0e79
commit
b22d99bf53
@ -2,12 +2,23 @@ package keyring
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/crypto/openpgp"
|
"golang.org/x/crypto/openpgp"
|
||||||
|
|
||||||
|
"mcquay.me/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewKeyPair(root, name, email string) error {
|
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)
|
e, err := openpgp.NewEntity(name, "pm", email, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.Wrap(err, "new entity")
|
errors.Wrap(err, "new entity")
|
||||||
|
Loading…
Reference in New Issue
Block a user