From eab6e5a317acf67409f82bc5c1f4d959413dfd47 Mon Sep 17 00:00:00 2001
From: ligi <ligi@ligi.de>
Date: Wed, 9 May 2018 01:13:53 +0200
Subject: build: specify the key to use when invoking gpg:sign-and-deploy-file
 (#16696)

---
 internal/build/pgp.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'internal')

diff --git a/internal/build/pgp.go b/internal/build/pgp.go
index 79ab9c06f..c7d0d2339 100644
--- a/internal/build/pgp.go
+++ b/internal/build/pgp.go
@@ -57,3 +57,15 @@ func PGPSignFile(input string, output string, pgpkey string) error {
 	// Generate the signature and return
 	return openpgp.ArmoredDetachSign(out, keys[0], in, nil)
 }
+
+// PGPKeyID parses an armored key and returns the key ID.
+func PGPKeyID(pgpkey string) (string, error) {
+	keys, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(pgpkey))
+	if err != nil {
+		return "", err
+	}
+	if len(keys) != 1 {
+		return "", fmt.Errorf("key count mismatch: have %d, want %d", len(keys), 1)
+	}
+	return keys[0].PrimaryKey.KeyIdString(), nil
+}
-- 
cgit v1.2.3