Skip to content

Commit

Permalink
Propagate GPG error message to the user (#1700)
Browse files Browse the repository at this point in the history
Fixes #1694

RELEASE_NOTES=[ENHANCEMENT] Show GPG --gen-key error to the user

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz authored Jan 12, 2021
1 parent 86d1594 commit 926c902
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/backend/crypto/gpg/cli/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ Expire-Date: 0
args := []string{"--batch", "--gen-key"}
cmd := exec.CommandContext(ctx, g.binary, args...)
cmd.Stdin = bytes.NewReader(buf.Bytes())
cmd.Stdout = nil
cmd.Stderr = nil

out := &bytes.Buffer{}
cmd.Stdout = out
cmd.Stderr = out

debug.Log("%s %+v", cmd.Path, cmd.Args)
if err := cmd.Run(); err != nil {
return errors.Wrapf(err, "failed to run command: '%s %+v'", cmd.Path, cmd.Args)
return errors.Wrapf(err, "failed to run command: '%s %+v': %q", cmd.Path, cmd.Args, out.String())
}
g.privKeys = nil
g.pubKeys = nil
Expand Down

0 comments on commit 926c902

Please sign in to comment.