Skip to content

Conversation

@mdelapenya
Copy link
Member

What does this PR do?

Use the Run function in registry

Why is it important?

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

Related issues

🤖 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 14:09
@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 34b469c
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/68e6709726ab3200088e7d55
😎 Deploy Preview https://deploy-preview-3431--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
    • Standardized registry configuration via unified options for environment variables and file mounts.
    • Reworked container startup to use a consolidated run flow with an HTTP-based wait strategy and startup timeout.
    • Improved error handling and messages during container setup for clearer failures.
    • Enhances reliability of registry startup and configuration consistency without changing the public API.

Walkthrough

Refactors registry module to use functional optionizers and testcontainers.Run. Updates options to apply files and env via testcontainers.WithFiles/WithEnv with error chaining. Run now builds moduleOpts (ports, env, wait strategy) and invokes testcontainers.Run, adjusting error text. No public API signature changes.

Changes

Cohort / File(s) Summary
Option helpers refactor
modules/registry/options.go
Replaced direct request mutations with testcontainers.WithFiles and testcontainers.WithEnv wrappers; added error-handling via chained customizers for WithData, WithHtpasswdFile, and WithHtpasswd.
Run flow via optionizers
modules/registry/registry.go
Rewrote Run to assemble moduleOpts (WithExposedPorts, WithEnv, WithWaitStrategy) and call testcontainers.Run(ctx, img, append(moduleOpts, opts...)...); updated error wrapping string.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Caller
  participant Reg as Registry.Run
  participant TC as testcontainers.Run
  participant Docker as Runtime
  Note over Reg: Build moduleOpts<br/>- WithExposedPorts<br/>- WithEnv<br/>- WithWaitStrategy
  Dev->>Reg: Run(ctx, img, opts...)
  Reg->>TC: Run(ctx, img, moduleOpts+opts)
  TC->>Docker: Create & start container
  Docker-->>TC: Container started / error
  TC-->>Reg: Container or error
  alt success
    Reg-->>Dev: *RegistryContainer
  else error
    Reg-->>Dev: error ("run registry: %w")
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • stevenh

Poem

I hop through options, neat and snug,
Wrapping envs with a tidy tug.
Files in my pouch, ports on the run,
testcontainers.Run—and boom, it’s done!
With waits that listen, ears held high,
A registry launched—carrot-fueled sky. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title uses a clear conventional commit format and succinctly captures the main change by indicating that the registry module now uses the Run function, directly reflecting the core update in the pull request.
Description Check ✅ Passed The description outlines that the PR updates the registry to use the Run function, explains why this migration to the new API is important, and references the related upstream issue, demonstrating clear relevance 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 7ae3814 and 34b469c.

📒 Files selected for processing (2)
  • modules/registry/options.go (2 hunks)
  • modules/registry/registry.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
modules/registry/registry.go (3)
options.go (3)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
  • WithWaitStrategy (366-368)
wait/http.go (1)
  • ForHTTP (149-151)
modules/redis/redis.go (1)
  • Run (58-139)
modules/registry/options.go (2)
options.go (2)
  • WithFiles (524-529)
  • WithEnv (75-85)
container.go (1)
  • ContainerFile (110-115)
⏰ 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). (3)
  • GitHub Check: test (1.25.x, modules/registry) / test: modules/registry/1.25.x
  • GitHub Check: test (1.24.x, modules/registry) / test: modules/registry/1.24.x
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
modules/registry/options.go (2)

21-34: LGTM! Clean refactoring to use wrapper composition.

The refactoring correctly chains WithFiles and WithEnv wrappers with proper error handling. This approach is cleaner than direct field mutation and aligns with the new API pattern.


64-80: LGTM! Consistent wrapper usage with proper error propagation.

The implementation correctly uses WithFiles and WithEnv wrappers, matching the pattern in WithData. Error handling is appropriate—failures from WithFiles are caught early, and the final WithEnv error is properly returned.

modules/registry/registry.go (1)

275-306: Ensure registry tests run in a Docker-enabled environment
The sandbox tests are failing with “rootless Docker not found.” Please rerun go test ./modules/registry on a machine where Docker (or rootless Docker) is available to confirm the refactoring hasn’t altered behavior.


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.

@mdelapenya mdelapenya merged commit d256b4b into testcontainers:main Oct 8, 2025
17 checks passed
@mdelapenya mdelapenya deleted the use-run-claude-registry branch October 8, 2025 14:24
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.

2 participants