pkg shouldn't have to search for keys

This commit is contained in:
Stephen McQuay 2018-02-27 18:24:41 -08:00
parent 344148be2d
commit 302f738bea
Signed by untrusted user: sm
GPG Key ID: 4E4B72F479BA3CE5
2 changed files with 8 additions and 11 deletions

View File

@ -153,7 +153,11 @@ func main() {
fatalf("usage: pm package create <directory>\n") fatalf("usage: pm package create <directory>\n")
} }
dir := args[0] 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) fatalf("creating package: %v\n", err)
} }
default: default:

View File

@ -2,25 +2,18 @@ package pkg
import ( import (
"fmt" "fmt"
"log"
"github.com/pkg/errors" "golang.org/x/crypto/openpgp"
"mcquay.me/fs" "mcquay.me/fs"
"mcquay.me/pm/keyring"
) )
// Create traverses the contents of dir and emits a valid pkg, signed by id // 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) { if !fs.Exists(dir) {
return fmt.Errorf("%q: doesn't exist", dir) return fmt.Errorf("%q: doesn't exist", dir)
} }
if !fs.IsDir(dir) { if !fs.IsDir(dir) {
return fmt.Errorf("%q: is not a directory", dir) return fmt.Errorf("%q: is not a directory", dir)
} }
e, err := keyring.FindSecretEntity(dir, id) return fmt.Errorf("creating package from %q for %q: NYI", dir, e.PrimaryKey.KeyIdShortString())
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)
} }