Skip to content

Commit

Permalink
revert unused code, formatting cleanup and disabling for presigning
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlm committed Aug 22, 2023
1 parent 6da070b commit f0c0376
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
21 changes: 9 additions & 12 deletions botocore/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,23 +784,20 @@ def _compute_user_agent_appid_config(self, config_kwargs):
config_kwargs['user_agent_appid'] = user_agent_appid

def _compute_account_id_endpoint_mode(self, config_kwargs):
account_id_endpoint_mode = config_kwargs.get(
'account_id_endpoint_mode'
)
if account_id_endpoint_mode is None:
account_id_endpoint_mode = self._config_store.get_config_variable(
act_id_ep_mode = config_kwargs.get('account_id_endpoint_mode')
if act_id_ep_mode is None:
act_id_ep_mode = self._config_store.get_config_variable(
'account_id_endpoint_mode'
)
if account_id_endpoint_mode is not None:
if account_id_endpoint_mode not in VALID_ACCOUNT_ID_ENDPOINT_MODES:
if act_id_ep_mode is not None:
if act_id_ep_mode not in VALID_ACCOUNT_ID_ENDPOINT_MODES:
valid_modes_str = ', '.join(VALID_ACCOUNT_ID_ENDPOINT_MODES)
error_msg = (
f"Invalid value '{account_id_endpoint_mode}' for "
f"account_id_endpoint_mode. Valid values are: {valid_modes_str}"
f"Invalid value '{act_id_ep_mode}' for "
"account_id_endpoint_mode. Valid values are: "
f"{valid_modes_str}"
)
raise botocore.exceptions.InvalidConfigError(
error_msg=error_msg
)
config_kwargs[
'account_id_endpoint_mode'
] = account_id_endpoint_mode
config_kwargs['account_id_endpoint_mode'] = act_id_ep_mode
3 changes: 0 additions & 3 deletions botocore/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,6 @@ def _make_file_safe(self, filename):
def _get_credentials(self):
raise NotImplementedError('_get_credentials()')

def _resolve_account_id(self, response=None):
raise NotImplementedError('_resolve_account_id()')

def fetch_credentials(self):
return self._get_cached_credentials()

Expand Down
10 changes: 6 additions & 4 deletions botocore/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,8 @@ def _get_provider_params(
config = request_context['client_config']
account_id_endpoint_mode = config.account_id_endpoint_mode
else:
account_id_endpoint_mode = request_context[
'account_id_endpoint_mode'
]
# Presigning requests do not support account ID routing..
account_id_endpoint_mode = 'disabled'
for param_name, param_def in self._param_definitions.items():
param_val = self._resolve_param_from_context(
param_name=param_name,
Expand Down Expand Up @@ -613,7 +612,10 @@ def _resolve_param_as_builtin(
if builtin_name not in EndpointResolverBuiltins.__members__.values():
raise UnknownEndpointResolutionBuiltInName(name=builtin_name)
builtin_value = builtins.get(builtin_name)
if builtin_name == EndpointResolverBuiltins.AWS_ACCOUNT_ID:
if (
builtin_name == EndpointResolverBuiltins.AWS_ACCOUNT_ID
and builtin_value is not None
):
builtin_value = self._resolve_account_id_builtin(
builtin_value, account_id_endpoint_mode
)
Expand Down
2 changes: 0 additions & 2 deletions botocore/signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ def generate_presigned_url(
context = {
'is_presign_request': True,
'use_global_endpoint': _should_use_global_endpoint(self),
'account_id_endpoint_mode': self.meta.config.account_id_endpoint_mode,
}

request_signer = self._request_signer
Expand Down Expand Up @@ -777,7 +776,6 @@ def generate_presigned_post(
context = {
'is_presign_request': True,
'use_global_endpoint': _should_use_global_endpoint(self),
'account_id_endpoint_mode': self.meta.config.account_id_endpoint_mode,
}

post_presigner = S3PostPresigner(self._request_signer)
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ pytest-cov==2.12.1
pytest-xdist==2.4.0
atomicwrites>=1.0 # Windows requirement
colorama>0.3.0 # Windows requirement
setuptools==67.8.0

0 comments on commit f0c0376

Please sign in to comment.