Forward host environment variables to the emulator container#161
Forward host environment variables to the emulator container#161
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughHost environment variables with prefix Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/container/start_test.go`:
- Line 72: Replace the unchecked defer os.Setenv("CI", originalCI) with a
t.Cleanup that restores the env and handles errors: inside the test (in
start_test.go) register t.Cleanup(func() { if err := os.Setenv("CI",
originalCI); err != nil { t.Fatalf("failed to restore CI env: %v", err) } }) so
the environment is restored reliably and the error from os.Setenv is not
ignored; alternatively, if available use t.Setenv to manage the variable
automatically.
- Around line 85-103: The test is rebuilding the env-forwarding logic instead of
exercising the real implementation and also ignores the os.Setenv error; extract
the host environment collection into a testable function (e.g., collectHostEnv
in start.go) that iterates os.Environ() and filters entries with
strings.HasPrefix(e, "CI=") or the LOCALSTACK_ rules, update Start to call
collectHostEnv, then rewrite the test to call collectHostEnv directly (in
start_test.go) and assert presence/absence of "CI=" using strings.HasPrefix
checks; also handle os.Setenv/os.Unsetenv return values (check and/or use
t.Cleanup and os.LookupEnv to restore original state) so no env-setting errors
are ignored.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 892049f8-b49a-4036-8d20-0d575e08580c
📒 Files selected for processing (2)
internal/container/start.gointernal/container/start_test.go
d784aba to
1384ec6
Compare
56a6a8f to
2d8e0ec
Compare
carole-lavillonniere
left a comment
There was a problem hiding this comment.
It looks good!
|
Thanks for taking another look, @carole-lavillonniere! Rebased to run checks again. ⏳ |
|
@carole-lavillonniere the integration tests were previously failing[1]. Tried to extract the host in a811f69. Checks are now green, but let me know if this still looks good. 🍵 |
Forwards two sets of host environment variables into the LocalStack container at startup, matching the behaviour of the legacy CLI:
CI: ensures LocalStack behaves correctly in CI environments.LOCALSTACK_*: forwards all LocalStack configuration variables set on the host. LOCALSTACK_AUTH_TOKEN is excluded since it is already explicitly injected.