Support for --passphrase & --passphrase-file arguments on publishing. #94

This commit is contained in:
Andrey Smirnov
2014-09-01 15:13:07 +04:00
parent f01ac06d97
commit 97158ef37b
11 changed files with 65 additions and 2 deletions
+17 -2
View File
@@ -17,6 +17,7 @@ type Signer interface {
Init() error
SetKey(keyRef string)
SetKeyRing(keyring, secretKeyring string)
SetPassphrase(passphrase, passphraseFile string)
DetachedSign(source string, destination string) error
ClearSign(source string, destination string) error
}
@@ -38,8 +39,9 @@ var (
// GpgSigner is implementation of Signer interface using gpg
type GpgSigner struct {
keyRef string
keyring, secretKeyring string
keyRef string
keyring, secretKeyring string
passphrase, passphraseFile string
}
// SetKey sets key ID to use when signing files
@@ -52,6 +54,11 @@ func (g *GpgSigner) SetKeyRing(keyring, secretKeyring string) {
g.keyring, g.secretKeyring = keyring, secretKeyring
}
// SetPassphrase sets passhprase params
func (g *GpgSigner) SetPassphrase(passphrase, passphraseFile string) {
g.passphrase, g.passphraseFile = passphrase, passphraseFile
}
func (g *GpgSigner) gpgArgs() []string {
args := []string{}
if g.keyring != "" {
@@ -65,6 +72,14 @@ func (g *GpgSigner) gpgArgs() []string {
args = append(args, "-u", g.keyRef)
}
if g.passphrase != "" {
args = append(args, "--passphrase", g.passphrase)
}
if g.passphraseFile != "" {
args = append(args, "--passphrase-file", g.passphraseFile)
}
return args
}