Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 77d07c5

Browse files
author
Alexis Bouchez
committed
fix(auth): repair docker login
1 parent f4fd40b commit 77d07c5

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

commands/auth/login.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"encoding/json"
88
"errors"
99
"fmt"
10-
"io"
1110
stdHTTP "net/http"
1211
"os"
1312
"os/exec"
@@ -215,34 +214,15 @@ func authenticateDockerRegistry(apiKey string) (err error) {
215214
defer cancel()
216215

217216
var out bytes.Buffer
218-
cmd := exec.CommandContext(ctx, binary, "login", "--username=x", "--password-stdin", registryHost)
217+
cmd := exec.CommandContext(ctx, binary, "login", "--username=x", "--password", apiKey, registryHost)
219218
cmd.Stdout = &out
220219
cmd.Stderr = &out
221220

222-
// Set up standard input for the `docker login` command.
223-
var in io.WriteCloser
224-
if in, err = cmd.StdinPipe(); err != nil {
225-
return err
226-
}
227-
228-
// This defer is for early-returns before successfully writing to the stream, hence safe.
229-
defer func() {
230-
if in != nil {
231-
in.Close()
232-
}
233-
}()
234-
235221
// Start the command (without stopping it, yet).
236222
if err = cmd.Start(); err != nil {
237223
return
238224
}
239225

240-
// Pass the API Key to the stdin.
241-
_, err = fmt.Fprint(in, apiKey)
242-
if err != nil {
243-
return err
244-
}
245-
246226
// Wait for the `docker login` command to be completed
247227
if err = cmd.Wait(); err != nil {
248228
return fmt.Errorf("failed authenticating with %s: %v", registryHost, out.String())

0 commit comments

Comments
 (0)