Refactor GPG signer/verifier

Goal is to make it easier to plug in another implementation.
This commit is contained in:
Andrey Smirnov
2017-05-23 02:54:56 +03:00
parent c026106352
commit 1be8d39105
21 changed files with 135 additions and 110 deletions
+3 -3
View File
@@ -3,19 +3,19 @@ package cmd
import (
"strings"
"github.com/smira/aptly/utils"
"github.com/smira/aptly/pgp"
"github.com/smira/commander"
"github.com/smira/flag"
)
func getVerifier(flags *flag.FlagSet) (utils.Verifier, error) {
func getVerifier(flags *flag.FlagSet) (pgp.Verifier, error) {
if LookupOption(context.Config().GpgDisableVerify, flags, "ignore-signatures") {
return nil, nil
}
keyRings := flags.Lookup("keyring").Value.Get().([]string)
verifier := &utils.GpgVerifier{}
verifier := &pgp.GpgVerifier{}
for _, keyRing := range keyRings {
verifier.AddKeyring(keyRing)
}
+3 -3
View File
@@ -1,17 +1,17 @@
package cmd
import (
"github.com/smira/aptly/utils"
"github.com/smira/aptly/pgp"
"github.com/smira/commander"
"github.com/smira/flag"
)
func getSigner(flags *flag.FlagSet) (utils.Signer, error) {
func getSigner(flags *flag.FlagSet) (pgp.Signer, error) {
if LookupOption(context.Config().GpgDisableSign, flags, "skip-signing") {
return nil, nil
}
signer := &utils.GpgSigner{}
signer := &pgp.GpgSigner{}
signer.SetKey(flags.Lookup("gpg-key").Value.String())
signer.SetKeyRing(flags.Lookup("keyring").Value.String(), flags.Lookup("secret-keyring").Value.String())
signer.SetPassphrase(flags.Lookup("passphrase").Value.String(), flags.Lookup("passphrase-file").Value.String())
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb"
"github.com/smira/aptly/pgp"
"github.com/smira/aptly/utils"
"github.com/smira/commander"
"github.com/smira/flag"
@@ -20,7 +21,7 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
name := args[0]
verifier := &utils.GpgVerifier{}
verifier := &pgp.GpgVerifier{}
repo, err := context.CollectionFactory().LocalRepoCollection().ByName(name)
if err != nil {
+2 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb"
"github.com/smira/aptly/pgp"
"github.com/smira/aptly/query"
"github.com/smira/aptly/utils"
"github.com/smira/commander"
@@ -28,7 +29,7 @@ func aptlyRepoInclude(cmd *commander.Command, args []string) error {
}
if verifier == nil {
verifier = &utils.GpgVerifier{}
verifier = &pgp.GpgVerifier{}
}
forceReplace := context.Flags().Lookup("force-replace").Value.Get().(bool)