Skip to content

Comments

refactor: use RequiredPlugins to decide if transitive enrichers should be enabled#2526

Merged
G-Rath merged 1 commit intogoogle:mainfrom
ackama:refactor/plugin-checking
Feb 23, 2026
Merged

refactor: use RequiredPlugins to decide if transitive enrichers should be enabled#2526
G-Rath merged 1 commit intogoogle:mainfrom
ackama:refactor/plugin-checking

Conversation

@G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Feb 17, 2026

Relates to #2537

@G-Rath G-Rath force-pushed the refactor/plugin-checking branch from c51cd96 to 42ed804 Compare February 22, 2026 22:56
@G-Rath G-Rath marked this pull request as ready for review February 22, 2026 22:56
if !actions.TransitiveScanning.Disabled {
// TODO: Use Enricher.RequiredPlugins to check this generically
if isRequirementsExtractorEnabled(plugins) {
if areRequiredPluginsEnabled(plugins, transitivedependencyrequirements.Enricher{}) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is probably relevant for #2537: I'm building the struct manually rather than using enricher.New because the latter actually does some work initializing API clients and such (which in some cases might even lead to an API request?).

I'm not sure if we can avoid that if we move to using a preset with our current structure

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should be able to use New(), no network requests are made there. (The http clients just create a struct, the deps.dep gRPC clients are lazily initiated, no connection is opened until the first request is made)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it seems a little odd, but the best I can think of to deal with this without too much change would be to have some kind of IsForRequirementChecks flag in cpb.PluginConfig, with which ideally plugins should do:

// New creates a new Enricher.
func New(cfg *cpb.PluginConfig) (enricher.Enricher, error) {
	if cfg.IsForRequirementChecks {
		return Enricher{}, nil
	}
	// ...
}

🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not quite following, why do we need a separate initialisation for IsRequirements check?

Copy link
Collaborator

@another-rex another-rex Feb 22, 2026

Choose a reason for hiding this comment

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

I was thinking we setup all the plugins, then do a loop and remove plugins that don't have their requirements met. Described in #2537

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah I posted that a couple of minutes after you posted your comment saying that we were ok with just always calling New.

I've had a look at the code paths and it looks like at most what we end up doing is potentially loading in some TLS PEM store stuff, but most of it does look very lazy (i.e. assigning a setupThisThing function field to be called later), and with no API calls being made.

Personally I'm still not the biggest fan of how much work it appears that we would be doing, but I don't think there's an easy way around that because Go 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this works for now but longer term I prefer to do all the checks in scalibrplugin.Resolve()

@G-Rath G-Rath force-pushed the refactor/plugin-checking branch from 42ed804 to dcc0d6d Compare February 23, 2026 00:24
@G-Rath G-Rath enabled auto-merge (squash) February 23, 2026 00:29
@codecov-commenter
Copy link

codecov-commenter commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.89%. Comparing base (a750891) to head (9ba99fe).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2526      +/-   ##
==========================================
- Coverage   67.92%   67.89%   -0.03%     
==========================================
  Files         172      172              
  Lines       13395    13395              
==========================================
- Hits         9098     9094       -4     
- Misses       3581     3583       +2     
- Partials      716      718       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@G-Rath G-Rath force-pushed the refactor/plugin-checking branch from dcc0d6d to e5f45d0 Compare February 23, 2026 00:36
@G-Rath G-Rath force-pushed the refactor/plugin-checking branch from e5f45d0 to 9ba99fe Compare February 23, 2026 00:36
@G-Rath G-Rath merged commit 5c9b892 into google:main Feb 23, 2026
16 of 17 checks passed
@G-Rath G-Rath deleted the refactor/plugin-checking branch February 23, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants