Skip to content

Conversation

@mdelapenya
Copy link
Member

What does this PR do?

Use the Run function in redis

Why is it important?

Migrate modules to the new API, improving consistency and leveraging the latest testcontainers functionality.

Related issues

🤖 Generated with Claude Code

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@mdelapenya mdelapenya requested a review from a team as a code owner October 8, 2025 09:06
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Oct 8, 2025
@netlify
Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 3857aca
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/68e63197e458820008bef273
😎 Deploy Preview https://deploy-preview-3429--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.

@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

Summary by CodeRabbit

  • Refactor

    • Streamlined Redis container startup using consolidated functional options.
    • Simplified TLS-enabled runs with automatic certificate handling and file uploads.
    • Unified command configuration for default and TLS modes.
  • Bug Fixes

    • Clearer error message when Redis container startup fails.
  • Chores

    • Preserved deprecated wrapper while delegating to the updated run flow.
    • No breaking changes to the public API.

Walkthrough

Refactors Redis module to use testcontainers' functional-options flow: config-file handling now applies WithFiles/WithCmd, and Run builds a moduleOpts slice (including TLS cert generation, files, cmd args, and wait strategy) passed to testcontainers.Run, then assigns the returned container.

Changes

Cohort / File(s) Summary
Config-file functional option
modules/redis/options.go
Replaces direct mutation of a ContainerRequest with applying testcontainers.WithFiles(...) and testcontainers.WithCmd(...) inside WithConfigFile, returning errors inline rather than mutating req in-place.
Run flow refactor & TLS
modules/redis/redis.go
Rebuilds Run to accumulate moduleOpts (options + TLS handling), generates TLS certs when enabled, appends WithFiles and WithCmd/wait options, calls testcontainers.Run(ctx, img, moduleOpts...), updates container assignment and error text ("run redis: %w").

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant RedisRun as Redis.Run
  participant TC as testcontainers.Run
  participant Container

  Caller->>RedisRun: Run(ctx, image, opts...)
  RedisRun->>RedisRun: Build moduleOpts via Option callbacks
  alt TLS enabled
    RedisRun->>RedisRun: Generate certs, add WithFiles, WithCmd, wait on TLS port
  end
  RedisRun->>TC: Run(ctx, image, moduleOpts...)
  TC-->>RedisRun: container / error
  alt success
    RedisRun->>Container: assign to RedisContainer.Container
    RedisRun-->>Caller: return RedisContainer, tlsConfig
  else error
    RedisRun-->>Caller: return error ("run redis: %w")
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • stevenh

Poem

A rabbit taps the Docker drum,
Options hop—no reqs to thrum.
Files tucked neat, commands in line,
TLS seeds sprout by design.
With Run we sprint; containers sing—🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title follows conventional commit style and succinctly describes the main change of migrating the Redis module to use the Run function, which aligns directly with the changes introduced in the pull request.
Description Check ✅ Passed The description explains the core change to use the Run function in Redis and outlines the motivation and related issues, making it clearly relevant 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 (beta)
  • 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 8f1f613 and 3857aca.

📒 Files selected for processing (1)
  • modules/redis/redis.go (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
modules/redis/redis.go (2)
options.go (5)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
  • WithWaitStrategy (366-368)
  • WithCmdArgs (470-475)
  • WithFiles (524-529)
container.go (2)
  • ContainerFile (110-115)
  • Container (41-73)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test (1.24.x, modules/redis) / test: modules/redis/1.24.x
  • GitHub Check: Analyze (go)

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.

- Move wait.ForListeningPort to base moduleOpts instead of conditional TLS block
- Port 6379 is always listening (regular or TLS traffic) so wait should be unconditional
- Removed duplicate wait strategy that was only added for TLS case

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@mdelapenya mdelapenya merged commit b890b0c into testcontainers:main Oct 8, 2025
17 checks passed
@mdelapenya mdelapenya deleted the use-run-claude-redis branch October 8, 2025 10:09
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