Skip to content

Commit 9093081

Browse files
Switch auth logout from --force to --auto-approve (#4755)
## Changes * Replace the logout-specific `--force` flag with `--auto-approve`, matching the pattern used by `bundle deploy`, `bundle destroy`, and other commands. * Register `--auto-approve` directly on the `auth logout` command instead of relying on an unregistered global `--yes` flag. * Stop registering a local `--profile` flag on `auth logout` — read the value from the shared flag already available on the command tree. * Update the logout help text, non-interactive error message, and unit/acceptance tests to reflect the `--auto-approve` behavior. ## Why The `--force` flag was specific to `auth logout`. Switching to `--auto-approve` aligns with the rest of the CLI's confirmation-skip pattern (`bundle deploy --auto-approve`, `bundle destroy --auto-approve`, etc.). `auth logout` was defining its own `--profile` flag, overriding the global one. Removing it and defaulting to the root behavior keeps UX aligned with other commands and removes a duplicate flag definition that can drift over time. ## Tests * `go test ./cmd/auth -run TestLogout -count=1` * `go test ./acceptance -run TestAccept/cmd/auth/logout -test.v`
1 parent 4aef5b3 commit 9093081

19 files changed

Lines changed: 53 additions & 53 deletions

File tree

acceptance/cmd/auth/logout/default-profile/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ host = [DATABRICKS_URL]
1111
auth_type = databricks-cli
1212

1313
=== Delete the DEFAULT profile
14-
>>> [CLI] auth logout --profile DEFAULT --force --delete
14+
>>> [CLI] auth logout --profile DEFAULT --auto-approve --delete
1515
Logged out of and deleted profile "DEFAULT".
1616

1717
=== Backup file should exist

acceptance/cmd/auth/logout/default-profile/script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ title "Initial config\n"
1616
cat "./home/.databrickscfg"
1717

1818
title "Delete the DEFAULT profile"
19-
trace $CLI auth logout --profile DEFAULT --force --delete
19+
trace $CLI auth logout --profile DEFAULT --auto-approve --delete
2020

2121
title "Backup file should exist\n"
2222
assert_backup_exists

acceptance/cmd/auth/logout/delete-clears-default/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
default_profile = workspace-a
55

66
=== Delete the default profile
7-
>>> [CLI] auth logout --profile workspace-a --force --delete
7+
>>> [CLI] auth logout --profile workspace-a --auto-approve --delete
88
Deleted profile "workspace-a" with no tokens to clear.
99

1010
=== Settings after deleting default — default_profile should be cleared
1111
[__settings__]
1212

1313
=== Delete a non-default profile
14-
>>> [CLI] auth logout --profile workspace-b --force --delete
14+
>>> [CLI] auth logout --profile workspace-b --auto-approve --delete
1515
Deleted profile "workspace-b" with no tokens to clear.
1616

1717
=== Settings after deleting non-default — section should still be present but empty

acceptance/cmd/auth/logout/delete-clears-default/script

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ title "Initial settings section\n"
2222
cat "./home/.databrickscfg" | grep -A1 __settings__
2323

2424
title "Delete the default profile"
25-
trace $CLI auth logout --profile workspace-a --force --delete
25+
trace $CLI auth logout --profile workspace-a --auto-approve --delete
2626

2727
title "Settings after deleting default — default_profile should be cleared\n"
2828
cat "./home/.databrickscfg" | grep -A1 __settings__
2929

3030
title "Delete a non-default profile"
31-
trace $CLI auth logout --profile workspace-b --force --delete
31+
trace $CLI auth logout --profile workspace-b --auto-approve --delete
3232

3333
title "Settings after deleting non-default — section should still be present but empty\n"
3434
cat "./home/.databrickscfg" | grep -A1 __settings__

acceptance/cmd/auth/logout/delete-pat-token-profile/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ host = https://dev.cloud.databricks.com
88
token = dev-pat-token
99

1010
=== Logout without --delete — should report no changes for non-U2M profile
11-
>>> [CLI] auth logout --profile dev --force
11+
>>> [CLI] auth logout --profile dev --auto-approve
1212
No tokens to clear for profile "dev". Use --delete to remove it from the config file.
1313

1414
=== Config after logout — profile should be unchanged
@@ -20,7 +20,7 @@ host = https://dev.cloud.databricks.com
2020
token = dev-pat-token
2121

2222
=== Logout with --delete — should delete the profile
23-
>>> [CLI] auth logout --profile dev --force --delete
23+
>>> [CLI] auth logout --profile dev --auto-approve --delete
2424
Deleted profile "dev" with no tokens to clear.
2525

2626
=== Backup file should exist

acceptance/cmd/auth/logout/delete-pat-token-profile/script

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ title "Initial config\n"
1313
cat "./home/.databrickscfg"
1414

1515
title "Logout without --delete — should report no changes for non-U2M profile"
16-
trace $CLI auth logout --profile dev --force
16+
trace $CLI auth logout --profile dev --auto-approve
1717

1818
title "Config after logout — profile should be unchanged\n"
1919
cat "./home/.databrickscfg"
2020

2121
title "Logout with --delete — should delete the profile"
22-
trace $CLI auth logout --profile dev --force --delete
22+
trace $CLI auth logout --profile dev --auto-approve --delete
2323

2424
title "Backup file should exist\n"
2525
assert_backup_exists

acceptance/cmd/auth/logout/error-cases/script

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ auth_type = databricks-cli
1010
EOF
1111

1212
title "Logout of non-existent profile\n"
13-
errcode $CLI auth logout --profile nonexistent --force
13+
errcode $CLI auth logout --profile nonexistent --auto-approve
1414

1515
title "Logout without --profile in non-interactive mode\n"
16-
errcode $CLI auth logout --force
16+
errcode $CLI auth logout --auto-approve

acceptance/cmd/auth/logout/last-non-default/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ host = [DATABRICKS_URL]
99
auth_type = databricks-cli
1010

1111
=== Delete the only non-default profile
12-
>>> [CLI] auth logout --profile only-profile --force --delete
12+
>>> [CLI] auth logout --profile only-profile --auto-approve --delete
1313
Logged out of and deleted profile "only-profile".
1414

1515
=== Backup file should exist

acceptance/cmd/auth/logout/last-non-default/script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ title "Initial config\n"
1414
cat "./home/.databrickscfg"
1515

1616
title "Delete the only non-default profile"
17-
trace $CLI auth logout --profile only-profile --force --delete
17+
trace $CLI auth logout --profile only-profile --auto-approve --delete
1818

1919
title "Backup file should exist\n"
2020
assert_backup_exists

acceptance/cmd/auth/logout/ordering-preserved/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ account_id = account-id
2222
auth_type = databricks-cli
2323

2424
=== Delete first non-default profile (alpha)
25-
>>> [CLI] auth logout --profile alpha --force --delete
25+
>>> [CLI] auth logout --profile alpha --auto-approve --delete
2626
Logged out of and deleted profile "alpha".
2727

2828
=== Backup file should exist
@@ -46,7 +46,7 @@ account_id = account-id
4646
auth_type = databricks-cli
4747

4848
=== Delete last profile (gamma)
49-
>>> [CLI] auth logout --profile gamma --force --delete
49+
>>> [CLI] auth logout --profile gamma --auto-approve --delete
5050
Logged out of and deleted profile "gamma".
5151

5252
=== Config after deleting gamma

0 commit comments

Comments
 (0)