Skip to content

Commit

Permalink
Support client context params for s3control (#2797)
Browse files Browse the repository at this point in the history
* also apply client context parameters for s3control, not only s3

* functional tests for usage of context params in endpoint resolution
  • Loading branch information
jonemo authored Oct 27, 2022
1 parent d60c2e4 commit 7d5a59f
Show file tree
Hide file tree
Showing 2 changed files with 518 additions and 4 deletions.
20 changes: 16 additions & 4 deletions botocore/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def compute_client_args(
self._compute_connect_timeout(config_kwargs)
s3_config = self.compute_s3_config(client_config)

is_s3_service = service_name in ['s3', 's3-control']
is_s3_service = self._is_s3_service(service_name)

if is_s3_service and 'dualstack' in endpoint_variant_tags:
if s3_config is None:
Expand Down Expand Up @@ -278,6 +278,16 @@ def compute_s3_config(self, client_config):

return s3_configuration

def _is_s3_service(self, service_name):
"""Whether the service is S3 or S3 Control.
Note that throughout this class, service_name refers to the endpoint
prefix, not the folder name of the service in botocore/data. For
S3 Control, the folder name is 's3control' but the endpoint prefix is
's3-control'.
"""
return service_name in ['s3', 's3-control']

def _compute_endpoint_config(
self,
service_name,
Expand Down Expand Up @@ -532,9 +542,11 @@ def _build_endpoint_resolver(
# botocore does not support client context parameters generically
# for every service. Instead, the s3 config section entries are
# available as client context parameters. In the future, endpoint
# rulesets of services other than S3 may require client context
# parameters.
client_context = s3_config_raw if service_name_raw == 's3' else {}
# rulesets of services other than s3/s3control may require client
# context parameters.
client_context = (
s3_config_raw if self._is_s3_service(service_name_raw) else {}
)
sig_version = (
client_config.signature_version
if client_config is not None
Expand Down
Loading

0 comments on commit 7d5a59f

Please sign in to comment.