Repository navigation
refactor: mv collector to subpackage - #4424
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughMakefile centralizes collector paths (ROOT_DIR, COLLECTOR_DIR, COLLECTOR_RELEASE_OUTPUT_DIR), adds a release-output helper that validates GOOS/GOARCH, and updates build targets to run from ./collector. The Docker builder now downloads and builds using the collector module (go mod download -C ./collector; go build -C ./collector ./cmd). ChangesCollector Build Module Independence
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
19 Open source vulnerabilities detected - critical severity
Aikido detected 19 vulnerabilities across 12 packages, it includes 2 critical, 6 high, 9 medium and 2 low vulnerabilities.
Details
Remediation Aikido suggests bumping the vulnerable packages to a safe version.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
There was a problem hiding this comment.
4 Open source vulnerabilities detected - high severity
Aikido detected 4 vulnerabilities across 2 packages, it includes 3 high and 1 medium vulnerabilities.
Details
Remediation Aikido suggests bumping the vulnerable packages to a safe version.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@benthos-collector.Dockerfile`:
- Line 14: Remove the trailing whitespace in the Dockerfile ENV declaration;
edit the line containing ENV GOMODCACHE=/go/pkg/mod (the ENV GOMODCACHE
assignment) so it ends exactly with "/go/pkg/mod" with no extra spaces or tabs
after it to fix formatting.
In `@Makefile`:
- Around line 118-124: The outdir variable is wrong for commands run from the
repo root: change outdir="../build/release/benthos-collector_$(GOOS)_$(GOARCH)"
to a repo-root relative path (e.g.
outdir="build/release/benthos-collector_$(GOOS)_$(GOARCH)") so rm -rf
"$$outdir", mkdir -p "$$outdir" and cp README.md LICENSE "$$outdir/" operate
inside the repo; keep the go build -C ./collector -o "$$outdir/benthos"
invocation (it will correctly write the binary into the repo-relative outdir).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f2b951ab-7ec3-490b-b890-91bf92fb955d
⛔ Files ignored due to path filters (4)
collector/go.modis excluded by!**/*.modcollector/go.sumis excluded by!**/*.sum,!**/*.sumgo.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (4)
Makefilebenthos-collector.Dockerfilecollector/cmd/main.gocollector/cmd/version.go
f67b827 to
86bbf0a
Compare
86bbf0a to
2894a72
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Makefile`:
- Line 130: The cleanup command is quoting the glob so the shell won't expand
the asterisk; update the rm invocation that uses COLLECTOR_RELEASE_OUTPUT_DIR so
the directory path is quoted but the wildcard is outside the quotes (e.g. change
the current "`@rm` -rf \"$(COLLECTOR_RELEASE_OUTPUT_DIR)/*\" && \" to use
"$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* or an equivalent unquoted glob), ensuring
the directory contents are actually removed while still safely quoting the
variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6db12db0-e635-4ef1-bec5-147751bdab23
⛔ Files ignored due to path filters (4)
collector/go.modis excluded by!**/*.modcollector/go.sumis excluded by!**/*.sum,!**/*.sumgo.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (4)
Makefilebenthos-collector.Dockerfilecollector/cmd/main.gocollector/cmd/version.go
2894a72 to
1994782
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
Makefile (1)
130-130:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix release output cleanup: quoted glob prevents expansion
The
*is inside the quotes, so the shell won't expand it—you'll just try to remove a literal file named*instead of the directory contents.💡 Suggested fix
- `@rm` -rf "$(COLLECTOR_RELEASE_OUTPUT_DIR)/*" && \ + `@rm` -rf "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* && \🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Makefile` at line 130, The Makefile cleanup command uses a quoted glob "$(COLLECTOR_RELEASE_OUTPUT_DIR)/*" which prevents shell expansion; change the command that removes release output (the rm -rf invocation referencing COLLECTOR_RELEASE_OUTPUT_DIR) to allow globbing by moving the wildcard outside the quotes (e.g., use "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* or unquoted DIR/*) so the directory contents are deleted correctly, and keep quoting only around the variable itself to preserve spaces in the path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@Makefile`:
- Line 130: The Makefile cleanup command uses a quoted glob
"$(COLLECTOR_RELEASE_OUTPUT_DIR)/*" which prevents shell expansion; change the
command that removes release output (the rm -rf invocation referencing
COLLECTOR_RELEASE_OUTPUT_DIR) to allow globbing by moving the wildcard outside
the quotes (e.g., use "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* or unquoted DIR/*) so
the directory contents are deleted correctly, and keep quoting only around the
variable itself to preserve spaces in the path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9b9ed760-8e8b-4c32-a9be-33aedc922757
⛔ Files ignored due to path filters (4)
collector/go.modis excluded by!**/*.modcollector/go.sumis excluded by!**/*.sum,!**/*.sumgo.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (4)
Makefilebenthos-collector.Dockerfilecollector/cmd/main.gocollector/cmd/version.go
1994782 to
d096946
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
benthos-collector.Dockerfile (1)
22-27: ⚡ Quick winYou can drop the root-module
go mod downloadin this image path.Now that the build is fully collector-module based, keeping both root and collector dependency downloads adds extra build time/cache churn for little value.
💡 Suggested simplification
-COPY --link go.mod go.sum ./ - -RUN --mount=type=cache,target=/go/pkg/mod \ - --mount=type=cache,target=/go/cache \ - go mod download -x - COPY --link collector/go.mod collector/go.sum ./collector/ RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/go/cache \ go mod download -C ./collector -x🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@benthos-collector.Dockerfile` around lines 22 - 27, Remove the redundant root-module dependency download and keep only the collector-module download: delete any earlier RUN that executes "go mod download" for the root module so the only dependency fetch is the existing "go mod download -C ./collector -x" (the COPY --link collector/go.mod collector/go.sum ./collector/ and the RUN mounting caches + go mod download -C ./collector -x should remain). This eliminates extra build time and cache churn while preserving module-scoped dependency resolution.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Makefile`:
- Line 5: The global default VERSION ?= unknown prevents existing guards like if
[ -z "$(VERSION)" ] from detecting a missing version; remove the global VERSION
?= unknown line from the Makefile so VERSION remains unset by default (or make
it explicitly empty), and either set VERSION only in the specific
release/publish target or update the guards (the if [ -z "$(VERSION)" ] checks)
to also reject the literal "unknown" (e.g., test for -z or = "unknown") so
targets requiring an explicit version fail fast.
---
Nitpick comments:
In `@benthos-collector.Dockerfile`:
- Around line 22-27: Remove the redundant root-module dependency download and
keep only the collector-module download: delete any earlier RUN that executes
"go mod download" for the root module so the only dependency fetch is the
existing "go mod download -C ./collector -x" (the COPY --link collector/go.mod
collector/go.sum ./collector/ and the RUN mounting caches + go mod download -C
./collector -x should remain). This eliminates extra build time and cache churn
while preserving module-scoped dependency resolution.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 256df2dc-2c9b-41f1-9373-0a8b8eaf419b
⛔ Files ignored due to path filters (4)
collector/go.modis excluded by!**/*.modcollector/go.sumis excluded by!**/*.sum,!**/*.sumgo.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (4)
Makefilebenthos-collector.Dockerfilecollector/cmd/main.gocollector/cmd/version.go
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Makefile (1)
128-129: 💤 Low valueRedundant validation – the order-only prereq already checks these.
Lines 128-129 duplicate the
GOOS/GOARCHvalidation that's already in thecollector-release-output-dirprerequisite (lines 118-119). You can drop these lines safely.♻️ Proposed cleanup
build-benthos-collector-release: | collector-release-output-dir ## Cross-compile benthos-collector for release (set GOOS/GOARCH/VERSION) $(call print-target) - $(if $(GOOS),,$(error GOOS is not set)) - $(if $(GOARCH),,$(error GOARCH is not set)) `@rm` -rf "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* && \🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Makefile` around lines 128 - 129, Remove the redundant GOOS/GOARCH checks by deleting the two lines `$(if $(GOOS),,$(error GOOS is not set))` and `$(if $(GOARCH),,$(error GOARCH is not set))` from the Makefile; the target prerequisite `collector-release-output-dir` already performs these order-only validations, so keep that prerequisite and remove these duplicate checks to avoid repetition.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Makefile`:
- Around line 128-129: Remove the redundant GOOS/GOARCH checks by deleting the
two lines `$(if $(GOOS),,$(error GOOS is not set))` and `$(if $(GOARCH),,$(error
GOARCH is not set))` from the Makefile; the target prerequisite
`collector-release-output-dir` already performs these order-only validations, so
keep that prerequisite and remove these duplicate checks to avoid repetition.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 594aebe9-c700-4d4d-b4ba-71a9203a9e17
⛔ Files ignored due to path filters (4)
collector/go.modis excluded by!**/*.modcollector/go.sumis excluded by!**/*.sum,!**/*.sumgo.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (4)
Makefilebenthos-collector.Dockerfilecollector/cmd/main.gocollector/cmd/version.go
d096946 to
c95d678
Compare
Signed-off-by: Krisztian Gacsal <[email protected]>
c95d678 to
de879e5
Compare
Overview
Move
benthos-collectorto a sub-module in order to isolate its dependencies fromopenmeterservices.Releasing the collector as binary and container image has not changed.
Releasing the
collectoras a separate go module is not implemented in this PR however can be added later on if there is a need for it.Summary by CodeRabbit