Skip to content

Conversation

@mdelapenya
Copy link
Member

  • chore(couchbase): apply consistent patterns for options
  • chore(etcd): apply consistent patterns for options
  • chore(gcloud/firestore): apply consistent patterns for options
  • chore(dockermcpgateway): apply consistent patterns for options
  • chore(azure/eventhubs): apply consistent patterns for options
  • chore(azure/servicebus): apply consistent patterns for options

What does this PR do?

It applies consistency in the definition of the module options.

Why is it important?

Consistency in the patterns discovered during the previous refactors.

Related issues

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

netlify bot commented Oct 10, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit a1d2e04
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/68e8ed390105490008b7334a
😎 Deploy Preview https://deploy-preview-3447--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 10, 2025

Summary by CodeRabbit

  • New Features
    • More consistent option handling across Azure Event Hubs, Service Bus, Couchbase, etcd, Firestore, and Docker MCP Gateway modules, leading to clearer errors and smoother container startup.
  • Bug Fixes
    • Corrected Couchbase admin password validation message to require “at least 6 characters,” improving guidance during setup.
  • Refactor
    • Reordered initialization to apply user options earlier in the startup sequence across multiple modules, improving reliability and surfacing misconfigurations sooner without changing external APIs.

Walkthrough

Refactors multiple module Run functions to apply options/settings before constructing default module options, then append user customizations and invoke Run. Adjusts control flow in Azure Event Hubs/Service Bus, Couchbase, Docker MCP Gateway, etcd, and GCloud Firestore without altering public APIs.

Changes

Cohort / File(s) Summary
Azure modules (option-first Run flow)
modules/azure/eventhubs/eventhubs.go, modules/azure/servicebus/servicebus.go
Move option application earlier: build defaultOptions and apply Option(s) first, then initialize moduleOpts (exposed ports, wait, health) and append user opts; preserves EULA, env, network, and container startup logic.
etcd (cluster-aware option processing)
modules/etcd/etcd.go
Apply ContainerCustomizer options early, prepare cluster-related options via configureCluster, then construct moduleOpts with defaults and lifecycle hooks; return early on option errors.
GCloud Firestore (two-phase assembly)
modules/gcloud/firestore/firestore.go
Extract emulator settings first into a settings object, then assemble moduleOpts (port, wait, WithCmd), and append user opts; retains explicit command composition and host binding.
Couchbase (unified customizers pipeline)
modules/couchbase/couchbase.go
Consolidate default service customizers and user opts into allCustomizers, iterate once to populate runtime config and moduleOpts; fix admin password validation message.
Docker MCP Gateway (settings-first, then defaults)
modules/dockermcpgateway/dockermcpgateway.go
Process options to derive settings before building default moduleOpts (ports, docker.sock bind, wait), then append user opts; keep secrets and command assembly unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant RunFn as Module.Run
  participant Opts as Option(s)
  participant Settings as Settings/Config
  participant ModuleOpts as moduleOpts
  participant Runtime as testcontainers.Run

  Caller->>RunFn: Invoke Run(ctx, ..., opts...)
  RunFn->>Opts: Apply each Option (mutate default settings)
  alt Option error
    Opts-->>RunFn: error
    RunFn-->>Caller: return error
  else Options ok
    Opts-->>Settings: Populate settings
    RunFn->>ModuleOpts: Build defaults (ports, wait, CMD)
    RunFn->>ModuleOpts: Append user opts
    RunFn->>Runtime: Run(ctx, image, ModuleOpts...)
    Runtime-->>RunFn: Container / error
    RunFn-->>Caller: Return result
  end
Loading
sequenceDiagram
  autonumber
  actor Caller
  participant RunETCD as etcd.Run
  participant Opts as ContainerCustomizer(s)
  participant Cluster as configureCluster
  participant ModuleOpts as moduleOpts
  participant Runtime as testcontainers.Run

  Caller->>RunETCD: Run(ctx, nodes, opts...)
  RunETCD->>Opts: Apply to settings
  alt Option error
    RunETCD-->>Caller: error
  else
    RunETCD->>Cluster: Prepare network + per-node opts
    Cluster-->>RunETCD: cluster options
    RunETCD->>ModuleOpts: Build defaults + hooks
    RunETCD->>ModuleOpts: Append cluster opts + user opts
    RunETCD->>Runtime: Run(...)
    Runtime-->>RunETCD: Container(s)
    RunETCD-->>Caller: Return
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • stevenh

Poem

I tweaked my hops and ordered my options first,
Then built my nests of ports and waits well-versed.
From clouds to hubs, I line them in a row—
A tidy warren where containers grow.
Thump-thump! says the bunny, CI lights aglow. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly indicates the chore scope by listing the affected modules and concisely summarizes that a consistent options pattern is being applied across them.
Description Check ✅ Passed The description outlines the modules updated, states the intent to enforce consistency in module option definitions, and is directly related to the changes without drifting off-topic.
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 e456e65 and a1d2e04.

