3232
3333PROMPT_HOST = 'Databricks Host (should begin with https://)'
3434PROMPT_USERNAME = 'Username'
35- PROMPT_PASSWORD = 'Password' # NOQA
35+ PROMPT_PASSWORD = 'Password [enter stdin to read from stdin every time] ' # NOQA
3636PROMPT_TOKEN = 'Token' # NOQA
3737
3838
3939def _configure_cli_token (profile , insecure ):
4040 config = ProfileConfigProvider (profile ).get_config () or DatabricksConfig .empty ()
4141 host = click .prompt (PROMPT_HOST , default = config .host , type = _DbfsHost ())
42- token = click .prompt (PROMPT_TOKEN , default = config .token )
42+ token = click .prompt (PROMPT_TOKEN , default = config .token , hide_input = True )
4343 new_config = DatabricksConfig .from_token (host , token , insecure )
4444 update_and_persist_config (profile , new_config )
4545
4646
47+ def _configure_cli_stdin (profile , insecure ):
48+ config = ProfileConfigProvider (profile ).get_config () or DatabricksConfig .empty ()
49+ host = click .prompt (PROMPT_HOST , default = config .host , type = _DbfsHost ())
50+ username = click .prompt (PROMPT_USERNAME , default = config .username )
51+ password = 'stdin'
52+ new_config = DatabricksConfig .from_password (host , username , password , insecure )
53+ update_and_persist_config (profile , new_config )
54+
55+
4756def _configure_cli_password (profile , insecure ):
4857 config = ProfileConfigProvider (profile ).get_config () or DatabricksConfig .empty ()
4958 if config .password :
@@ -64,16 +73,19 @@ def _configure_cli_password(profile, insecure):
6473 short_help = 'Configures host and authentication info for the CLI.' )
6574@click .option ('--token' , show_default = True , is_flag = True , default = False )
6675@click .option ('--insecure' , show_default = True , is_flag = True , default = None )
76+ @click .option ('--stdin' , show_default = True , is_flag = True , default = False )
6777@debug_option
6878@profile_option
69- def configure_cli (token , insecure ):
79+ def configure_cli (token , insecure , stdin ):
7080 """
7181 Configures host and authentication info for the CLI.
7282 """
7383 profile = get_profile_from_context ()
7484 insecure_str = str (insecure ) if insecure is not None else None
7585 if token :
7686 _configure_cli_token (profile , insecure_str )
87+ elif stdin :
88+ _configure_cli_stdin ()
7789 else :
7890 _configure_cli_password (profile , insecure_str )
7991
0 commit comments