Skip to content

Commit

Permalink
feat(other): use docker hub if registry address not specified in `wer…
Browse files Browse the repository at this point in the history
…f cr`

Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
  • Loading branch information
alexey-igrychev committed May 30, 2024
1 parent c421962 commit 661f357
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions cmd/werf/cr/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,18 @@ werf cr login --insecure-registry registry.example.com`,
return err
}

if len(args) != 1 {
var registry string
switch {
case len(args) == 0:
registry = "https://index.docker.io/v1/"
case len(args) == 1:
registry = args[0]
default: // len(args) > 1
common.PrintHelp(cmd)
return fmt.Errorf("registry address argument required")
return fmt.Errorf("invalid number of arguments, expected optional registry address: got %d arguments", len(args))
}

return Login(ctx, args[0], LoginOptions{
return Login(ctx, registry, LoginOptions{
Username: cmdData.Username,
Password: cmdData.Password,
PasswordStdin: cmdData.PasswordStdin,
Expand Down
12 changes: 9 additions & 3 deletions cmd/werf/cr/logout/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ func NewCmd(ctx context.Context) *cobra.Command {
return err
}

if len(args) != 1 {
var registry string
switch {
case len(args) == 0:
registry = "https://index.docker.io/v1/"
case len(args) == 1:
registry = args[0]
default: // len(args) > 1
common.PrintHelp(cmd)
return fmt.Errorf("registry address argument required")
return fmt.Errorf("invalid number of arguments, expected optional registry address: got %d arguments", len(args))
}

return Logout(ctx, args[0], LogoutOptions{
return Logout(ctx, registry, LogoutOptions{
DockerConfigDir: *commonCmdData.DockerConfig,
})
},
Expand Down

0 comments on commit 661f357

Please sign in to comment.