Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
## Bug Fixes
- Custom `base_image` values are now explicitly rejected with an error rather than silently ignored, providing clearer feedback when unsupported configuration options are supplied.

## Other Changes
- Updated CLI documentation to remove references to non-existent commands and add documentation for previously undocumented ones.
Add improvements/clarity to user facing CLI output.
2 changes: 1 addition & 1 deletion dispatch_cli/auth_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def _fetch_organizations(self, access_token: str) -> list[AuthOrganization]:
def _select_organization(self, organizations: list[AuthOrganization]) -> str:
choices = [
questionary.Choice(
title=f"{organization.display_name} ({organization.id})",
title=organization.display_name,
value=organization.id,
)
for organization in organizations
Expand Down
14 changes: 4 additions & 10 deletions dispatch_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ def login(
logger.success("Logged in with browser auth")
if session.user_email:
logger.info(f"User: {session.user_email}")
if session.org_display_name and session.org_id:
logger.info(f"Organization: {session.org_display_name} ({session.org_id})")
elif session.org_id:
logger.info(f"Organization: {session.org_id}")
if session.org_display_name:
logger.info(f"Organization: {session.org_display_name}")


@app.command()
Expand Down Expand Up @@ -169,12 +167,8 @@ def whoami():

if credential.user_email:
logger.info(f"User: {credential.user_email}")
if credential.org_display_name and credential.org_id:
logger.info(
f"Organization: {credential.org_display_name} ({credential.org_id})"
)
elif credential.org_id:
logger.info(f"Organization: {credential.org_id}")
if credential.org_display_name:
logger.info(f"Organization: {credential.org_display_name}")

try:
session = default_auth_session_store().load()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dispatch-cli"
version = "0.9.12"
version = "0.9.13"
description = ""
authors = [
{name = "Diamond Bishop", email = "diamond.bishop@datadoghq.com"},
Expand Down
5 changes: 4 additions & 1 deletion tests/test_auth_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def test_login_runs_oauth_flow_and_persists_session(self, runner):
assert stored is not None
assert stored.user_email == "user@example.com"
assert "Logged in with browser auth" in result.output
assert "Organization: Example Org" in result.output
assert "org_123" not in result.output

def test_login_surfaces_oauth_flow_failure(self, runner):
login_flow = Mock()
Expand Down Expand Up @@ -170,7 +172,8 @@ def test_whoami_shows_oauth_identity(self, runner):
assert result.exit_code == 0
assert "Auth mode: oauth" in result.output
assert "User: user@example.com" in result.output
assert "Organization: Example Org (org_123)" in result.output
assert "Organization: Example Org" in result.output
assert "org_123" not in result.output

def test_whoami_shows_api_key_mode(self, runner):
provider = StaticCredentialProvider(
Expand Down
28 changes: 28 additions & 0 deletions tests/test_auth_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,34 @@ def test_prompts_for_org_when_multiple_orgs_are_available(self):
assert session.org_id == "org_456"
flow._select_organization.assert_called_once()

def test_org_prompt_choices_hide_auth0_ids(self):
flow = BrowserLoginFlow(
AuthClientConfig(
domain="tenant.auth0.com",
client_id="client_123",
audience="aud",
)
)

with patch("dispatch_cli.auth_login.questionary.select") as select:
select.return_value.ask.return_value = "org_456"

selected = flow._select_organization(
[
AuthOrganization(
id="org_123", name="first", display_name="First Org"
),
AuthOrganization(
id="org_456", name="chosen", display_name="Chosen Org"
),
]
)

assert selected == "org_456"
choices = select.call_args.kwargs["choices"]
assert [choice.title for choice in choices] == ["First Org", "Chosen Org"]
assert [choice.value for choice in choices] == ["org_123", "org_456"]

def test_raises_when_user_has_no_organizations(self):
flow = BrowserLoginFlow(
AuthClientConfig(
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading