MCPcopy Index your code
hub / github.com/getsops/sops / gpgExec

Function gpgExec

pgp/keysource.go:625–636  ·  view source on GitHub ↗

gpgExec runs the provided args with the gpgBinary, while restricting it to homeDir when provided. Stdout and stderr can be read from the returned buffers. When the command fails, an error is returned.

(ctx context.Context, homeDir string, args []string, stdin io.Reader)

Source from the content-addressed store, hash-verified

623// homeDir when provided. Stdout and stderr can be read from the returned
624// buffers. When the command fails, an error is returned.
625func gpgExec(ctx context.Context, homeDir string, args []string, stdin io.Reader) (stdout bytes.Buffer, stderr bytes.Buffer, err error) {
626 if homeDir != "" {
627 args = append([]string{"--homedir", homeDir}, args...)
628 }
629
630 cmd := exec.CommandContext(ctx, gpgBinary(), args...)
631 cmd.Stdin = stdin
632 cmd.Stdout = &stdout
633 cmd.Stderr = &stderr
634 err = cmd.Run()
635 return
636}
637
638// gpgBinary returns the GnuPG binary which must be used.
639// It allows for runtime modifications by setting the replacement binary

Callers 8

ImportContextMethod · 0.85
encryptWithGnuPGMethod · 0.85
decryptWithGnuPGMethod · 0.85
TestGnuPGHome_ImportFunction · 0.85
TestMasterKey_DecryptFunction · 0.85

Calls 1

gpgBinaryFunction · 0.85

Tested by 5

TestGnuPGHome_ImportFunction · 0.68
TestMasterKey_DecryptFunction · 0.68