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.78% +0.88%
==========================================
Files 140 141 +1
Lines 13441 13382 -59
==========================================
+ Hits 7783 7867 +84
+ Misses 4470 4307 -163
- Partials 1188 1208 +20 ☔ 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
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))
f45c501 to
ba1392c
Compare
ba1392c to
fbe2335
Compare
6bae3d9 to
26f2d3a
Compare
26f2d3a to
3176657
Compare
Adds a streaming gRPC endpoint for retrieving custom schema FBC
objects as google.protobuf.Struct, indexed during cache build by
(schema, packageName, content-hash).
Key behaviors:
- Empty packageName queries blobs with no package association
- Packageless blobs are stored via PutMeta but excluded from the
package index to avoid creating empty-named packages
- Standard schemas (olm.package, olm.channel, olm.bundle,
olm.deprecation) are excluded — served by existing typed RPCs
- Input validation rejects path traversal characters ("/", "\",
".", "..") at both server and cache layers
- Identical blobs are deduplicated via FNV-64a content hashing
- Cache digest remains backward-compatible with older opm versions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3176657 to
0415704
Compare
Summary
Adds a streaming gRPC endpoint
ListPackageCustomSchemas(schema, packageName)toopm servefor retrieving custom schema FBC objects asgoogle.protobuf.Struct.Design
packageNameis optional — empty string queries custom schema blobs with no package association; non-empty queries blobs scoped to that packagePutMetabut excluded from the package index to avoid creating empty-named packages(schema, packageName, FNV-64a), providing natural deduplication 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)PutMetaruns inside the existingwalkMulock during concurrent cache buildsComputeDigesthashes 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— integrationAGENTS.md— endpoint descriptionMakefile,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 with package index isolation, 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