shell_command.go 626 B

12345678910111213141516171819202122232425262728
  1. package credentials
  2. import (
  3. "io"
  4. "os/exec"
  5. )
  6. func shellCommandFn(storeName string) func(args ...string) command {
  7. name := remoteCredentialsPrefix + storeName
  8. return func(args ...string) command {
  9. return &shell{cmd: exec.Command(name, args...)}
  10. }
  11. }
  12. // shell invokes shell commands to talk with a remote credentials helper.
  13. type shell struct {
  14. cmd *exec.Cmd
  15. }
  16. // Output returns responses from the remote credentials helper.
  17. func (s *shell) Output() ([]byte, error) {
  18. return s.cmd.Output()
  19. }
  20. // Input sets the input to send to a remote credentials helper.
  21. func (s *shell) Input(in io.Reader) {
  22. s.cmd.Stdin = in
  23. }