Skip to content

Commit

Permalink
Update ls to support endpoint-url
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesls committed Nov 18, 2013
1 parent 85a3127 commit 6629b29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions awscli/customizations/s3/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _do_command(self, parsed_args, parsed_globals):
cmd_params.add_paths(parsed_args.paths)
cmd_params.check_force(parsed_globals)
cmd = CommandArchitecture(self._session, self._name,
cmd_params.parameters)
cmd_params.parameters)
cmd.create_instructions()
return cmd.run()

Expand Down Expand Up @@ -342,12 +342,16 @@ def _create_operation_parser(self, parameter_table):
parser.add_argument("paths", **self.options)
return parser

def _get_endpoint(self, service, parsed_globals):
return service.get_endpoint(region_name=parsed_globals.region,
endpoint_url=parsed_globals.endpoint_url)


class ListCommand(S3SubCommand):
def _do_command(self, parsed_args, parsed_globals):
bucket, key = find_bucket_key(parsed_args.paths[0][5:])
self.service = self._session.get_service('s3')
self.endpoint = self.service.get_endpoint(parsed_globals.region)
self.endpoint = self._get_endpoint(self.service, parsed_globals)
if not bucket:
self._list_all_buckets()
else:
Expand Down Expand Up @@ -480,8 +484,9 @@ def __init__(self, session, cmd, parameters):
self.parameters = parameters
self.instructions = []
self._service = self.session.get_service('s3')
self._endpoint = self._service.get_endpoint(region_name=self.parameters['region'],
endpoint_url=self.parameters['endpoint_url'])
self._endpoint = self._service.get_endpoint(
region_name=self.parameters['region'],
endpoint_url=self.parameters['endpoint_url'])

def create_instructions(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def test_s3_with_region_and_endpoint_url(self):
http_response = models.Response()
http_response.status_code = 200
endpoint.return_value.make_request.return_value = (
http_response, {})
http_response, {'CommonPrefixes': [], 'Contents': []})
self.assert_params_for_cmd(
's3 ls s3://test --region us-east-1 --endpoint-url https://foobar.com/',
expected_rc=0)
Expand Down

0 comments on commit 6629b29

Please sign in to comment.