-
Notifications
You must be signed in to change notification settings - Fork 146
Add auth logout command with --profile and --force flags #4613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
828fd02
3628b08
7628785
65e9ec8
f7121e1
36b9983
605a454
433df86
ac76e0a
ca22376
40046fc
7001e21
3de4b00
229ba37
b647cab
865c3b0
d363ad8
aa2fd40
25dca58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| ; Dev workspace | ||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| auth_type = databricks-cli |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
|
|
||
| === Initial config | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
| host = https://default.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Dev workspace | ||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| === Delete the DEFAULT profile | ||
| >>> [CLI] auth logout --profile DEFAULT --force --delete | ||
| Logged out of and deleted profile "DEFAULT". | ||
|
|
||
| === Backup file should exist | ||
| OK: Backup file exists | ||
|
|
||
| === Config after logout — empty DEFAULT with comment should remain at the top of the file | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| ; Dev workspace | ||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| sethome "./home" | ||
|
|
||
| cat > "./home/.databrickscfg" <<'EOF' | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
| host = https://default.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Dev workspace | ||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
| EOF | ||
|
|
||
| title "Initial config\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| title "Delete the DEFAULT profile" | ||
| trace $CLI auth logout --profile DEFAULT --force --delete | ||
|
|
||
| title "Backup file should exist\n" | ||
| assert_backup_exists | ||
|
|
||
| title "Config after logout — empty DEFAULT with comment should remain at the top of the file\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| cp "./home/.databrickscfg" "./out.databrickscfg" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
|
|
||
| === Initial config | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| token = dev-pat-token | ||
|
|
||
| === Logout without --delete — should report no changes for non-U2M profile | ||
| >>> [CLI] auth logout --profile dev --force | ||
| No tokens to clear for profile "dev". Use --delete to remove it from the config file. | ||
|
|
||
| === Config after logout — profile should be unchanged | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| token = dev-pat-token | ||
|
|
||
| === Logout with --delete — should delete the profile | ||
| >>> [CLI] auth logout --profile dev --force --delete | ||
| Deleted profile "dev" with no tokens to clear. | ||
|
|
||
| === Backup file should exist | ||
| OK: Backup file exists | ||
|
|
||
| === Config after delete — profile should be removed | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| sethome "./home" | ||
|
|
||
| cat > "./home/.databrickscfg" <<'EOF' | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| token = dev-pat-token | ||
| EOF | ||
|
|
||
| title "Initial config\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| title "Logout without --delete — should report no changes for non-U2M profile" | ||
| trace $CLI auth logout --profile dev --force | ||
|
|
||
| title "Config after logout — profile should be unchanged\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| title "Logout with --delete — should delete the profile" | ||
| trace $CLI auth logout --profile dev --force --delete | ||
|
|
||
| title "Backup file should exist\n" | ||
| assert_backup_exists | ||
|
|
||
| title "Config after delete — profile should be removed\n" | ||
| cat "./home/.databrickscfg" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
| === Logout of non-existent profile | ||
| Error: profile "nonexistent" not found. Available profiles: dev | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === Logout without --profile in non-interactive mode | ||
| Error: the command is being run in a non-interactive environment, please specify a profile to log out of using --profile | ||
|
|
||
| Exit code: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| sethome "./home" | ||
|
|
||
| cat > "./home/.databrickscfg" <<'EOF' | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| [dev] | ||
| host = https://dev.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
| EOF | ||
|
|
||
| title "Logout of non-existent profile\n" | ||
| errcode $CLI auth logout --profile nonexistent --force | ||
|
|
||
| title "Logout without --profile in non-interactive mode\n" | ||
| errcode $CLI auth logout --force |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| === Initial config | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| ; The only non-default profile | ||
| [only-profile] | ||
| host = https://only.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| === Delete the only non-default profile | ||
| >>> [CLI] auth logout --profile only-profile --force --delete | ||
| Logged out of and deleted profile "only-profile". | ||
|
|
||
| === Backup file should exist | ||
| OK: Backup file exists | ||
|
|
||
| === Config after logout — DEFAULT section with comment should remain | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| sethome "./home" | ||
|
|
||
| cat > "./home/.databrickscfg" <<'EOF' | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| ; The only non-default profile | ||
| [only-profile] | ||
| host = https://only.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
| EOF | ||
|
|
||
| title "Initial config\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| title "Delete the only non-default profile" | ||
| trace $CLI auth logout --profile only-profile --force --delete | ||
|
|
||
| title "Backup file should exist\n" | ||
| assert_backup_exists | ||
|
|
||
| title "Config after logout — DEFAULT section with comment should remain\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| cp "./home/.databrickscfg" "./out.databrickscfg" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
| host = https://default.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Second workspace — beta | ||
| [beta] | ||
| host = https://beta.cloud.databricks.com | ||
| auth_type = databricks-cli |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
|
|
||
| === Initial config | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
| host = https://default.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; First workspace — alpha | ||
| [alpha] | ||
| host = https://alpha.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Second workspace — beta | ||
| [beta] | ||
| host = https://beta.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Third workspace — gamma | ||
| [gamma] | ||
| host = https://accounts.cloud.databricks.com | ||
| account_id = account-id | ||
| auth_type = databricks-cli | ||
|
|
||
| === Delete first non-default profile (alpha) | ||
| >>> [CLI] auth logout --profile alpha --force --delete | ||
| Logged out of and deleted profile "alpha". | ||
|
|
||
| === Backup file should exist | ||
| OK: Backup file exists | ||
|
|
||
| === Config after deleting alpha | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
| host = https://default.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Second workspace — beta | ||
| [beta] | ||
| host = https://beta.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Third workspace — gamma | ||
| [gamma] | ||
| host = https://accounts.cloud.databricks.com | ||
| account_id = account-id | ||
| auth_type = databricks-cli | ||
|
|
||
| === Delete last profile (gamma) | ||
| >>> [CLI] auth logout --profile gamma --force --delete | ||
| Logged out of and deleted profile "gamma". | ||
|
|
||
| === Config after deleting gamma | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
| host = https://default.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Second workspace — beta | ||
| [beta] | ||
| host = https://beta.cloud.databricks.com | ||
| auth_type = databricks-cli |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| sethome "./home" | ||
|
|
||
| cat > "./home/.databrickscfg" <<'EOF' | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
| host = https://default.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; First workspace — alpha | ||
| [alpha] | ||
| host = https://alpha.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Second workspace — beta | ||
| [beta] | ||
| host = https://beta.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| ; Third workspace — gamma | ||
| [gamma] | ||
| host = https://accounts.cloud.databricks.com | ||
| account_id = account-id | ||
| auth_type = databricks-cli | ||
| EOF | ||
|
|
||
| title "Initial config\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| title "Delete first non-default profile (alpha)" | ||
| trace $CLI auth logout --profile alpha --force --delete | ||
|
|
||
| title "Backup file should exist\n" | ||
| assert_backup_exists | ||
|
|
||
| title "Config after deleting alpha\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| title "Delete last profile (gamma)" | ||
| trace $CLI auth logout --profile gamma --force --delete | ||
|
|
||
| title "Config after deleting gamma\n" | ||
| cat "./home/.databrickscfg" | ||
|
|
||
| cp "./home/.databrickscfg" "./out.databrickscfg" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| assert_backup_exists() { | ||
| if [ -f "./home/.databrickscfg.bak" ]; then | ||
| echo "OK: Backup file exists" | ||
| else | ||
| echo "ERROR: Backup file does not exist" | ||
| fi | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Ignore = [ | ||
| "home" | ||
| ] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
|
|
||
| === Token cache keys before logout | ||
| [ | ||
| "dev", | ||
| "https://shared.cloud.databricks.com", | ||
| "staging" | ||
| ] | ||
|
|
||
| === Logout dev without --delete | ||
| >>> [CLI] auth logout --profile dev --force | ||
| Logged out of profile "dev". Use --delete to also remove it from the config file. | ||
|
|
||
| === Config after logout — both profiles should still exist | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| [dev] | ||
| host = https://shared.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| [staging] | ||
| host = https://shared.cloud.databricks.com | ||
| auth_type = databricks-cli | ||
|
|
||
| === Token cache keys after logout — dev removed, host preserved (shared with staging) | ||
| [ | ||
| "https://shared.cloud.databricks.com", | ||
| "staging" | ||
| ] |
Uh oh!
There was an error while loading. Please reload this page.