Skip to content

Commit be331f8

Browse files
Show "DEFAULT" as the default profile for databricks auth login (#3252)
## Changes Show `"DEFAULT"` as the default profile for the `databricks auth login` command. This change uses the same UX as seen in the `databricks bundle init` command, i.e. it shows the default value between square backets rather than in the input field. ## Why This change aims to make `databricks auth login` more self-documenting. I want to reference it from templates in the future.
1 parent 6010f56 commit be331f8

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Dependency updates
88

99
### CLI
10+
* Show "DEFAULT" as the default profile for `databricks auth login` [#3252](https://github.com/databricks/cli/pull/3252)
1011

1112
### Bundles
1213

cmd/auth/login.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ func promptForProfile(ctx context.Context, defaultValue string) (string, error)
2626
}
2727

2828
prompt := cmdio.Prompt(ctx)
29-
prompt.Label = "Databricks profile name"
30-
prompt.Default = defaultValue
29+
prompt.Label = "Databricks profile name [" + defaultValue + "]"
3130
prompt.AllowEdit = true
32-
return prompt.Run()
31+
result, err := prompt.Run()
32+
if result == "" {
33+
// Manually return the default value. We could use the prompt.Default
34+
// field, but be inconsistent with other prompts in the CLI.
35+
return defaultValue, err
36+
}
37+
return result, err
3338
}
3439

3540
const (
@@ -101,7 +106,11 @@ depends on the existing profiles you have set in your configuration file
101106
// If the user has not specified a profile name, prompt for one.
102107
if profileName == "" {
103108
var err error
104-
profileName, err = promptForProfile(ctx, getProfileName(authArguments))
109+
profileName = getProfileName(authArguments)
110+
if profileName == "" {
111+
profileName = "DEFAULT"
112+
}
113+
profileName, err = promptForProfile(ctx, profileName)
105114
if err != nil {
106115
return err
107116
}

0 commit comments

Comments
 (0)