diff --git a/CHANGELOG.md b/CHANGELOG.md index 2003ba4..928fc83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Makefile b/Makefile index 8ec927d..3b30626 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME = yum-plugin-s3-iam -VERSION = 1.1.0 +VERSION = 1.1.1 RELEASE = 1 ARCH = noarch diff --git a/s3iam.py b/s3iam.py index bd40742..ba6fb1f 100755 --- a/s3iam.py +++ b/s3iam.py @@ -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', @@ -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/ + 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-.amazonaws.com/ 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: @@ -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 diff --git a/tests.py b/tests.py index f163850..4e5cda1 100644 --- a/tests.py +++ b/tests.py @@ -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() diff --git a/yum-plugin-s3-iam.spec b/yum-plugin-s3-iam.spec index 16387ac..c0949d3 100644 --- a/yum-plugin-s3-iam.spec +++ b/yum-plugin-s3-iam.spec @@ -37,6 +37,9 @@ rm -rf ${RPM_BUILD_ROOT} /usr/lib/yum-plugins/s3iam.py* %changelog +* Thu Feb 16 2017 Mathias Brossard 1.1.1-1 +- Add support for cn-north-1 region + * Wed Jul 11 2016 Mathias Brossard 1.1.0-1 - Add support for AWS v4 signature (@mbrossard) - Add support for s3:// scheme (@asedge, @mbrossard)