Skip to content

Commit

Permalink
Support new S3 URL format (#123)
Browse files Browse the repository at this point in the history
* add support for new s3 format

* update version and changelog

* update tests
  • Loading branch information
oscarbc96 committed Sep 2, 2020
1 parent 7a856e0 commit 9e3af51
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.19.1] - 2020-09-01
### Improvements
- Add support for this new S3 url format: `https://bucket.s3.aws-region.amazonaws.com/path1/path2`

## [0.19.0] - 2020-05-21
### Breaking changes
- `rule_mode` is now `BLOCKING` for all Rules.
Expand Down
2 changes: 1 addition & 1 deletion cfripper/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = (0, 19, 0)
VERSION = (0, 19, 1)

__version__ = ".".join(map(str, VERSION))
5 changes: 5 additions & 0 deletions cfripper/model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def extract_bucket_name_and_path_from_url(url):
if match:
bucket_name, path = match.group(1), match.group(2)[1:] # Trim start /

# https://bucket.s3.aws-region.amazonaws.com/path1/path2
match = re.search(r"^https://([^.]+)\.s3\.[^\.]+\.amazonaws\.com(.*?)$", url)
if match:
bucket_name, path = match.group(1), match.group(2)[1:] # Trim start /

# https://bucket.s3-aws-region.amazonaws.com/path1/path2
match = re.search(r"^https://([^.]+)\.s3-[^\.]+\.amazonaws\.com(.*?)$", url)
if match:
Expand Down
5 changes: 5 additions & 0 deletions tests/model/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
"cf-templates",
"path/to/template.yml",
),
(
"https://cf-templates.s3.eu-central-1.amazonaws.com/path/to/template.yml",
"cf-templates",
"path/to/template.yml",
),
],
)
def test_extract_bucket_name_and_path_from_url_works(template_url, bucket, path):
Expand Down

0 comments on commit 9e3af51

Please sign in to comment.