Skip to content

Conversation

@mdelapenya
Copy link
Member

@mdelapenya mdelapenya commented Oct 9, 2025

What does this PR do?

Use the Run function in valkey

Why is it important?

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

Related issues

mdelapenya and others added 3 commits October 9, 2025 16:15
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
This commit migrates the valkey module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Use entrypoint for valkey-server process and WithCmd/WithCmdArgs for arguments
- Simplify WithConfigFile to prepend config file as first argument
- Simplify WithLogLevel and WithSnapshotting to use WithCmdArgs directly
- Process custom options before building module options for TLS support
- Update option tests to reflect entrypoint-based approach

Ref: testcontainers#3174

🤖 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 9, 2025 14:46
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Oct 9, 2025
@mdelapenya mdelapenya self-assigned this Oct 9, 2025
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Oct 9, 2025
@mdelapenya mdelapenya closed this Oct 9, 2025
@netlify
Copy link

netlify bot commented Oct 9, 2025

Deploy Preview for testcontainers-go ready!

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

@mdelapenya mdelapenya reopened this Oct 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Summary by CodeRabbit

  • Refactor

    • Adopted option-based container configuration for Valkey, simplifying setup.
    • Unified handling of config, log level, and snapshotting via command arguments.
    • Improved TLS setup with automatic cert mounting and stricter file permissions.
    • Clearer, more specific error messages.
  • Bug Fixes

    • Preserves user-supplied commands without prepending a server binary.
    • Default config naming aligned to valkey.conf.
    • Snapshot settings normalized for zero values.
  • Tests

    • Updated tests to reflect new command handling and config naming.

Walkthrough

Refactors valkey module to use option-based testcontainers.Run with WithCmd/WithCmdArgs/WithFiles and updated wait strategy/TLS handling. Tests are adjusted to remove automatic server binary prefixing and to align expectations with the new option-driven command construction and config naming.

Changes

Cohort / File(s) Summary
Valkey module option-based refactor
modules/valkey/valkey.go
Replaces manual ContainerRequest/Cmd manipulation with moduleOpts and testcontainers.Run; adds option-driven TLS mounting/args and file modes; reworks WithConfigFile/WithLogLevel/WithSnapshotting to use WithCmd/WithCmdArgs/WithFiles; updates wait strategy composition and error handling.
Tests alignment with new command construction
modules/valkey/options_test.go
Updates expected command sequences to drop automatic valkeyServerProcess prefix; switches config reference to valkey.conf; normalizes snapshotting tests and adds zero-values normalization case; adjusts log level and save options expectations.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as Caller
  participant V as Valkey.Run
  participant TC as testcontainers.Run
  participant C as Container

  U->>V: Run(ctx, image, opts...)
  V->>V: Build moduleOpts (ExposedPorts, Entrypoint)
  alt TLS enabled
    V->>V: Add TLS files and args (WithFiles, WithCmdArgs)
  end
  opt Config file provided
    V->>V: WithFiles(config), WithCmd(config path)
  end
  opt Log level/snapshotting
    V->>V: WithCmdArgs(--loglevel/--save ...)
  end
  V->>TC: Run(ctx, image, moduleOpts..., opts...)
  TC-->>V: Container or error
  V-->>U: Container or wrapped error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • stevenh

Poem

A bunny taps the Run command, hop!
Options bloom where fields once flop.
TLS carrots safely stowed,
Config trails in tidy mode.
Logs and saves now neatly spun—
Thump-thump: refactor’s done. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “chore(valkey): use Run function” succinctly captures the primary change of migrating the valkey module to leverage the new Run function and aligns directly with the modifications in the code. It is concise, clear, and specific enough for a reviewer scanning the history to understand the main intent without unnecessary detail. It avoids generic or vague wording and reflects the core update.
Description Check ✅ Passed The description clearly explains what the PR does—using the Run function in valkey—why it matters for API consistency, and references the related upstream issue. It directly relates to the changes in both tests and implementation and provides relevant context for reviewers.
✨ 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 88f1499 and d51a682.

📒 Files selected for processing (2)
  • modules/valkey/options_test.go (4 hunks)
  • modules/valkey/valkey.go (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
modules/valkey/options_test.go (1)
modules/valkey/valkey.go (1)
  • WithConfigFile (151-168)
modules/valkey/valkey.go (4)
modules/valkey/options.go (1)
  • Option (22-22)
options.go (8)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
  • WithEntrypoint (438-443)
  • WithCmdArgs (470-475)
  • WithFiles (524-529)
  • WithWaitStrategy (366-368)
  • WithCmd (462-467)
  • CustomizeRequestOption (28-28)
container.go (1)
  • ContainerFile (110-115)
generic.go (1)
  • GenericContainerRequest (21-27)

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 225ad7f into testcontainers:main Oct 9, 2025
17 checks passed
@mdelapenya mdelapenya deleted the use-run-claude-valkey branch October 9, 2025 16:07
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