Add ListPackageCustomSchemas gRPC endpoint to opm serve#1981
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1981 +/- ##
==========================================
+ Coverage 57.90% 58.79% +0.88%
==========================================
Files 140 141 +1
Lines 13441 13373 -68
==========================================
+ Hits 7783 7862 +79
+ Misses 4470 4306 -164
- Partials 1188 1205 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds support for streaming per-package “custom schema” FBC blobs over gRPC, backed by new cache storage primitives in both pogreb and JSON cache backends. This extends the opm serve gRPC surface to expose non-standard schema content without introducing new typed protobuf messages.
Changes:
- Adds
ListPackageCustomSchemas(schema, packageName)server-streaming gRPC RPC returninggoogle.protobuf.Struct. - Extends cache backends with meta blob storage/retrieval keyed by
(schema, packageName)and updates cache build to persist non-standard schemas. - Updates protoc/tooling wiring to include protobuf well-known types (
struct.proto) during codegen.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/ensure-protoc.sh | Downloads protoc include files so well-known protos (e.g., struct.proto) can be imported during codegen. |
| README.md | Documents the new gRPC method in the public list of endpoints. |
| pkg/server/server.go | Implements the new gRPC streaming handler and converts stored JSON blobs into structpb.Struct. |
| pkg/server/server_test.go | Adds integration-style gRPC tests for streaming results, empty results, and invalid-argument behavior. |
| pkg/client/client_test.go | Updates the client stub interface to include the new RPC. |
| pkg/cache/pogrebv1.go | Adds meta blob Put/Send support in the pogreb backend. |
| pkg/cache/meta_key.go | Introduces meta key validation helpers for schema/packageName components. |
| pkg/cache/json.go | Adds meta blob directory layout and Put/Send support in the JSON backend. |
| pkg/cache/cache.go | Extends cache interface + build pipeline to store non-standard schema blobs and expose query method. |
| pkg/cache/cache_test.go | Adds unit tests covering custom schema storage/retrieval and packageless blob skipping. |
| pkg/api/registry.proto | Adds the new RPC and request message; imports google/protobuf/struct.proto. |
| pkg/api/registry.pb.go | Regenerated protobuf Go types (incl. new request type). |
| pkg/api/registry_grpc.pb.go | Regenerated gRPC service stubs (incl. new streaming method). |
| Makefile | Updates protoc include paths used by make codegen. |
| AGENTS.md | Documents the new gRPC method in internal agent docs. |
Files not reviewed (2)
- pkg/api/registry.pb.go: Language not supported
- pkg/api/registry_grpc.pb.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9e6cfcf to
8f19197
Compare
8f19197 to
029eaa4
Compare
318e335 to
4226e11
Compare
Adds a streaming gRPC endpoint for retrieving raw FBC blobs of non-standard (custom) schemas. Blobs are indexed during cache build by (schema, packageName, content-hash) and served via a new ListPackageCustomSchemas RPC. Empty packageName is accepted to query custom schema blobs that have no package association. Standard schemas (olm.package, olm.channel, olm.bundle, olm.deprecation) are excluded — they are served by existing typed RPCs. Input validation for path traversal is applied at both the server (gRPC status codes) and cache layers (defense in depth). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4226e11 to
f45c501
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 16 changed files in this pull request and generated 2 comments.
Files not reviewed (2)
- pkg/api/registry.pb.go: Language not supported
- pkg/api/registry_grpc.pb.go: Language not supported
Comments suppressed due to low confidence (1)
pkg/cache/cache.go:323
- In Build’s WalkMetasFS callback, custom-schema metas with an empty packageName are still appended to byPackageReaders[""] and later written into the package index via
pkgs[pkgName] = pkgIndex[pkgName]. This will cause ListPackages to include an empty package name when packageless custom schema blobs exist. Consider short-circuiting after storing the meta (PutMeta) for non-standard schemas when packageName == "" so they don’t participate in package index construction (and don’t create a pkgs[""] entry).
switch meta.Schema {
case declcfg.SchemaPackage, declcfg.SchemaChannel, declcfg.SchemaBundle, declcfg.SchemaDeprecation:
default:
mk, err := newValidatedMetaKey(meta.Schema, packageName)
if err != nil {
return fmt.Errorf("invalid custom schema meta: %v", err)
}
if err := c.backend.PutMeta(ctx, mk, meta.Blob); err != nil {
return fmt.Errorf("store custom schema meta %v: %v", mk, err)
}
}
if _, err := tmpFile.Write(meta.Blob); err != nil {
return err
}
sr := io.NewSectionReader(tmpFile, offset, int64(len(meta.Blob)))
byPackageReaders[packageName] = append(byPackageReaders[packageName], sr)
offset += int64(len(meta.Blob))
| - `GetLatestChannelEntriesThatProvide(group, version, kind)` - Stream latest entries providing an API | ||
| - `GetDefaultBundleThatProvides(group, version, kind)` - Get default bundle providing an API | ||
| - `ListBundles()` - Stream all bundles | ||
| - `ListPackageCustomSchemas(schema, packageName)` - Stream raw FBC blobs for a non-standard schema scoped to a package |
| GetBundleThatReplaces | ||
| GetChannelEntriesThatProvide | ||
| GetChannelEntriesThatReplace | ||
| ListPackageCustomSchemas | ||
| GetDefaultBundleThatProvides |
Summary
Adds a streaming gRPC endpoint
ListPackageCustomSchemas(schema, packageName)toopm servefor retrieving raw FBC blobs of non-standard (custom) schemas.Design
packageNameis optional — empty string queries custom schema blobs with no package association; non-empty queries blobs scoped to that package(schema, packageName)are supported; the caller decides whether multiple results are expected or an error(schema, packageName, FNV-64a), providing natural deduplication of identical blobs without build-time counters or ordering stateolm.package,olm.channel,olm.bundle,olm.deprecationare served by existing typed RPCs/,\,..) rejected at both server (codes.InvalidArgument) and cache layers (defense in depth)ComputeDigesthashes all cache contents agnostically, so caches built by this version are usable by older opm versions without digest mismatchChanges
registry.proto— newListPackageCustomSchemasstreaming RPCcache.go,meta_key.go—ListPackageCustomSchemasonCacheinterface,metaKeyvalidationpogrebv1.go,json.go—PutMeta/SendMetaswith content-hash keysserver.go— streaming handler with input validationmeta_key_test.go— validation edge cases;cache_test.go,server_test.go— integrationMakefile,ensure-protoc.sh— well-known proto includes; protoc v5.27.0, protoc-gen-go v1.36.11Test plan
go build ./...go test ./pkg/cache/...— storage, retrieval, multiple blobs per key, packageless blobs, empty results, validation edge cases (both backends)go test ./pkg/server/...— end-to-end gRPC streaming, packageless queries, empty results,InvalidArgumentvalidationgo test ./pkg/client/...— stub compatibility🤖 Generated with Claude Code