Skip to content

Conversation

@zampani-docker
Copy link

Summary

Implements a new docker whoami command that displays the username of the currently logged-in user for Docker registries.

Features

  • Display username for Docker Hub by default (when no registry is specified)
  • Support specifying a custom registry as an argument: docker whoami [SERVER]
  • Add --all flag to list all authenticated registries with usernames
  • Proper error handling for non-authenticated registries
  • Follows existing patterns from docker login and docker logout commands

Implementation Details

  • Added cli/command/registry/whoami.go with main implementation
  • Added cli/command/registry/whoami_test.go with comprehensive test coverage (13 test cases)
  • All existing tests pass (2365 tests)
  • Command appears in help output with appropriate category ordering

Usage Examples

# Show username for Docker Hub
docker whoami

# Show username for a specific registry
docker whoami custom.registry.com

# List all authenticated registries with usernames
docker whoami --all

# Show help
docker whoami --help

Test Coverage

  • Not logged in scenarios (Docker Hub and custom registries)
  • Logged in scenarios (Docker Hub and custom registries)
  • --all flag functionality
  • Registry address normalization (with/without protocol, with port)
  • Docker.io alias handling
  • Empty username handling
  • DOCKER_AUTH_CONFIG environment variable warning

🤖 Generated with Claude Code

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 61.70213% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/command/registry/whoami.go 61.70% 16 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@thaJeztah
Copy link
Member

Thanks for contributing; I'm not sure if we should add this though, currently; there's work in progress to rewrite all authentication, and as part of that the way credentials are stored (and used) may be updated in the (near) future.

@Benehiko may be able to fill me in on some of that, but it's probably better to keep the status quo for now until that work is completed.

Add a new 'docker whoami' command that displays the username of the
currently logged-in user for Docker registries. The command follows
existing patterns from login/logout commands.

Features:
- Display username for Docker Hub by default
- Support specifying a custom registry as an argument
- Add --all flag to list all authenticated registries with usernames
- Proper error handling for non-authenticated registries
- Comprehensive test coverage with 13 test cases

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants