Skip to content

Commit

Permalink
Merge pull request #219 from astronomer/windows-astro-auth-login-issue
Browse files Browse the repository at this point in the history
Astro CLI for Windows error authenticating #211
  • Loading branch information
schnie committed May 14, 2019
2 parents 87c63c1 + bc35690 commit 32e477e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions docker/docker.go
@@ -1,7 +1,8 @@
package docker

import (
"fmt"
"io"
"log"
"os"
"os/exec"

Expand Down Expand Up @@ -40,14 +41,24 @@ func ExecLogin(registry, username, password string) error {
panic(lookErr)
}

loginCmd := fmt.Sprintf("echo '%s' | docker login %s -u %s --password-stdin", password, registry, username)
cmd := exec.Command("/usr/bin/env", "sh", "-c", loginCmd)
cmd := exec.Command("docker", "login", registry, "-u", username, "--password-stdin")
stdin, err := cmd.StdinPipe()
if err != nil {
log.Fatal(err)
}

go func() {
defer stdin.Close()
io.WriteString(stdin, password)
}()

_, err = cmd.CombinedOutput()

cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr

return cmd.Run()
return err
}

// AirflowCommand is the main method of interaction with Airflow
Expand Down

0 comments on commit 32e477e

Please sign in to comment.