-
Notifications
You must be signed in to change notification settings - Fork 58
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
[SNOW-1833500] New command: snow helpers import-snowsql-connections #1956
base: main
Are you sure you want to change the base?
[SNOW-1833500] New command: snow helpers import-snowsql-connections #1956
Conversation
…snowsql-config-migration-commands
log.debug( | ||
"Reading SnowSQL's connection configuration [%s] from [%s]", | ||
snowsql_connection_section_name, | ||
str(file.path), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider cli_console.step
instead of debug. Imo showing users what is being read what is happening may be helpful in case of this command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied your suggestion and changed debug to console.step.
raise ClickException( | ||
f"Default connection name [{default_cli_connection_name}] conflicts with the name of one of connections from SnowSQL. Please specify a different name for your default connection." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about making this command more interactive? We error in case of connection/default names. In both cases we can prompt for user action instead of failing and requiring them to do some manual steps
Connection 'foo' exists in both configuration files, do you want to use SnowSQL definition? [y/N]
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea. I'd also consider --no-interactive
or --skip-conflicting-connections
so user can choose not to be prompted, but this might wait until someone actually requests it.
key_names_replacements = { | ||
"accountname": "account", | ||
"username": "user", | ||
"databasename": "database", | ||
"dbname": "database", | ||
"schemaname": "schema", | ||
"warehousename": "warehouse", | ||
"rolename": "role", | ||
"private_key_path": "private_key_file", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this full list of options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't know.
|
||
def parse_value(value: Any): | ||
try: | ||
parsed_value = literal_eval(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need eval?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only literal_eval
and it's used as parser of values (to correct types) because using raw values would add them to CLI always as strings and CLI wouldn't be able to use such config. Reading everything as strings is the specific behaviour of configparser. At the beginning I wanted to use TOML parser to read SQL's config but SQL's config can contain strings without quotes (even example connection added after installation contains such strings) and they are not valid TOML values. So as the result I read everything as strings and try to parse literals to correct types before saving them in CLI.
custom_snowsql_config_files: Optional[List[Path]] = typer.Option( | ||
None, | ||
"--snowsql-config-file", | ||
help="Specifies file paths to SnowSQL configuration. The option can be used multiple times to specify more than 1 file.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help="Specifies file paths to SnowSQL configuration. The option can be used multiple times to specify more than 1 file.", | |
help="Specifies file paths to custom SnowSQL configuration. The option can be used multiple times to specify more than 1 file.", |
At first I thought that you need to provide default locations by hand :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied your suggestion :)
imported_named_conenction = _convert_connection_from_snowsql_config_section( | ||
snowsql_named_connection | ||
) | ||
if connection_name in imported_named_connections: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we raise / prompt if connection is defined twice instead of overriding (or at least log console.step(connection redefined in X, overriding)
)
…snowsql-config-migration-commands
Pre-review checklist
Changes description
snow helpers import-snowsql-connections