Skip to content

Commit f9a676a

Browse files
authored
Merge pull request #1947 from dbcli/RW/remove-legacy-ssl-options
Remove support for legacy `--ssl`/`--no-ssl` CLI arguments
2 parents 9f00b5d + 108d82a commit f9a676a

4 files changed

Lines changed: 3 additions & 52 deletions

File tree

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ Upcoming (TBD)
22
==============
33

44
Breaking Changes
5+
---------
56
* Change default table format to `mysql_unicode`.
67
* Remove support for deprecated environment variable `$DSN`.
78
* Remove support for deprecated environment variable `$MYSQL_UNIX_PORT`.
9+
* Remove support for `--ssl/--no-ssl` CLI arguments in favor of `--ssl-mode`.
810

911

1012
Internal

mycli/cli_runner.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,6 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non
134134
if cli_args.table:
135135
cli_args.format = 'table'
136136

137-
if cli_args.deprecated_ssl is not None:
138-
click.secho(
139-
"Warning: The --ssl/--no-ssl CLI options are deprecated and will be removed in a future release. "
140-
"Please use the \"default_ssl_mode\" config option or --ssl-mode CLI flag instead. "
141-
f"See issue {ISSUES_URL}/1507",
142-
err=True,
143-
fg="yellow",
144-
)
145-
146137
# ssh_port and ssh_config_path have truthy defaults and are not included
147138
if (
148139
any([
@@ -288,25 +279,12 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non
288279
keepalive_ticks = cli_args.keepalive_ticks if cli_args.keepalive_ticks is not None else mycli.default_keepalive_ticks
289280
ssl_mode = cli_args.ssl_mode or mycli.ssl_mode
290281

291-
# if there is a mismatch between the ssl_mode value and other sources of ssl config, show a warning
292-
# specifically using "is False" to not pickup the case where cli_args.deprecated_ssl is None (not set by the user)
293-
if cli_args.deprecated_ssl and ssl_mode == "off" or cli_args.deprecated_ssl is False and ssl_mode in ("auto", "on"):
294-
click.secho(
295-
f"Warning: The current ssl_mode value of '{ssl_mode}' is overriding the value provided by "
296-
f"either the --ssl/--no-ssl CLI options or a DSN URI parameter (ssl={cli_args.deprecated_ssl}).",
297-
err=True,
298-
fg="yellow",
299-
)
300-
301-
# configure SSL if ssl_mode is auto/on or if
302-
# cli_args.deprecated_ssl = True (from --ssl or a DSN URI) and ssl_mode is None
303-
if ssl_mode in ("auto", "on") or (cli_args.deprecated_ssl and ssl_mode is None):
282+
if ssl_mode in ("auto", "on"):
304283
if cli_args.socket and ssl_mode == 'auto':
305284
ssl = None
306285
else:
307286
ssl = {
308287
"mode": ssl_mode,
309-
"enable": cli_args.deprecated_ssl, # todo: why is this set at all?
310288
"ca": cli_args.ssl_ca and os.path.expanduser(cli_args.ssl_ca),
311289
"cert": cli_args.ssl_cert and os.path.expanduser(cli_args.ssl_cert),
312290
"key": cli_args.ssl_key and os.path.expanduser(cli_args.ssl_key),

mycli/main.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ class CliArgs:
128128
type=click.Choice(['auto', 'on', 'off']),
129129
help='Set desired SSL behavior. auto=preferred if TCP/IP, on=required, off=off.',
130130
)
131-
deprecated_ssl: bool | None = clickdc.option(
132-
'--ssl/--no-ssl',
133-
'deprecated_ssl',
134-
default=None,
135-
clickdc=None,
136-
help='Enable SSL for connection (automatically enabled with other flags).',
137-
)
138131
ssl_ca: str | None = clickdc.option(
139132
type=click.Path(exists=True),
140133
help='CA file in PEM format.',

test/pytests/test_main.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -349,28 +349,6 @@ def test_ssl_mode_off(executor, capsys):
349349
assert not ssl_cipher
350350

351351

352-
@dbtest
353-
def test_ssl_mode_overrides_ssl(executor, capsys):
354-
runner = CliRunner()
355-
ssl_mode = "off"
356-
sql = "select * from performance_schema.session_status where variable_name = 'Ssl_cipher'"
357-
result = runner.invoke(click_entrypoint, args=CLI_ARGS + ["--csv", "--ssl-mode", ssl_mode, "--ssl"], input=sql)
358-
result_dict = next(csv.DictReader(result.stdout.split("\n")))
359-
ssl_cipher = result_dict.get("VARIABLE_VALUE", None)
360-
assert not ssl_cipher
361-
362-
363-
@dbtest
364-
def test_ssl_mode_overrides_no_ssl(executor, capsys):
365-
runner = CliRunner()
366-
ssl_mode = "on"
367-
sql = "select * from performance_schema.session_status where variable_name = 'Ssl_cipher'"
368-
result = runner.invoke(click_entrypoint, args=CLI_ARGS + ["--csv", "--ssl-mode", ssl_mode, "--no-ssl"], input=sql)
369-
result_dict = next(csv.DictReader(result.stdout.split("\n")))
370-
ssl_cipher = result_dict.get("VARIABLE_VALUE", None)
371-
assert ssl_cipher
372-
373-
374352
@dbtest
375353
def test_reconnect_database_is_selected(executor, capsys):
376354
m = MyCli()

0 commit comments

Comments
 (0)