Skip to content

Commit

Permalink
Explicitly translate supported confi values to TransferConfig
Browse files Browse the repository at this point in the history
The previous implementation made the open-ended assumption that
runtime config translates 1-1 to transfer configs.
This also had the (unintended) side effect that everything in
transfer config was implicitly supported in the ~/.aws/config
file because the config is passed directly to `TransferConfig`.

I've updated the code to have a fixed list of supported config values.
This means that we need to explicitly update this list as we decide
to support for transfer config options.
  • Loading branch information
jamesls committed Sep 1, 2016
1 parent 9a6d466 commit 864936e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 6 additions & 5 deletions awscli/customizations/s3/transferconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ def create_transfer_config_from_runtime_config(runtime_config):
"""
translation_map = {
'max_concurrent_requests': 'max_request_concurrency',
'max_queue_size': 'max_request_queue_size'
'max_queue_size': 'max_request_queue_size',
'multipart_threshold': 'multipart_threshold',
'multipart_chunksize': 'multipart_chunksize',
}
kwargs = {}

for key, value in runtime_config.items():
new_key = translation_map.get(key, key)
kwargs[new_key] = value

if key not in translation_map:
continue
kwargs[translation_map[key]] = value
return TransferConfig(**kwargs)
8 changes: 7 additions & 1 deletion tests/unit/customizations/s3/test_transferconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ def test_convert(self):
'multipart_threshold': 1,
'multipart_chunksize': 2,
'max_concurrent_requests': 3,
'max_queue_size': 4
'max_queue_size': 4,
'addressing_style': 'path',
'use_accelerate_endpoint': True,
# This is a TransferConfig only option, it should
# just be ignored if it's in the ~/.aws/config for now.
'max_in_memory_upload_chunks': 1000,
}
result = transferconfig.create_transfer_config_from_runtime_config(
runtime_config)
self.assertEqual(result.multipart_threshold, 1)
self.assertEqual(result.multipart_chunksize, 2)
self.assertEqual(result.max_request_concurrency, 3)
self.assertEqual(result.max_request_queue_size, 4)
self.assertNotEqual(result.max_in_memory_upload_chunks, 1000)

0 comments on commit 864936e

Please sign in to comment.