Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 9a3d3a7

Browse files
authored
Merge pull request #715 from docker/fix_docker_login
Fix regression: let users login to local registry (no ‘.’ In registry name)
2 parents abd6af6 + 6d0f7f3 commit 9a3d3a7

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

cli/cmd/login/login.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ package login
1919
import (
2020
"context"
2121
"fmt"
22-
"strings"
23-
24-
"github.com/docker/compose-cli/cli/cmd/mobyflags"
2522

2623
"github.com/pkg/errors"
2724
"github.com/spf13/cobra"
2825

2926
"github.com/docker/compose-cli/api/client"
27+
"github.com/docker/compose-cli/cli/cmd/mobyflags"
3028
"github.com/docker/compose-cli/cli/mobycli"
3129
"github.com/docker/compose-cli/errdefs"
3230
)
@@ -52,10 +50,6 @@ func Command() *cobra.Command {
5250
}
5351

5452
func runLogin(cmd *cobra.Command, args []string) error {
55-
if len(args) == 1 && !strings.Contains(args[0], ".") {
56-
backend := args[0]
57-
return errors.New("unknown backend type for cloud login: " + backend)
58-
}
5953
mobycli.Exec(cmd.Root())
6054
return nil
6155
}

tests/e2e/e2e_test.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,30 @@ func TestLoginCommandDelegation(t *testing.T) {
205205
})
206206
})
207207

208+
t.Run("localhost registry interactive", func(t *testing.T) {
209+
res := c.RunDockerOrExitError("login", "localhost:443")
210+
res.Assert(t, icmd.Expected{
211+
ExitCode: 1,
212+
Err: "Cannot perform an interactive login from a non TTY device",
213+
})
214+
})
215+
216+
t.Run("localhost registry", func(t *testing.T) {
217+
res := c.RunDockerOrExitError("login", "localhost", "-u", "user", "-p", "password")
218+
res.Assert(t, icmd.Expected{
219+
ExitCode: 1,
220+
Err: "http://localhost/v2/",
221+
})
222+
})
223+
208224
t.Run("logout", func(t *testing.T) {
209225
res := c.RunDockerCmd("logout", "someregistry.docker.io")
210-
res.Assert(t, icmd.Expected{Out: "someregistry.docker.io"})
226+
res.Assert(t, icmd.Expected{Out: "Removing login credentials for someregistry.docker.io"})
227+
})
228+
229+
t.Run("logout", func(t *testing.T) {
230+
res := c.RunDockerCmd("logout", "localhost:443")
231+
res.Assert(t, icmd.Expected{Out: "Removing login credentials for localhost:443"})
211232
})
212233

213234
t.Run("existing context", func(t *testing.T) {
@@ -221,18 +242,6 @@ func TestLoginCommandDelegation(t *testing.T) {
221242
})
222243
}
223244

224-
func TestCloudLogin(t *testing.T) {
225-
c := NewParallelE2eCLI(t, binDir)
226-
227-
t.Run("unknown backend", func(t *testing.T) {
228-
res := c.RunDockerOrExitError("login", "mycloudbackend")
229-
res.Assert(t, icmd.Expected{
230-
ExitCode: 1,
231-
Err: "unknown backend type for cloud login: mycloudbackend",
232-
})
233-
})
234-
}
235-
236245
func TestMissingExistingCLI(t *testing.T) {
237246
t.Parallel()
238247
home, err := ioutil.TempDir("", "")

0 commit comments

Comments
 (0)