OSAC-3975: extract shared envutil package for adapter env parsing - #288
Conversation
Move requireEnv, envOrDefault, readFileOrFatal, and splitAndTrim from m360-adapter into adapters/envutil/ so both adapters (and future ones) share the same startup helpers instead of re-implementing them inline. Assisted-by: Claude Code <noreply@anthropic.com> Signed-off-by: Amit Oren <amoren@redhat.com>
|
@amito: This pull request references OSAC-3975 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amito The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: osac-project/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
WalkthroughThe change adds shared startup configuration helpers and tests, then updates the Echo and M360 adapters to use them for environment variables, file reads, metrics defaults, and topic parsing. ChangesAdapter configuration standardization
Estimated code review effort: 2 (Simple) | ~15 minutes 🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
|
🤖 Finished Review · ✅ Success · Started 1:59 PM UTC · Completed 2:12 PM UTC Commit: |
ReviewFindingsLow
Labels: PR extracts shared utility package from adapter code — a code-organization refactoring |
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" |
There was a problem hiding this comment.
[low] test-suite-organization
Every other test package in the adapters module places the Ginkgo suite bootstrap in a dedicated *_suite_test.go file. Here, the bootstrap is inlined alongside the specs.
Suggested fix: Extract the bootstrap into envutil_suite_test.go.
|
/lgtm |
045b7c2
Summary
requireEnv,envOrDefault,readFileOrFatal, andsplitAndTrimfrom m360-adapter into a shared adapters/envutil/ package so all adapters use the same startup helpersm360-adapterandecho-adapterto importenvutilinstead of re-implementing env parsing inlineContext
Identified during PR #236 review (OSAC-3424):
m360-adapterextracted reusable helpers while echo-adapter used inlineos.Getenv+ifblocks. Without standardizing, each new adapter would copy one pattern or the other, compounding the inconsistency.Changes
RequireEnv,EnvOrDefault,ReadFileOrFatal,SplitAndTrimenvutil.*imports, remove 37 linesenvutil.*Behavioral note
echo-adapter's
KAFKA_BROKERSerror message changes from"KAFKA_BROKERS is required (comma-separated broker list)"to"KAFKA_BROKERS is required"(standardized viaRequireEnv).Test plan
make testinadapters/— 114 specs pass (67 framework + 15 echo + 23 m360 + 9 envutil)make lintinadapters/— 0 issuesSummary by CodeRabbit
Improvements
Tests