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

Feat: Delete versioned S3 objects #54

Merged
merged 2 commits into from
Feb 4, 2024
Merged

Feat: Delete versioned S3 objects #54

merged 2 commits into from
Feb 4, 2024

Conversation

nao1215
Copy link
Owner

@nao1215 nao1215 commented Feb 4, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced S3 application capabilities with the introduction of S3 object version listing and deletion based on versions.
  • Refactor
    • Updated dependency injection and service initialization to support new S3 object version handling features.
  • Tests
    • Expanded test coverage to include new functionality for listing and deleting S3 object versions.

Copy link
Contributor

coderabbitai bot commented Feb 4, 2024

Warning

Rate Limit Exceeded

@nao1215 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 4 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 6f0e184 and 5ceee5b.

Walkthrough

The project implemented enhancements to handle S3 object version listing within its infrastructure. It involved adding a new dependency, updating domain models and services, and extending functionality in the external interface and interactor to support object version management. This update allows for more granular control over S3 objects, including version listing and deletion based on specific versions, thereby improving data management and operational capabilities.

Changes

Files Change Summaries
app/di/wire.go Added dependency external.S3ObjectVersionsListerSet.
app/di/wire_gen.go Created s3ObjectVersionsLister in NewS3App.
app/domain/model/s3.go Added Join method to S3Key.
app/domain/service/s3.go Added interfaces and structures for S3 object version listing.
app/external/.../mock/s3.go Added mock S3ObjectVersionsLister type and ListS3ObjectVersions method.
app/external/s3.go Implemented S3ObjectVersionsLister, added S3ObjectVersionsListerSet, and NewS3ObjectVersionsLister.
app/interactor/s3.go Updated S3ObjectsDeleter with new version listing logic.
app/interactor/s3_test.go Modified tests to include s3ObjectVersionLister.

🐇✨
In the realm of bytes and bits,
A rabbit hopped, fixing kits.
With each leap, versions align,
In S3 buckets, they now shine.
🌟🐾

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a105246 and 6f0e184.
Files selected for processing (8)
  • app/di/wire.go (1 hunks)
  • app/di/wire_gen.go (1 hunks)
  • app/domain/model/s3.go (1 hunks)
  • app/domain/service/s3.go (1 hunks)
  • app/external/mock/s3.go (1 hunks)
  • app/external/s3.go (1 hunks)
  • app/interactor/s3.go (3 hunks)
  • app/interactor/s3_test.go (4 hunks)
Additional comments: 11
app/di/wire.go (1)
  • 51-51: Change approved: Correctly added external.S3ObjectVersionsListerSet to the dependency injection setup in NewS3App.
app/external/mock/s3.go (1)
  • 97-103: Change approved: Correctly added mock type S3ObjectVersionsLister and its method ListS3ObjectVersions for unit testing.
app/domain/service/s3.go (1)
  • 179-194: Change approved: Correctly added interfaces and structures for S3ObjectVersionsLister domain service.
app/di/wire_gen.go (1)
  • 36-37: Change approved: Correctly instantiated s3ObjectVersionsLister and passed it to interactor.NewS3ObjectsDeleter.
app/interactor/s3.go (3)
  • 144-144: Change approved: Correctly added service.S3ObjectVersionsLister field to S3ObjectsDeleter struct.
  • 158-166: Change approved: Correctly updated NewS3ObjectsDeleter function signature to include service.S3ObjectVersionsLister.
  • 183-217: Change approved: Correctly implemented logic in DeleteS3Objects method for listing object versions and deleting objects based on those versions.
app/domain/model/s3.go (1)
  • 406-406: The Join method implementation in S3Key struct is correct and follows best practices for string manipulation in Go.
app/external/s3.go (1)
  • 417-471: The implementation of S3ObjectVersionsLister and its method ListS3ObjectVersions correctly adheres to the interface contract for listing S3 object versions. The method efficiently handles pagination with AWS SDK's ListObjectVersions call, ensuring all versions and delete markers are captured. The use of MaxS3Keys constant for limiting the number of keys per request is a good practice for managing performance and avoiding excessive data retrieval in a single call.
app/interactor/s3_test.go (2)
  • 457-457: This test case does not include the s3ObjectVersionLister parameter. If this is intentional (e.g., testing behavior when the version lister is not available), it's acceptable. Otherwise, consider adding it to maintain consistency across test cases.
  • 482-482: The absence of s3ObjectVersionLister in this test case appears intentional, focusing on testing with minimal setup. No action needed unless the test's scope is intended to cover versioned object deletion logic.

Comment on lines 376 to 382
s3ObjectVersionLister := mock.S3ObjectVersionsLister(func(ctx context.Context, input *service.S3ObjectVersionsListerInput) (*service.S3ObjectVersionsListerOutput, error) {
return &service.S3ObjectVersionsListerOutput{
Objects: model.S3ObjectIdentifiers{},
}, nil
})

s3ObjectsDeleter := NewS3ObjectsDeleter(s3ObjectsDeleterMock, s3BucketLocationGetter, s3ObjectVersionLister)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure the s3ObjectVersionLister mock is correctly set up to return a meaningful response for testing the DeleteS3Objects functionality, even if it's an empty list in this case. Consider adding test cases or modifying the mock to return different sets of object versions to more thoroughly test the handling of versioned objects.

Comment on lines 422 to 428
s3ObjectVersionLister := mock.S3ObjectVersionsLister(func(ctx context.Context, input *service.S3ObjectVersionsListerInput) (*service.S3ObjectVersionsListerOutput, error) {
return &service.S3ObjectVersionsListerOutput{
Objects: model.S3ObjectIdentifiers{},
}, nil
})

s3ObjectsDeleter := NewS3ObjectsDeleter(s3ObjectsDeleterMock, s3BucketLocationGetter, s3ObjectVersionLister)
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the previous comment, verify that the s3ObjectVersionLister mock setup is appropriate for the test scenario. If testing error handling or specific logic related to object versions, adjust the mock's return values accordingly.

Copy link

github-actions bot commented Feb 4, 2024

HOTTEST report

PASS FAIL SKIP TOTAL DURATION
283 0 7 290 3.856270242s

Reported by hottest

Copy link

github-actions bot commented Feb 4, 2024

Code Metrics Report

main (a105246) #54 (cec711b) +/-
Coverage 24.6% 24.8% +0.2%
Test Execution Time 12s 6s -6s
Details
  |                     | main (a105246) | #54 (cec711b) |  +/-  |
  |---------------------|----------------|---------------|-------|
+ | Coverage            |          24.6% |         24.8% | +0.2% |
  |   Files             |             42 |            42 |     0 |
  |   Lines             |           1619 |          1649 |   +30 |
+ |   Covered           |            398 |           409 |   +11 |
+ | Test Execution Time |            12s |            6s |   -6s |

Code coverage of files in pull request scope (69.1% → 66.5%)

Files Coverage +/-
app/di/wire_gen.go 0.0% 0.0%
app/domain/model/s3.go 99.0% 0.0%
app/external/mock/s3.go 100.0% 0.0%
app/external/s3.go 35.3% -6.6%
app/interactor/s3.go 97.9% -2.1%

Reported by octocov

@nao1215 nao1215 merged commit 1b8bc1d into main Feb 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant