Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Aug 14, 2024
1 parent 0234593 commit 4dc7d1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func promptForHost(ctx context.Context) (string, error) {
}

prompt := cmdio.Prompt(ctx)
prompt.Label = "Databricks Host (e.g. https://<databricks-instance>.cloud.databricks.com)"
prompt.Label = "Databricks host (e.g. https://<databricks-instance>.cloud.databricks.com)"
return prompt.Run()
}

Expand All @@ -50,7 +50,7 @@ func promptForAccountID(ctx context.Context) (string, error) {
}

prompt := cmdio.Prompt(ctx)
prompt.Label = "Databricks account id"
prompt.Label = "Databricks account ID"
prompt.Default = ""
prompt.AllowEdit = true
return prompt.Run()
Expand Down
21 changes: 10 additions & 11 deletions cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
"github.com/spf13/cobra"
)

func promptForProfile(ctx context.Context, dv string) (string, error) {
func promptForProfile(ctx context.Context, defaultValue string) (string, error) {
if !cmdio.IsInTTY(ctx) {
return "", fmt.Errorf("the command is being run in a non-interactive environment, please specify a profile using --profile")
}

prompt := cmdio.Prompt(ctx)
prompt.Label = "Databricks profile name"
prompt.Default = dv
prompt.Default = defaultValue
prompt.AllowEdit = true
return prompt.Run()
}
Expand Down Expand Up @@ -185,17 +185,16 @@ func setHostAndAccountId(ctx context.Context, profileName string, persistentAuth
return err
}

// If [HOST] is provided, set the host to the provided positional argument.
if len(args) > 0 && persistentAuth.Host == "" {
persistentAuth.Host = args[0]
}

// If neither [HOST] nor --host are provided, and the profile has a host, use it.
// Otherwise, prompt the user for a host.
if len(args) == 0 && persistentAuth.Host == "" {
if len(profiles) > 0 && profiles[0].Host != "" {
if persistentAuth.Host == "" {
if len(args) > 0 {
// If [HOST] is provided, set the host to the provided positional argument.
persistentAuth.Host = args[0]
} else if len(profiles) > 0 && profiles[0].Host != "" {
// If neither [HOST] nor --host are provided, and the profile has a host, use it.
persistentAuth.Host = profiles[0].Host
} else {
// If neither [HOST] nor --host are provided, and the profile does not have a host,
// then prompt the user for a host.
hostName, err := promptForHost(ctx)
if err != nil {
return err
Expand Down

0 comments on commit 4dc7d1c

Please sign in to comment.