Skip to content
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

Make --verify-ssl choices explicit #289

Merged
merged 1 commit into from Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions setup.cfg
Expand Up @@ -4,3 +4,6 @@ universal=1
[flake8]
ignore = E501,C901
exclude = tabulate.py

[pycodestyle]
ignore = E501
19 changes: 13 additions & 6 deletions src/crate/crash/command.py
Expand Up @@ -31,7 +31,7 @@
import urllib3
from getpass import getpass
from appdirs import user_data_dir, user_config_dir
from argparse import ArgumentParser
from argparse import ArgumentParser, ArgumentTypeError
from collections import namedtuple
from crate.client import connect
from crate.client.exceptions import ConnectionError, ProgrammingError
Expand Down Expand Up @@ -110,12 +110,14 @@ def parse_args(parser):


def boolean(v):
if str(v).lower() in ("yes", "true", "t", "1"):
v = str(v).lower()
if v in ("yes", "true", "t", "1"):
return True
elif str(v).lower() in ("no", "false", "f", "0"):
elif v in ("no", "false", "f", "0"):
return False
else:
raise ValueError('not a boolean value')
raise ArgumentTypeError(
'Invalid choice `{v}`, expected one of: [yes, true, t, 1, no, false, f, 0]'.format(v=v))


def get_parser(output_formats=[], conf=None):
Expand Down Expand Up @@ -160,8 +162,13 @@ def _conf_or_default(key, value):
parser.add_argument('--hosts', type=str, nargs='*',
default=_conf_or_default('hosts', ['localhost:4200']),
help='connect to HOSTS.', metavar='HOSTS')
parser.add_argument('--verify-ssl', type=boolean, default=True,
help='force the verification of the server SSL certificate')
parser.add_argument(
'--verify-ssl',
choices=(True, False),
type=boolean,
default=True,
help='Enable or disable the verification of the server SSL certificate'
)
parser.add_argument('--cert-file', type=file_with_permissions, metavar='FILENAME',
help='use FILENAME as the client certificate file')
parser.add_argument('--key-file', type=file_with_permissions, metavar='FILENAME',
Expand Down