|
15 | 15 | from mycli.main_modes.checkup import main_checkup |
16 | 16 | from mycli.main_modes.execute import main_execute_from_cli |
17 | 17 | from mycli.main_modes.list_dsn import main_list_dsn |
18 | | -from mycli.main_modes.list_ssh_config import main_list_ssh_config |
19 | 18 | from mycli.packages.cli_utils import is_valid_connection_scheme |
20 | | -from mycli.packages.ssh_utils import read_ssh_config |
21 | 19 |
|
22 | 20 | if TYPE_CHECKING: |
23 | 21 | from mycli.main import CliArgs |
@@ -134,30 +132,9 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non |
134 | 132 | if cli_args.table: |
135 | 133 | cli_args.format = 'table' |
136 | 134 |
|
137 | | - # ssh_port and ssh_config_path have truthy defaults and are not included |
138 | | - if ( |
139 | | - any([ |
140 | | - cli_args.ssh_user, |
141 | | - cli_args.ssh_host, |
142 | | - cli_args.ssh_password, |
143 | | - cli_args.ssh_key_filename, |
144 | | - cli_args.list_ssh_config, |
145 | | - cli_args.ssh_config_host, |
146 | | - ]) |
147 | | - and not cli_args.ssh_warning_off |
148 | | - ): |
149 | | - click.secho( |
150 | | - f"Warning: The built-in SSH functionality is deprecated and will be removed in a future release. See issue {ISSUES_URL}/1464", |
151 | | - err=True, |
152 | | - fg="red", |
153 | | - ) |
154 | | - |
155 | 135 | if cli_args.list_dsn: |
156 | 136 | sys.exit(main_list_dsn(mycli)) |
157 | 137 |
|
158 | | - if cli_args.list_ssh_config: |
159 | | - sys.exit(main_list_ssh_config(mycli, cli_args)) |
160 | | - |
161 | 138 | # Choose which ever one has a valid value. |
162 | 139 | database = cli_args.dbname or cli_args.database |
163 | 140 |
|
@@ -201,6 +178,11 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non |
201 | 178 | mycli.dsn_alias = cli_args.dsn |
202 | 179 |
|
203 | 180 | if dsn_uri: |
| 181 | + is_valid_scheme, scheme = is_valid_connection_scheme(dsn_uri) |
| 182 | + if not is_valid_scheme: |
| 183 | + click.secho(f'Error: Unknown connection scheme provided for DSN URI ({scheme}://)', err=True, fg='red') |
| 184 | + sys.exit(1) |
| 185 | + |
204 | 186 | uri = urlparse(dsn_uri) |
205 | 187 | env_var_alias_name = None |
206 | 188 | dsn_alias = getattr(mycli, 'dsn_alias', None) |
@@ -298,23 +280,6 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non |
298 | 280 | else: |
299 | 281 | ssl = None |
300 | 282 |
|
301 | | - if cli_args.ssh_config_host: |
302 | | - ssh_config = read_ssh_config(cli_args.ssh_config_path).lookup(cli_args.ssh_config_host) |
303 | | - ssh_host = cli_args.ssh_host if cli_args.ssh_host else ssh_config.get("hostname") |
304 | | - ssh_user = cli_args.ssh_user if cli_args.ssh_user else ssh_config.get("user") |
305 | | - if ssh_config.get("port") and cli_args.ssh_port == 22: |
306 | | - # port has a default value, overwrite it if it's in the config |
307 | | - ssh_port = int(ssh_config.get("port")) |
308 | | - else: |
309 | | - ssh_port = cli_args.ssh_port |
310 | | - ssh_key_filename = cli_args.ssh_key_filename if cli_args.ssh_key_filename else ssh_config.get("identityfile", [None])[0] |
311 | | - else: |
312 | | - ssh_host = cli_args.ssh_host |
313 | | - ssh_user = cli_args.ssh_user |
314 | | - ssh_port = cli_args.ssh_port |
315 | | - ssh_key_filename = cli_args.ssh_key_filename |
316 | | - |
317 | | - ssh_key_filename = ssh_key_filename and os.path.expanduser(ssh_key_filename) |
318 | 283 | # Merge init-commands: global, DSN-specific, then CLI |
319 | 284 | init_cmds: list[str] = [] |
320 | 285 | # 1) Global init-commands |
@@ -434,11 +399,6 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non |
434 | 399 | socket=cli_args.socket, |
435 | 400 | local_infile=cli_args.local_infile, |
436 | 401 | ssl=ssl, |
437 | | - ssh_user=ssh_user, |
438 | | - ssh_host=ssh_host, |
439 | | - ssh_port=ssh_port, |
440 | | - ssh_password=cli_args.ssh_password, |
441 | | - ssh_key_filename=ssh_key_filename, |
442 | 402 | init_command=combined_init_cmd, |
443 | 403 | unbuffered=cli_args.unbuffered, |
444 | 404 | character_set=cli_args.character_set, |
|
0 commit comments