Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions awscli/customizations/globalargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def resolve_cli_connect_timeout(parsed_args, session, **kwargs):
arg_name = 'connect_timeout'
_resolve_timeout(session, parsed_args, arg_name)

def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs):
def detect_migration_breakage(parsed_args, session, remaining_args, **kwargs):
if not resolve_v2_debug_mode(parsed_args):
return
region = parsed_args.region or session.get_config_variable('region')
Expand Down Expand Up @@ -174,7 +174,11 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs):
'#cliv2-migration-profile-plugins.\n',
out_file=sys.stderr
)
if parsed_args.command == 'ecr' and remaining_args[0] == 'get-login':
if (
parsed_args.command == 'ecr' and
remaining_args is not None and
remaining_args[0] == 'get-login'
):
uni_print(
'\nAWS CLI v2 UPGRADE WARNING: The `ecr get-login` command has '
'been removed in AWS CLI v2. You must use `ecr get-login-password` '
Expand All @@ -189,6 +193,7 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs):
working_param = working_split[2]
if (
parsed_args.command == working_service
and remaining_args is not None
and remaining_args[0] == working_cmd
and f"--{working_param}" in remaining_args
):
Expand Down
4 changes: 2 additions & 2 deletions awscli/customizations/scalarparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def iso_format(value):
return parse_timestamp(value).isoformat()


def add_timestamp_parser(session, v2_debug):
def add_timestamp_parser(session, v2_debug=False):
factory = session.get_component('response_parser_factory')
print_v2_debug_warnings = v2_debug
try:
Expand Down Expand Up @@ -112,7 +112,7 @@ def identity_with_warning(x):
factory.set_parser_defaults(timestamp_parser=timestamp_parser)


def add_scalar_parsers(session, parsed_args, **kwargs):
def add_scalar_parsers(session, parsed_args=None, **kwargs):
factory = session.get_component('response_parser_factory')
factory.set_parser_defaults(blob_parser=identity)
add_timestamp_parser(session, resolve_v2_debug_mode(parsed_args))
2 changes: 1 addition & 1 deletion awscli/paramfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(self, prefixes=None):
prefixes.update(REMOTE_PREFIX_MAP)
self._prefixes = prefixes

def __call__(self, event_name, param, value, parsed_globals, **kwargs):
def __call__(self, event_name, param, value, parsed_globals=None, **kwargs):
"""Handler that supports param values from URIs."""
cli_argument = param
qualified_param_name = '.'.join(event_name.split('.')[1:])
Expand Down
6 changes: 4 additions & 2 deletions awscli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def find_service_and_method_in_event_name(event_name):
def resolve_v2_debug_mode(args):
# Resolve whether v2-debug mode is enabled,
# following the correct precedence order.
if args is None:
return False
if getattr(args, 'v2_debug', False):
return True
if os.environ.get('AWS_CLI_UPGRADE_DEBUG_MODE', '').lower() == 'true':
Expand Down Expand Up @@ -215,12 +217,12 @@ def ignore_ctrl_c():
signal.signal(signal.SIGINT, original)


def emit_top_level_args_parsed_event(session, args, remaining):
def emit_top_level_args_parsed_event(session, args, remaining=None):
session.emit(
'top-level-args-parsed',
parsed_args=args,
session=session,
remaining_args=remaining,
session=session
)


Expand Down
18 changes: 9 additions & 9 deletions tests/unit/customizations/test_globalargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ def test_register_feature_id(self):
session = get_session()
globalargs.detect_migration_breakage(
parsed_args,
session,
[],
session
)
# Verify the correct feature ID is registered during the
# provide-client-params event.
Expand All @@ -216,8 +216,8 @@ def test_ecr_login_v2_debug(self):
with capture_output() as output:
globalargs.detect_migration_breakage(
parsed_args,
session,
remaining_args,
session
)
# Verify the expected warning is printed
self.assertIn(
Expand All @@ -235,8 +235,8 @@ def test_ecr_login_v2_debug_env_var(self):
with mock.patch('os.environ', env):
globalargs.detect_migration_breakage(
parsed_args,
session,
remaining_args,
session
)
# Verify the expected warning is printed
self.assertIn(
Expand All @@ -251,7 +251,7 @@ def test_v2_debug_python_utf8_env_var(self):
environ = {'PYTHONUTF8': '1'}
with mock.patch('os.environ', environ):
with capture_output() as output:
globalargs.detect_migration_breakage(parsed_args, [], session)
globalargs.detect_migration_breakage(parsed_args, session, [])
self.assertIn(
'The AWS CLI v2 does not support The `PYTHONUTF8` and '
'`PYTHONIOENCODING` environment variables, and instead '
Expand All @@ -265,7 +265,7 @@ def test_v2_debug_python_utf8_resolved_env_var(self):
environ = {'PYTHONUTF8': '1', 'AWS_CLI_FILE_ENCODING': 'UTF-8'}
with mock.patch('os.environ', environ):
with capture_output() as output:
globalargs.detect_migration_breakage(parsed_args, [], session)
globalargs.detect_migration_breakage(parsed_args, session, [])
self.assertNotIn(
'AWS CLI v2 UPGRADE WARNING: The PYTHONUTF8 and '
'PYTHONIOENCODING environment variables are unsupported '
Expand All @@ -279,7 +279,7 @@ def test_v2_debug_python_io_encoding_env_var(self):
environ = {'PYTHONIOENCODING': 'UTF8'}
with mock.patch('os.environ', environ):
with capture_output() as output:
globalargs.detect_migration_breakage(parsed_args, [], session)
globalargs.detect_migration_breakage(parsed_args, session, [])
self.assertIn(
'The AWS CLI v2 does not support The `PYTHONUTF8` and '
'`PYTHONIOENCODING` environment variables, and instead '
Expand All @@ -290,7 +290,7 @@ def test_v2_debug_python_io_encoding_env_var(self):
def test_v2_debug_s3_sigv2(self):
parsed_args = FakeParsedArgs(v2_debug=True)
session = get_session()
globalargs.detect_migration_breakage(parsed_args, [], session)
globalargs.detect_migration_breakage(parsed_args, session, [])
with capture_output() as output:
session.emit(
'choose-signer.s3.*',
Expand All @@ -308,7 +308,7 @@ def test_v2_debug_s3_sigv2(self):
def test_v2_debug_s3_us_east_1(self):
parsed_args = FakeParsedArgs(v2_debug=True, region='us-east-1')
session = get_session()
globalargs.detect_migration_breakage(parsed_args, [], session)
globalargs.detect_migration_breakage(parsed_args, session, [])
def mock_get(key: str):
if key == 'retries':
return {'invocation-id': '012345'}
Expand All @@ -335,7 +335,7 @@ def mock_get(key: str):
def test_v2_debug_s3api_us_east_1(self):
parsed_args = FakeParsedArgs(v2_debug=True, region='us-east-1')
session = get_session()
globalargs.detect_migration_breakage(parsed_args, [], session)
globalargs.detect_migration_breakage(parsed_args, session, [])

def mock_get(key: str):
if key == 'retries':
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def test_env_var_non_true_value(self):
with mock.patch.dict(os.environ, {'AWS_CLI_UPGRADE_DEBUG_MODE': 'false'}):
self.assertFalse(resolve_v2_debug_mode(args))

def test_args_none(self):
self.assertFalse(resolve_v2_debug_mode(None))


class MockProcess(object):
@property
Expand Down