Skip to content

Conversation

@mdelapenya
Copy link
Member

What does this PR do?

Use Run function in the DynamoDB module

Why is it important?

Migrate modules to the new API

Related issues

@mdelapenya mdelapenya requested a review from a team as a code owner October 2, 2025 12:38
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Oct 2, 2025
@mdelapenya mdelapenya self-assigned this Oct 2, 2025
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Oct 2, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Summary by CodeRabbit

  • New Features
    • None.
  • Refactor
    • Streamlined DynamoDB container setup for more consistent configuration and startup behavior.
    • Consolidated option handling, reducing implicit side effects and improving maintainability.
  • Improvements
    • Clearer error messages when container startup fails, aiding quicker issue diagnosis.
  • Chores
    • Aligned implementation with modern container APIs for better compatibility and future-proofing.

Walkthrough

Refactors the DynamoDB module to use testcontainers.Run with ContainerCustomizer helpers instead of GenericContainerRequest. Updates option handling to WithEntrypoint, WithCmdArgs, WithExposedPorts, WithWait, and WithReuseByName. Adjusts error messages and reworks WithSharedDB and WithDisableTelemetry to return composed customizers.

Changes

Cohort / File(s) Summary of edits
DynamoDB module: migrate to Run API
modules/dynamodb/dynamodb.go
Replace GenericContainerRequest/GenericContainer with testcontainers.Run(ctx, img, moduleOpts...). Build moduleOpts via WithEntrypoint, WithCmdArgs, WithExposedPorts, WithWait. Update error text to "run dynamodb: %w". Reimplement WithSharedDB using WithCmdArgs and WithReuseByName. Reimplement WithDisableTelemetry returning WithCmdArgs customizer.

Sequence Diagram(s)

sequenceDiagram
    participant U as Caller
    participant D as DynamoDB Module
    participant T as testcontainers.Run
    participant C as Container

    U->>D: New DynamoDB(...)
    D->>D: Build moduleOpts<br/>- WithEntrypoint<br/>- WithCmdArgs<br/>- WithExposedPorts<br/>- WithWait
    alt Shared DB enabled
        D->>D: WithSharedDB<br/>- WithCmdArgs<br/>- WithReuseByName
    end
    opt Disable telemetry
        D->>D: WithDisableTelemetry -> WithCmdArgs(-disableTelemetry)
    end
    D->>T: Run(ctx, image, moduleOpts...)
    T-->>D: Container or error
    D-->>U: Container handle or error
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I whisk my ears at changing seas,
From Generic winds to Run with ease;
With With* hops I tweak the way,
Shared burrows named for reuse stay;
Telemetry hush, ports align—
A tidy warren, clean by design.
Hop-run-hop! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly indicates the purpose of the change—migrating the DynamoDB module to use the new Run function—using concise, conventional commit style phrasing that accurately reflects the main change.
Description Check ✅ Passed The description explains what the PR does—adopting the Run function in the DynamoDB module—and why it is important, linking to the related issue and clearly relating to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c076d1d and 5ea8fd4.

📒 Files selected for processing (1)
  • modules/dynamodb/dynamodb.go (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
modules/dynamodb/dynamodb.go (2)
options.go (7)
  • ContainerCustomizer (22-24)
  • WithEntrypoint (438-443)
  • WithCmd (462-467)
  • WithExposedPorts (454-459)
  • WithWaitStrategy (366-368)
  • WithCmdArgs (470-475)
  • WithReuseByName (129-138)
wait/host_port.go (1)
  • ForListeningPort (67-69)
🔇 Additional comments (3)
modules/dynamodb/dynamodb.go (3)

22-43: LGTM! Clean migration to the new Run API.

The refactor correctly replaces explicit ContainerRequest construction with composable ContainerCustomizer helpers. The container is properly wrapped even on error (enabling cleanup), and the error message is more specific.


51-65: LGTM! Proper composition of customizers.

The function correctly chains WithCmdArgs and WithReuseByName helpers with appropriate error propagation. The sequential invocation pattern aligns with the new API design.


68-73: LGTM! Concise flag addition.

The function correctly uses WithCmdArgs to append the telemetry flag to any existing command arguments, as documented in the inline comment.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link

netlify bot commented Oct 2, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 5ea8fd4
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/68de725be51dcf00086cc0aa
😎 Deploy Preview https://deploy-preview-3406--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Changes that do not impact the existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant