Thanks to visit codestin.com
Credit goes to github.com

Skip to content

implement S3 native CORS #8814

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

Merged
merged 2 commits into from
Aug 14, 2023
Merged

implement S3 native CORS #8814

merged 2 commits into from
Aug 14, 2023

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Aug 3, 2023

This PR implements CORS for the new S3 native provider. This is basically just to make it compatible between both provider.

@bentsku bentsku added aws:s3 Amazon Simple Storage Service semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases labels Aug 3, 2023
@bentsku bentsku self-assigned this Aug 3, 2023
@coveralls
Copy link

coveralls commented Aug 3, 2023

Coverage Status

coverage: 81.504% (-0.04%) from 81.547% when pulling 0b78a1f on s3-native-cors into a7e97ea on master.

@bentsku bentsku force-pushed the s3-native-tagging branch from 59f24eb to dd31f9c Compare August 7, 2023 14:56
@bentsku bentsku force-pushed the s3-native-tagging branch from dd31f9c to 659e02d Compare August 7, 2023 15:26
@bentsku bentsku force-pushed the s3-native-tagging branch from 659e02d to f0f245f Compare August 8, 2023 22:01
@bentsku bentsku force-pushed the s3-native-tagging branch from f0f245f to 6d255bd Compare August 10, 2023 10:27
@bentsku bentsku marked this pull request as ready for review August 10, 2023 11:58
@bentsku bentsku requested a review from macnev2013 as a code owner August 10, 2023 11:58
@bentsku bentsku force-pushed the s3-native-tagging branch from 6d255bd to 897b718 Compare August 10, 2023 22:16
@bentsku bentsku requested a review from thrau as a code owner August 10, 2023 22:16
@bentsku bentsku force-pushed the s3-native-cors branch 2 times, most recently from fd2eeb9 to 4b8f4e6 Compare August 10, 2023 22:25
Base automatically changed from s3-native-tagging to master August 12, 2023 17:42
@github-actions
Copy link

github-actions bot commented Aug 12, 2023

LocalStack Community integration with Pro

       2 files         2 suites   1h 25m 15s ⏱️
2 060 tests 1 656 ✔️ 404 💤 0
2 061 runs  1 656 ✔️ 405 💤 0

Results for commit 0b78a1f.

♻️ This comment has been updated with latest results.

Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

Looks really good! I like the refactoring around the validators.

I have one minor suggestion but nothing blocking

Comment on lines 34 to 38
bucket_cors_index: BucketCorsIndex
bucket_cors_index: BucketCorsIndex | BucketCorsIndexV2

def __init__(self):
self.bucket_cors_index = BucketCorsIndex()
def __init__(self, bucket_cors_index: BucketCorsIndex | BucketCorsIndexV2 = None):
self.bucket_cors_index = bucket_cors_index or BucketCorsIndex()
Copy link
Member

@thrau thrau Aug 14, 2023

Choose a reason for hiding this comment

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

This is a minor thing, but since S3CorsHandler seems independent from the provider, maybe we could further remove the dependency here, instead of introducing a dependency to both providers.
Suggestion (note: remove the call to BucketCorsIndex()):

introduce a Protocol here:

class BucketCorsIndex(Protocol):

    @property
    def cors(self) -> dict[str, CORSConfiguration]:
        raise NotImplementedError

    @property
    def buckets(self) -> set[str]:
        raise NotImplementedError


class S3CorsHandler(Handler):
    bucket_cors_index: BucketCorsIndex

    def __init__(self, bucket_cors_index: BucketCorsIndex):
        self.bucket_cors_index = bucket_cors_index
        ...

then, make sure to instantiate the provider-specific BucketCorsIndex in the provier:

self._cors_handler = S3CorsHandler()

since it's a protocol and it's just for type checking, there's also no need to let the implementations inherit from the protocol class.

Copy link
Member

Choose a reason for hiding this comment

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

nice 💯

@bentsku bentsku merged commit 3de99b6 into master Aug 14, 2023
@bentsku bentsku deleted the s3-native-cors branch August 14, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:s3 Amazon Simple Storage Service semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants