Skip to content

Commit

Permalink
Merge pull request #52 from seporaitis/aws-cn
Browse files Browse the repository at this point in the history
Add support for cn-north-1
  • Loading branch information
mbrossard authored Feb 17, 2017
2 parents c29061a + a67fcfb commit 014eb17
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.1.1 (2016-02-17)
- #51: Add support for cn-north-1 region

## 1.1.0 (2016-07-11)
- #32: Add support for AWS v4 signature (@mbrossard)
- #32: Add support for s3:// scheme (@asedge, @mbrossard)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = yum-plugin-s3-iam
VERSION = 1.1.0
VERSION = 1.1.1
RELEASE = 1
ARCH = noarch

Expand Down
10 changes: 9 additions & 1 deletion s3iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
__email__ = "julius@seporaitis.net"
__copyright__ = "Copyright 2012, Julius Seporaitis"
__license__ = "Apache 2.0"
__version__ = "1.1.0"
__version__ = "1.1.1"


__all__ = ['requires_api_version', 'plugin_type', 'CONDUIT',
Expand Down Expand Up @@ -82,6 +82,11 @@ def parse_url(url):
if m:
return (m.group(2), 'us-east-1', m.group(3))

# http[s]://s3.cn-north-1.amazonaws.com.cn/<bucket>
m = re.match(r'(http|https|s3)://s3[.]cn-north-1[.]amazonaws[.]com[.]cn/([a-z0-9][a-z0-9-.]{1,61}[a-z0-9])(.*)$', url)
if m:
return (m.group(2), 'cn-north-1', m.group(3))

# http[s]://s3-<region>.amazonaws.com/<bucket>
m = re.match(r'(http|https|s3)://s3-([a-z0-9-]+)[.]amazonaws[.]com/([a-z0-9][a-z0-9-.]{1,61}[a-z0-9])(.*)$', url)
if m:
Expand Down Expand Up @@ -128,6 +133,9 @@ def __init__(self, repoid, repo):
else:
self.baseurl = "https://%s.s3.amazonaws.com%s" % (bucket, path)

if 'cn-north-1' in region:
self.baseurl = "https://s3.cn-north-1.amazonaws.com.cn/%s%s" % (bucket, path)

self.name = repo.name
self.region = repo.region if repo.region else region
self.basecachedir = repo.basecachedir
Expand Down
5 changes: 5 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,10 @@ def test_urls(self):
self.assertEqual(r, 'us-west-1')
self.assertEqual(p, '/path')

(b, r, p) = s3iam.parse_url('https://s3.cn-north-1.amazonaws.com.cn/bar/path')
self.assertEqual(b, 'bar')
self.assertEqual(r, 'cn-north-1')
self.assertEqual(p, '/path')

if __name__ == '__main__':
unittest.main()
3 changes: 3 additions & 0 deletions yum-plugin-s3-iam.spec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ rm -rf ${RPM_BUILD_ROOT}
/usr/lib/yum-plugins/s3iam.py*

%changelog
* Thu Feb 16 2017 Mathias Brossard <mathias@brossard.org> 1.1.1-1
- Add support for cn-north-1 region

* Wed Jul 11 2016 Mathias Brossard <mathias@brossard.org> 1.1.0-1
- Add support for AWS v4 signature (@mbrossard)
- Add support for s3:// scheme (@asedge, @mbrossard)
Expand Down

0 comments on commit 014eb17

Please sign in to comment.