Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override all other regions if region is set #624

Merged
merged 1 commit into from
Jan 31, 2018
Merged
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: 8 additions & 1 deletion minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def make_bucket(self, bucket_name, location='us-east-1'):
url = self._endpoint_url + '/' + bucket_name + '/'

# Get signature headers if any.
headers = sign_v4(method, url, 'us-east-1',
headers = sign_v4(method, url, location,
headers, self._access_key,
self._secret_key, content_sha256_hex)

Expand Down Expand Up @@ -296,6 +296,9 @@ def list_buckets(self):

# default for all requests.
region = 'us-east-1'
# region is set then use the region.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we call the same code block twice, we can make it a simple method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to make this a method @ebozduman - it will confuse with _get_bucket_location() - i will prefer to keep it as is.

if self._region:
region = self._region

# Get signature headers if any.
headers = sign_v4(method, url, region,
Expand Down Expand Up @@ -1706,6 +1709,10 @@ def _get_bucket_location(self, bucket_name):
# default for all requests.
region = 'us-east-1'

# Region is set override.
if self._region:
return self._region

# For anonymous requests no need to get bucket location.
if self._access_key is None or self._secret_key is None:
return 'us-east-1'
Expand Down