📒 Files selected for processing (1)
  • modules/couchbase/couchbase.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • modules/couchbase/couchbase.go
⏰ 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). (9)
  • GitHub Check: test (1.24.x, modules/dockermcpgateway) / test: modules/dockermcpgateway/1.24.x
  • GitHub Check: test (1.25.x, modules/gcloud) / test: modules/gcloud/1.25.x
  • GitHub Check: test (1.24.x, modules/azure) / test: modules/azure/1.24.x
  • GitHub Check: test (1.24.x, modules/couchbase) / test: modules/couchbase/1.24.x
  • GitHub Check: test (1.25.x, modules/couchbase) / test: modules/couchbase/1.25.x
  • GitHub Check: test (1.24.x, modules/gcloud) / test: modules/gcloud/1.24.x
  • GitHub Check: test (1.24.x, modules/etcd) / test: modules/etcd/1.24.x
  • GitHub Check: test (1.25.x, modules/azure) / test: modules/azure/1.25.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.

Copy link

@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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
modules/couchbase/couchbase.go (1)

95-101: Fix contradictory password validation message.

The guard enforces passwords of length ≥6, but the error reads “at most 6,” which is misleading for users hitting this validation.

-				return nil, errors.New("admin password must be at most 6 characters long")
+				return nil, errors.New("admin password must be at least 6 characters long")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7bf834 and e456e65.

📒 Files selected for processing (6)
  • modules/azure/eventhubs/eventhubs.go (2 hunks)
  • modules/azure/servicebus/servicebus.go (1 hunks)
  • modules/couchbase/couchbase.go (2 hunks)
  • modules/dockermcpgateway/dockermcpgateway.go (3 hunks)
  • modules/etcd/etcd.go (2 hunks)
  • modules/gcloud/firestore/firestore.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
modules/azure/eventhubs/eventhubs.go (4)
options.go (3)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
  • WithWaitStrategy (366-368)
wait/all.go (1)
  • ForAll (44-48)
wait/host_port.go (1)
  • ForListeningPort (67-69)
wait/http.go (1)
  • ForHTTP (149-151)
modules/azure/servicebus/servicebus.go (2)
modules/azure/servicebus/options.go (1)
  • Option (30-30)
modules/azure/eventhubs/eventhubs.go (1)
  • Container (31-34)
modules/etcd/etcd.go (1)
options.go (2)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
modules/gcloud/firestore/firestore.go (4)
options.go (4)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
  • WithWaitStrategy (366-368)
  • WithCmd (462-467)
wait/all.go (1)
  • ForAll (44-48)
wait/host_port.go (1)
  • ForListeningPort (67-69)
wait/log.go (1)
  • ForLog (118-120)
modules/dockermcpgateway/dockermcpgateway.go (4)
options.go (4)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
  • WithHostConfigModifier (88-94)
  • WithWaitStrategy (366-368)
wait/all.go (1)
  • ForAll (44-48)
wait/host_port.go (1)
  • ForListeningPort (67-69)
wait/log.go (1)
  • ForLog (118-120)
modules/couchbase/couchbase.go (1)
options.go (2)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
⏰ 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). (11)
  • GitHub Check: test (1.25.x, modules/gcloud) / test: modules/gcloud/1.25.x
  • GitHub Check: test (1.24.x, modules/azure) / test: modules/azure/1.24.x
  • GitHub Check: test (1.25.x, modules/etcd) / test: modules/etcd/1.25.x
  • GitHub Check: test (1.24.x, modules/gcloud) / test: modules/gcloud/1.24.x
  • GitHub Check: test (1.24.x, modules/dockermcpgateway) / test: modules/dockermcpgateway/1.24.x
  • GitHub Check: test (1.25.x, modules/couchbase) / test: modules/couchbase/1.25.x
  • GitHub Check: test (1.24.x, modules/couchbase) / test: modules/couchbase/1.24.x
  • GitHub Check: test (1.25.x, modules/dockermcpgateway) / test: modules/dockermcpgateway/1.25.x
  • GitHub Check: test (1.25.x, modules/azure) / test: modules/azure/1.25.x
  • GitHub Check: test (1.24.x, modules/etcd) / test: modules/etcd/1.24.x
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
modules/dockermcpgateway/dockermcpgateway.go (2)

30-38: LGTM! Settings extraction pattern improves consistency.

Extracting settings from custom options before constructing moduleOpts is a cleaner pattern that allows the module to use settings for building commands and handling secrets before finalizing container configuration.


48-60: LGTM! Default module options construction is correct.

The moduleOpts are properly constructed with sensible defaults:

  • Port exposure for the gateway
  • Docker socket binding for container access
  • Appropriate wait strategies (port listening + log pattern)

@mdelapenya mdelapenya merged commit ae0c648 into testcontainers:main Oct 10, 2025
29 checks passed
@mdelapenya mdelapenya deleted the consolidate-patterns branch October 10, 2025 11:37
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