fix: properly pass in password to docker login command

This commit is contained in:
Jose Diaz-Gonzalez committed 2021-08-05 01:12:10 -04:00
1 parent c07b3161fc
commit 13608df0ef
1 file changed
+5 -4
+5 -4
View File
@@ -1,8 +1,8 @@
package registry package registry
import ( import (
"bytes"
"errors" "errors"
"io"
"io/ioutil" "io/ioutil"
"os" "os"
"strings" "strings"
@@ -40,10 +40,11 @@ func CommandLogin(server string, username string, password string, passwordStdin
server, server,
} }
reader, writer := io.Pipe() buffer := bytes.Buffer{}
writer.Write([]byte(password)) buffer.Write([]byte(password + "\n"))
loginCmd := common.NewShellCmd(strings.Join(command, " ")) loginCmd := common.NewShellCmd(strings.Join(command, " "))
loginCmd.Command.Stdin = reader loginCmd.Command.Stdin = &buffer
if !loginCmd.Execute() { if !loginCmd.Execute() {
return errors.New("Failed to log into registry") return errors.New("Failed to log into registry")
} }