Skip to content

Commit 283d362

Browse files
author
Chris Every
authored
Merge pull request #165 from ovotech/armoured-keyring-path
Make armoured keyring configurable
2 parents f5ecdac + 8a13d28 commit 283d362

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

pkg/cred/creds.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Credentials struct {
1919
CircleCIAPIToken string
2020
GitAccount GitAccount
2121
AkrPass string
22+
AkrPath string
2223
KmsKey string
2324
GocdServer GocdServer
2425
}

pkg/crypt/crypt.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,17 @@ func EncryptedServiceAccountKey(key, kmsKey string) (encKey []byte) {
3535
//CommitSignKey creates an openPGP Entity based on a user's name, email,
3636
//armoredKeyRing and passphrase for the key ring. This commitSignKey can then
3737
//be used to GPG sign Git commits
38-
func CommitSignKey(name, email, passphrase string) (entity *openpgp.Entity,
38+
func CommitSignKey(name, email, passphrase, path string) (entity *openpgp.Entity,
3939
err error) {
40-
if passphrase == "" {
40+
if len(passphrase) == 0 {
4141
err = errors.New("ArmouredKeyRing passphrase must not be empty")
4242
return
4343
}
44+
if len(path) == 0 {
45+
path = "/etc/cloud-key-rotator/akr.asc"
46+
}
4447
var reader *os.File
45-
if reader, err = os.Open("/etc/cloud-key-rotator/akr.asc"); err != nil {
48+
if reader, err = os.Open(path); err != nil {
4649
if reader, err = os.Open("./akr.asc"); err != nil {
4750
return
4851
}

pkg/location/git.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (git Git) Write(serviceAccountName string, keyWrapper KeyWrapper, creds cre
5656
defer os.RemoveAll(localDir)
5757

5858
var signKey *openpgp.Entity
59-
if signKey, err = crypt.CommitSignKey(creds.GitAccount.GitName, creds.GitAccount.GitEmail, creds.AkrPass); err != nil {
59+
if signKey, err = crypt.CommitSignKey(creds.GitAccount.GitName, creds.GitAccount.GitEmail, creds.AkrPass, creds.AkrPath); err != nil {
6060
return
6161
}
6262

0 commit comments

Comments
 (0)