Skip to content

Commit

Permalink
Merge pull request #667 from seberm/feature/add-gpg-command-into-config
Browse files Browse the repository at this point in the history
Add possibility to configure GPG cli command in config file
  • Loading branch information
twpayne committed Apr 13, 2020
2 parents ecb873b + 2fca0ae commit f89a8c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func newConfig(options ...configOption) *Config {
Merge: mergeConfig{
Command: "vimdiff",
},
GPG: chezmoi.GPG{
Command: "gpg",
},
maxDiffDataSize: 1 * 1024 * 1024, // 1MB
templateFuncs: sprig.TxtFuncMap(),
scriptStateBucket: []byte("script"),
Expand Down
1 change: 1 addition & 0 deletions cmd/docs.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ The following configuration variables are available:
| `follow` | bool | `false` | Follow symlinks |
| `genericSecret.command` | string | *none* | Generic secret command |
| `gopass.command` | string | `gopass` | gopass CLI command |
| `gpg.command` | string | `gpg` | GPG CLI command |
| `gpg.recipient` | string | *none* | GPG recipient |
| `gpg.symmetric` | bool | `false` | Use symmetric GPG encryption |
| `keepassxc.args` | []string | *none* | Extra args to KeePassXC CLI command |
Expand Down
8 changes: 6 additions & 2 deletions internal/chezmoi/gpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

// GPG interfaces with gpg.
type GPG struct {
Command string
Recipient string
Symmetric bool
}
Expand All @@ -28,8 +29,9 @@ func (g *GPG) Decrypt(filename string, ciphertext []byte) ([]byte, error) {
return nil, err
}

//nolint:gosec
cmd := exec.Command(
"gpg",
g.Command,
"--output", outputFilename,
"--quiet",
"--decrypt", inputFilename,
Expand Down Expand Up @@ -73,7 +75,9 @@ func (g *GPG) Encrypt(filename string, plaintext []byte) ([]byte, error) {
args = append(args, "--encrypt")
}
args = append(args, filename)
cmd := exec.Command("gpg", args...)

//nolint:gosec
cmd := exec.Command(g.Command, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down

0 comments on commit f89a8c3

Please sign in to comment.