Add extensible source providers - #429
Merged
ashutosh-narkar merged 1 commit intoSep 30, 2026
Merged
Conversation
ashutosh-narkar
force-pushed
the
ext-source-provider
branch
from
September 28, 2026 21:47
a4e20d9 to
fb383c3
Compare
ashutosh-narkar
marked this pull request as ready for review
September 28, 2026 22:08
srenatus
approved these changes
Sep 29, 2026
srenatus
left a comment
Contributor
There was a problem hiding this comment.
Small fry only, thanks!
| providers: | ||
| - name: users | ||
| type: example.custom-source | ||
| param1: value |
Contributor
There was a problem hiding this comment.
Would it be possible to have a provider registered for E2E test purposes? So we could have a positive tests here, too.
| @@ -46,6 +46,7 @@ func Migrations(dialect string) (fs.FS, error) { | |||
| addSourcesGitCredentialsName(25, dialect), | |||
| addBundlesStatuses(26, dialect), | |||
| addBundlesStatusesUpdatedAt(27, dialect), // adds 2, next is 29. | |||
Contributor
There was a problem hiding this comment.
Suggested change
| addBundlesStatusesUpdatedAt(27, dialect), // adds 2, next is 29. | |
| addBundlesStatusesUpdatedAt(27, dialect), |
| return config.Requirement{Source: &name, Path: path, Prefix: prefix} | ||
| } | ||
|
|
||
| func intPtr(i int) *int { return &i } |
Contributor
There was a problem hiding this comment.
[nit] So we still need this these days? new(10) might do the same 🤔
|
|
||
| // If any source manifest specifies roots, use those. Log if they differ from computed. | ||
| for _, m := range sourceManifests { | ||
| manifestRootsFrom := "" // source whose .manifest roots replaced the computed ones |
Contributor
There was a problem hiding this comment.
nested claimed roots fail when a .manifest sets roots. One provider claims ["lazy/users", "lazy"], and another source's .manifest sets roots: ["app"]. The build fails with:
source "provider" claims root "lazy", which overlaps root "lazy/users" from the .manifest of source "git"
Member
Author
There was a problem hiding this comment.
Good catch. Fixed and added tests to cover this.
OCP's source types are hard-coded. Projects that embed OCP as a library and need to build bundles from other kinds of sources currently have to fork OCP or upstream every new type. This adds a way to register custom source types programmatically. Providers are Go code registered through the public API of pkg/service. They then work like the built-in sources: they're configured on a source, synced by the bundle workers, and built into the same bundles. Fixes: open-policy-agent#361 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
ashutosh-narkar
force-pushed
the
ext-source-provider
branch
from
September 29, 2026 19:52
1c9f5b2 to
5c4279d
Compare
ashutosh-narkar
merged commit Sep 30, 2026
a8aed0b
into
open-policy-agent:main
13 of 14 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
OCP's source types are hard-coded. Projects that embed OCP as a
library and need to build bundles from other kinds of sources currently
have to fork OCP or upstream every new type.
This adds a way to register custom source types programmatically. Providers are
Go code registered through the public API of
pkg/service. They then work likethe built-in sources: they're configured on a source, synced by the bundle workers,
and built into the same bundles.
Some changes
pkg/sync:SourceProviderandSourceProviderRegistry. A providerdeclares its
Type, a JSON Schema for its configuration,Parseforvalidation, and
Newto create aSynchronizer. Its synchronizer canoptionally implement
BundleContributorto add manifest metadata, claimroots it has no files for, or set the Rego version of its content.
providers:list on sources.nameandtypearerequired;
pathoptionally prefixes the entry's content; all other keysgo to the provider.
sources_providerstable (migration 29). As withrequirements, a source without
providersleaves stored entries in place,and
providers: []removes them.pkg/sync.Synchronizer.Executenow returns(map[string]any, error)instead oferror.Example
Registering a provider:
Using it in a source:
Fixes: #361