From 302f738beab532350102d66dddeea377377d1f05 Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Tue, 27 Feb 2018 18:24:41 -0800 Subject: [PATCH] pkg shouldn't have to search for keys --- cmd/pm/main.go | 6 +++++- pkg/pkg.go | 13 +++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/pm/main.go b/cmd/pm/main.go index 1aea055..3b549cd 100644 --- a/cmd/pm/main.go +++ b/cmd/pm/main.go @@ -153,7 +153,11 @@ func main() { fatalf("usage: pm package create \n") } dir := args[0] - if err := pkg.Create(root, signID, dir); err != nil { + e, err := keyring.FindSecretEntity(root, signID) + if err != nil { + fatalf("find secret key: %v\n", err) + } + if err := pkg.Create(e, dir); err != nil { fatalf("creating package: %v\n", err) } default: diff --git a/pkg/pkg.go b/pkg/pkg.go index ee57e0d..891a5a7 100644 --- a/pkg/pkg.go +++ b/pkg/pkg.go @@ -2,25 +2,18 @@ package pkg import ( "fmt" - "log" - "github.com/pkg/errors" + "golang.org/x/crypto/openpgp" "mcquay.me/fs" - "mcquay.me/pm/keyring" ) // Create traverses the contents of dir and emits a valid pkg, signed by id -func Create(root, id, dir string) error { +func Create(e *openpgp.Entity, dir string) error { if !fs.Exists(dir) { return fmt.Errorf("%q: doesn't exist", dir) } if !fs.IsDir(dir) { return fmt.Errorf("%q: is not a directory", dir) } - e, err := keyring.FindSecretEntity(dir, id) - if err != nil { - return errors.Wrap(err, "find secret key") - } - log.Printf("found key: %v", e.PrimaryKey.KeyIdShortString()) - return fmt.Errorf("creating package from %q for %q: NYI", dir, id) + return fmt.Errorf("creating package from %q for %q: NYI", dir, e.PrimaryKey.KeyIdShortString()) }