From 344148be2d995b78ecfa32adc404e9774bd7bf2e Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Mon, 26 Feb 2018 20:07:47 -0800 Subject: [PATCH] Stub out fetching secret key entity --- cmd/pm/main.go | 2 +- keyring/keyring.go | 5 +++++ pkg/pkg.go | 10 +++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/pm/main.go b/cmd/pm/main.go index 53ecc96..1aea055 100644 --- a/cmd/pm/main.go +++ b/cmd/pm/main.go @@ -153,7 +153,7 @@ func main() { fatalf("usage: pm package create \n") } dir := args[0] - if err := pkg.Create(dir, signID); err != nil { + if err := pkg.Create(root, signID, dir); err != nil { fatalf("creating package: %v\n", err) } default: diff --git a/keyring/keyring.go b/keyring/keyring.go index 2fffb94..f8c32b1 100644 --- a/keyring/keyring.go +++ b/keyring/keyring.go @@ -328,3 +328,8 @@ func findKey(el openpgp.EntityList, id string) (*openpgp.Entity, error) { } return e, fmt.Errorf("key %q not found", id) } + +// FindSecretEntity searches for id in the secret keyring. +func FindSecretEntity(root, id string) (*openpgp.Entity, error) { + return nil, errors.New("NYI") +} diff --git a/pkg/pkg.go b/pkg/pkg.go index 62b4e68..ee57e0d 100644 --- a/pkg/pkg.go +++ b/pkg/pkg.go @@ -2,17 +2,25 @@ package pkg import ( "fmt" + "log" + "github.com/pkg/errors" "mcquay.me/fs" + "mcquay.me/pm/keyring" ) // Create traverses the contents of dir and emits a valid pkg, signed by id -func Create(dir, id string) error { +func Create(root, id, 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) }