-
-
Notifications
You must be signed in to change notification settings - Fork 590
chore(azurite): use Run function #3318
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
Conversation
We have hit the classic “typed-nil inside an interface” pitfall: in eventhubs (and probably other modules) "c.Container != nil" is true because the interface is non-nil, but it holds a nil *DockerContainer. Calling its method dereferences a nil receiver and panics inside the Terminate method.
Summary by CodeRabbit
WalkthroughRefactors Azure modules to use testcontainers.Run with option-based configuration, adds EULA validation as a request customizer, updates tests to cleanup containers earlier, and introduces a nil-receiver guard in DockerContainer.Terminate. Azurite, EventHubs, and ServiceBus flows now compose With* options for ports, env, wait strategies, networking, and commands. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer Code
participant Mod as Module.Run (EventHubs/ServiceBus)
participant Opts as Module Options (With*, validateEula)
participant TC as testcontainers.Run
participant Eng as Docker Engine
Dev->>Mod: Run(ctx, img, userOpts...)
Mod->>Opts: Build moduleOpts (WithExposedPorts/WithEnv/WithCmd/WithWaitStrategy/WithNetwork)
Mod->>Opts: Append validateEula
Mod->>TC: Run(ctx, img, moduleOpts...)
TC->>TC: Apply options in order
TC->>TC: validateEula checks ACCEPT_EULA
alt EULA not accepted
TC-->>Mod: error ("EULA not accepted")
Mod-->>Dev: error
else EULA accepted
TC->>Eng: Create & start container
Eng-->>TC: container handle
TC-->>Mod: container
Mod-->>Dev: container
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (9)
🧰 Additional context used🧬 Code graph analysis (8)modules/azure/eventhubs/eventhubs.go (8)
modules/azure/servicebus/options.go (2)
modules/azure/azurite/options.go (1)
modules/azure/servicebus/servicebus.go (3)
modules/azure/eventhubs/options.go (2)
modules/azure/servicebus/servicebus_test.go (1)
modules/azure/azurite/azurite.go (4)
modules/azure/eventhubs/eventhubs_test.go (1)
⏰ 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)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Comment |
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| // Default: timeout is 10 seconds. | ||
| func (c *DockerContainer) Terminate(ctx context.Context, opts ...TerminateOption) error { | ||
| if c == nil { | ||
| return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this nil-guard after finding that we have hit the classic “typed-nil inside an interface” pitfall: in eventhubs (and probably other modules) c.Container != nil is true because the interface is non-nil, but it holds a nil *DockerContainer. Calling its method dereferences a nil receiver and panics inside the Terminate method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Migrates Azure modules (Azurite, EventHubs, and ServiceBus) from the legacy GenericContainer API to the new Run function API and adds a nil check to prevent failures during container termination.
- Refactors module initialization code to use testcontainers.Run instead of testcontainers.GenericContainer
- Simplifies option handling by using new testcontainers helper functions
- Adds nil safety check in DockerContainer.Terminate method
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| modules/azure/servicebus/servicebus.go | Migrates ServiceBus module to use Run function with modular options approach |
| modules/azure/servicebus/options.go | Adds validateEula function and updates imports |
| modules/azure/servicebus/servicebus_test.go | Updates test to use CleanupContainer instead of asserting nil container |
| modules/azure/eventhubs/eventhubs.go | Migrates EventHubs module to use Run function with modular options approach |
| modules/azure/eventhubs/options.go | Adds validateEula function and simplifies WithAcceptEULA using testcontainers.WithEnv |
| modules/azure/eventhubs/eventhubs_test.go | Updates test to use CleanupContainer instead of asserting nil container |
| modules/azure/azurite/azurite.go | Migrates Azurite module to use Run function with modular options approach |
| modules/azure/azurite/options.go | Simplifies WithInMemoryPersistence using testcontainers.WithCmdArgs |
| docker.go | Adds nil check to prevent termination failures when container is nil |
Comments suppressed due to low confidence (1)
modules/azure/azurite/azurite.go:1
- [nitpick] The cmd slice is declared outside the return statement but could be constructed inline. Consider moving the slice construction inside the return statement or declaring it where it's used to improve readability.
package azurite
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
What does this PR do?
Use Run function in the Azure modules
Why is it important?
Migrate modules to the new API
Related issues