Skip to content

Commit 63e5d82

Browse files
authored
feat(controlplane): filter referrer discovery by project name and version (#3158)
1 parent da086e1 commit 63e5d82

15 files changed

Lines changed: 544 additions & 29 deletions

app/cli/pkg/action/referrer_discover.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func NewReferrerDiscoverPublicIndex(cfg *ActionsOpts) *ReferrerDiscoverPublic {
6767
return &ReferrerDiscoverPublic{cfg}
6868
}
6969

70+
// Run calls the deprecated public shared index RPC, kept for backwards compatibility.
71+
//
72+
//nolint:staticcheck // the RPC is deprecated but still supported
7073
func (action *ReferrerDiscoverPublic) Run(ctx context.Context, digest, kind string, p *PaginationOpts) (*ReferrerDiscoverResult, error) {
7174
client := pb.NewReferrerServiceClient(action.cfg.CPConnection)
7275
resp, err := client.DiscoverPublicShared(ctx, &pb.DiscoverPublicSharedRequest{

app/controlplane/api/controlplane/v1/referrer.pb.go

Lines changed: 37 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/controlplane/v1/referrer.proto

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ service ReferrerService {
3636
};
3737
}
3838
// DiscoverPublicShared returns the referrer item for a given digest in the public shared index
39+
// Deprecated: the public shared index is being retired.
3940
rpc DiscoverPublicShared(DiscoverPublicSharedRequest) returns (DiscoverPublicSharedResponse) {
41+
option deprecated = true;
4042
option (google.api.http) = {get: "/discover/shared/{digest}"};
4143
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
4244
summary: "Discover public shared referrer"
@@ -60,6 +62,20 @@ message ReferrerServiceDiscoverPrivateRequest {
6062
string kind = 2;
6163
// Pagination options for the references list
6264
CursorPaginationRequest pagination = 3;
65+
// ProjectName optionally scopes the discovery to a project by name. Can be set on its own
66+
// (project-wide filter) or together with project_version (project + version filter).
67+
string project_name = 4;
68+
// ProjectVersion optionally scopes the discovery to a project version (by name, e.g. v1.2.0).
69+
// Requires project_name, since a version name is unique only within a project.
70+
string project_version = 5;
71+
72+
// project_version requires project_name (a version name is unique only within a project);
73+
// project_name on its own is allowed.
74+
option (buf.validate.message).cel = {
75+
id: "discover_project_version_requires_project_name"
76+
expression: "!(this.project_version != '' && this.project_name == '')"
77+
message: "project_name must be set when project_version is set"
78+
};
6379

6480
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
6581
json_schema: {
@@ -70,7 +86,10 @@ message ReferrerServiceDiscoverPrivateRequest {
7086
}
7187

7288
// DiscoverPublicSharedRequest is the request for the DiscoverPublicShared method
89+
// Deprecated: the public shared index is being retired.
7390
message DiscoverPublicSharedRequest {
91+
option deprecated = true;
92+
7493
// Digest is the unique identifier of the referrer to discover
7594
string digest = 1 [(buf.validate.field).string = {min_len: 1}];
7695
// Kind is the optional type of referrer, i.e CONTAINER_IMAGE, GIT_HEAD, ...

app/controlplane/api/controlplane/v1/referrer_grpc.pb.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/controlplane/v1/referrer_http.pb.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/frontend/controlplane/v1/referrer.ts

Lines changed: 49 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.DiscoverPublicSharedRequest.jsonschema.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.DiscoverPublicSharedRequest.schema.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.ReferrerServiceDiscoverPrivateRequest.jsonschema.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.ReferrerServiceDiscoverPrivateRequest.schema.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)