Skip to content

refactor(detector): Attempt to add WithStoreProvider, including interface definitions#19927

Draft
Stringy wants to merge 1 commit intogiles/ROX-33799-refactor-detector-constructorfrom
giles/refactor-store-provider-detector-builder
Draft

refactor(detector): Attempt to add WithStoreProvider, including interface definitions#19927
Stringy wants to merge 1 commit intogiles/ROX-33799-refactor-detector-constructorfrom
giles/refactor-store-provider-detector-builder

Conversation

@Stringy
Copy link
Copy Markdown
Contributor

@Stringy Stringy commented Apr 9, 2026

Description

change me!

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

change me!

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 9, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@Stringy Stringy changed the title Attempt to add WithStoreProvider, including interface definitions refactor(detector): Attempt to add WithStoreProvider, including interface definitions Apr 9, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new WithStoreProvider on detector.Builder now overlaps with the existing WithXStore/With*LabelProvider methods; consider either deprecating the more granular setters or documenting/preventing mixed usage so it’s clear which values win if both are called.
  • There are now two different StoreProvider types (the new detector.StoreProvider interface and the existing Kubernetes StoreProvider struct) with the same name in different packages; consider renaming one (e.g. DetectorStoreProvider or ReadOnlyStoreProvider) to reduce ambiguity when reading or searching the codebase.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `WithStoreProvider` on `detector.Builder` now overlaps with the existing `WithXStore`/`With*LabelProvider` methods; consider either deprecating the more granular setters or documenting/preventing mixed usage so it’s clear which values win if both are called.
- There are now two different `StoreProvider` types (the new `detector.StoreProvider` interface and the existing Kubernetes `StoreProvider` struct) with the same name in different packages; consider renaming one (e.g. `DetectorStoreProvider` or `ReadOnlyStoreProvider`) to reduce ambiguity when reading or searching the codebase.

## Individual Comments

### Comment 1
<location path="sensor/common/detector/builder.go" line_range="26-34" />
<code_context>
 	"github.com/stackrox/rox/sensor/common/updater"
 )

+// StoreProvider provides access to the stores needed by the detector.
+type StoreProvider interface {
+	Deployments() store.DeploymentStore
+	ServiceAccounts() store.ServiceAccountStore
+	NetworkPolicies() store.NetworkPolicyStore
+	Nodes() store.NodeStore
+	Registries() registry.Provider
+	ClusterLabels() scopecomp.ClusterLabelProvider
+	NamespaceLabels() scopecomp.NamespaceLabelProvider
+}
+
</code_context>
<issue_to_address>
**suggestion:** Consider reusing or embedding the existing store.Provider to avoid overlapping store-provider abstractions.

This new StoreProvider overlaps with sensor/common/store.Provider (Deployments, ServiceAccounts, NetworkPolicies, Nodes, Registries). To avoid drift between two similar interfaces, consider either accepting store.Provider here and defining a separate interface only for the label providers, or embedding store.Provider in StoreProvider and adding ClusterLabels/NamespaceLabels. That keeps the API smaller and reduces divergence risk.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +26 to +34
// StoreProvider provides access to the stores needed by the detector.
type StoreProvider interface {
Deployments() store.DeploymentStore
ServiceAccounts() store.ServiceAccountStore
NetworkPolicies() store.NetworkPolicyStore
Nodes() store.NodeStore
Registries() registry.Provider
ClusterLabels() scopecomp.ClusterLabelProvider
NamespaceLabels() scopecomp.NamespaceLabelProvider
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider reusing or embedding the existing store.Provider to avoid overlapping store-provider abstractions.

This new StoreProvider overlaps with sensor/common/store.Provider (Deployments, ServiceAccounts, NetworkPolicies, Nodes, Registries). To avoid drift between two similar interfaces, consider either accepting store.Provider here and defining a separate interface only for the label providers, or embedding store.Provider in StoreProvider and adding ClusterLabels/NamespaceLabels. That keeps the API smaller and reduces divergence risk.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

🚀 Build Images Ready

Images are ready for commit ba301fe. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.11.x-578-gba301fe9a6

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 5.55556% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.57%. Comparing base (50d4e56) to head (ba301fe).

Files with missing lines Patch % Lines
sensor/common/detector/builder.go 0.00% 10 Missing ⚠️
...or/kubernetes/listener/resources/store_provider.go 0.00% 6 Missing ⚠️
sensor/kubernetes/listener/resources/dispatcher.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                                Coverage Diff                                @@
##           giles/ROX-33799-refactor-detector-constructor   #19927      +/-   ##
=================================================================================
- Coverage                                          49.58%   49.57%   -0.02%     
=================================================================================
  Files                                               2764     2764              
  Lines                                             208402   208414      +12     
=================================================================================
- Hits                                              103343   103326      -17     
- Misses                                             97394    97426      +32     
+ Partials                                            7665     7662       -3     
Flag Coverage Δ
go-unit-tests 49.57% <5.55%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant