Skip to content

Commit

Permalink
Make federation a first-class citizen
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Nov 5, 2023
1 parent 6e616aa commit a628f73
Show file tree
Hide file tree
Showing 17 changed files with 525 additions and 235 deletions.
92 changes: 53 additions & 39 deletions buf/registry/module/v1beta1/branch.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,54 @@ option go_package = "buf.build/gen/go/bufbuild/registry/protocolbuffers/go/buf/r
message Branch {
option (buf.registry.priv.extension.v1beta1.message).response_only = true;

// The id of the Branch.
// The id of the Branch within the BSR instance denoted by registry_hostname.
string id = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The hostname of the registry of the BSR instance that the Branch is on.
string registry_hostname = 2 [
(buf.validate.field).required = true,
(buf.validate.field).string.hostname = true
];
// The time the Branch was created on the BSR.
google.protobuf.Timestamp create_time = 2 [(buf.validate.field).required = true];
google.protobuf.Timestamp create_time = 3 [(buf.validate.field).required = true];
// The last time the Branch was updated on the BSR.
//
// This is typically the last time a Commit was pushed to the Branch.
google.protobuf.Timestamp update_time = 3 [(buf.validate.field).required = true];
google.protobuf.Timestamp update_time = 4 [(buf.validate.field).required = true];
// The name of the Branch.
//
// Unique within a given Module.
string name = 4 [
string name = 5 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 250
];
// The id of the User or Organization that owns the Module that the Branch is associated with.
string owner_id = 5 [
// The id of the User or Organization within the BSR instance denoted by registry_hostname
// that owns the Module that the Branch is associated with.
string owner_id = 6 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The id of the Module that the Branch is associated with.
string module_id = 6 [
// The id of the Module within the BSR instance denoted by registry_hostname
// that the Branch is associated with.
string module_id = 7 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// True if the Branch is the release Branch for the module.
//
// Only one Branch per module will be marked as the release Branch.
// TODO: enum?
bool is_release = 9 [(buf.validate.field).required = true];
// The id of the latest Commit created on the Branch.
string latest_commit_id = 10 [
bool is_release = 8 [(buf.validate.field).required = true];
// The id of the latest Commit within the BSR instance dennoted by registry_hostname
// created on the Branch.
string latest_commit_id = 9 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The Digest of the latest Commit pushed to the Branch.
buf.registry.storage.v1beta1.Digest latest_commit_digest = 11 [(buf.validate.field).required = true];
buf.registry.storage.v1beta1.Digest latest_commit_digest = 10 [(buf.validate.field).required = true];
}

// BranchRef is a reference to a Branch, either an id or a fully-qualified name.
Expand All @@ -75,35 +83,41 @@ message Branch {
message BranchRef {
option (buf.registry.priv.extension.v1beta1.message).request_only = true;

oneof value {
option (buf.validate.oneof).required = true;
// The id of the Branch.
string id = 1 [(buf.validate.field).string.uuid = true];
// The fully-qualified name of the Branch.
BranchFullName name = 2;
// The fully-qualified name of a Branch within a BSR instance.
//
// A Name uniquely identifies a Branch within a BSR instance.
// This is used for requests when a caller only has the branch name and not the ID.
message Name {
// The name of the User or Organization that owns the Module that contains this Branch.
string owner = 2 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 255
];
// The name of the Module that contains this Branch.
string module = 3 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 255
];
// The name of the Branch.
string branch = 4 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 250
];
}
}

// The fully-qualified name of a Branch within a BSR instance.
//
// A BranchFullName uniquely identifies a Branch.
// This is used for requests when a caller only has the branch name and not the ID.
message BranchFullName {
option (buf.registry.priv.extension.v1beta1.message).request_only = true;

// The name of the User or Organization that owns the Module that contains this Branch.
string owner = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 255
];
// The name of the Module that contains this Branch.
string module = 2 [
// The hostname of the registry of the Buf Schema Registry instance that the Branch is on.
//
// In most circumstances, this must match the hostname of the instance you are calling via the API.
// Where there are exceptions to this, this is specifically noted in the top-level request message.
string registry_hostname = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 255
];
// The name of the Branch.
string branch = 3 [
(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 250
(buf.validate.field).string.hostname = true
];
oneof value {
option (buf.validate.oneof).required = true;
// The id of the Branch within the BSR instance as denoted by registry_hostname.
string id = 2 [(buf.validate.field).string.uuid = true];
// The fully-qualified name of the Branch within the BSR instance as denoted by registry_hostname.
Name name = 3;
}
}
18 changes: 18 additions & 0 deletions buf/registry/module/v1beta1/branch_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,33 @@ service BranchService {

message GetBranchesRequest {
// The Branches to request.
//
// Only Branches with registry_hostnames equal to the hostname of the BSR instance you are
// calling can be referenced, other registry_hostnames will result in an error.
repeated BranchRef branch_refs = 1 [(buf.validate.field).repeated.min_items = 1];
}

message GetBranchesResponse {
// The retreived Branches in the same order as requested.
//
// Only Branches with registry_hostnames equal to the hostname of the BSR instance you are
// calling will be returned.
repeated Branch branches = 1 [(buf.validate.field).repeated.min_items = 1];
}

message GetReleaseBranchesRequest {
// The Modules to request the release Branches for.
//
// Only Modules with registry_hostnames equal to the hostname of the BSR instance you are
// calling can be referenced, other registry_hostnames will result in an error.
repeated ModuleRef module_refs = 1 [(buf.validate.field).repeated.min_items = 1];
}

message GetReleaseBranchesResponse {
// The retrieved release Branches in the same order as requested.
//
// Only Branches with registry_hostnames equal to the hostname of the BSR instance you are
// calling will be returned.
repeated Branch branches = 1 [(buf.validate.field).repeated.min_items = 1];
}

Expand All @@ -78,6 +90,9 @@ message ListBranchesRequest {
// - If a Tag is referenced, all Branches that contain the Tag are returned.
// - If a VCSCommit is referenced, all Branches that contain the VCSCommit are returned.
// - Is a Branch is referenced, this Branch is returned.
//
// Only resources with registry_hostnames equal to the hostname of the BSR instance you are
// calling can be referenced, other registry_hostnames will result in an error.
ResourceRef resource_ref = 3 [(buf.validate.field).required = true];
}

Expand All @@ -87,5 +102,8 @@ message ListBranchesResponse {
/// If empty, there are no more pages.
string next_page_token = 1;
// The listed Branches.
//
// Only Branches with registry_hostnames equal to the hostname of the BSR instance you are
// calling will be returned.
repeated Branch branches = 2;
}
46 changes: 36 additions & 10 deletions buf/registry/module/v1beta1/commit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,62 @@ option go_package = "buf.build/gen/go/bufbuild/registry/protocolbuffers/go/buf/r
message Commit {
option (buf.registry.priv.extension.v1beta1.message).response_only = true;

// The id of the Commit.
// The id of the Commit within the BSR instance denoted by registry_hostname.
string id = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The hostname of the registry of the BSR instance that the Commit is on.
string registry_hostname = 2 [
(buf.validate.field).required = true,
(buf.validate.field).string.hostname = true
];
// The time the Commit was pushed to the BSR.
//
// Commits are immutable, so there is no corresponding update_time.
google.protobuf.Timestamp create_time = 2 [(buf.validate.field).required = true];
// The id of the User or Organization that owns the Module that the Commit is associated with.
string owner_id = 3 [
google.protobuf.Timestamp create_time = 3 [(buf.validate.field).required = true];
// The id of the User or Organization within the BSR instance denoted by registry_hostname
// that owns the Module that the Commit is associated with.
string owner_id = 4 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The id of the Module that the Commit is associated with.
string module_id = 4 [
// The id of the Module within the BSR instance denoted by registry_hostname
// that the Commit is associated with.
string module_id = 5 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The digest of the Commit's contents.
//
// This is a digest of the digest of all files associated with the Commit.
buf.registry.storage.v1beta1.Digest digest = 5 [(buf.validate.field).required = true];
// The id of the User that created this Commit on the BSR.
string created_by_user_id = 6 [
buf.registry.storage.v1beta1.Digest digest = 6 [(buf.validate.field).required = true];
// The id of the User within the BSR instance denoted by registry_hostname
// hat created this Commit on the BSR.
string created_by_user_id = 7 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The SPDX license ID of the associated license, if any.
//
// To retrieve the specific license file, use the ContentService.
string spdx_license_id = 7 [(buf.validate.field).string.max_len = 255];
string spdx_license_id = 8 [(buf.validate.field).string.max_len = 255];
}

// CommitRef is a reference to a Commit.
//
// This is used in requests.
message CommitRef {
option (buf.registry.priv.extension.v1beta1.message).request_only = true;

// The hostname of the registry of the Buf Schema Registry instance that the Commit is on.
//
// In most circumstances, this must match the hostname of the instance you are calling via the API.
// Where there are exceptions to this, this is specifically noted in the top-level request message.
string registry_hostname = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.hostname = true
];
// The id of the Commit within the BSR instance as denoted by registry_hostname.
string id = 2 [(buf.validate.field).string.uuid = true];
}
23 changes: 23 additions & 0 deletions buf/registry/module/v1beta1/commit_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ message ResolveCommitsRequest {
// - If a Tag is referenced, this is interpreted to mean the Commit associated with the Tag.
// - If a VCSCommit is referenced, this is interpreted to mean the Commit associated with the VCSCommit.
// - Is a Branch is referenced, this is interpreted to mean the latest Commit on the Branch.
//
// Only resources with registry_hostnames equal to the hostname of the BSR instance you are
// calling can be referenced, other registry_hostnames will result in an error.
repeated ResourceRef resource_refs = 1 [(buf.validate.field).repeated.min_items = 1];
}

message ResolveCommitsResponse {
// The found Commits in the same order as requested.
//
// Only Commits with registry_hostnames equal to the hostname of the BSR instance you are
// calling will be returned.
repeated Commit commits = 1 [(buf.validate.field).repeated.min_items = 1];
}

Expand All @@ -98,6 +104,9 @@ message ListCommitHistoryRequest {
// - If a Tag is referenced, history is started at the Commit associated with the Tag.
// - If a VCSCommit is referenced, history is started at the Commit associated with the VCSCommit.
// - Is a Branch is referenced, history is started at the latest Commit on the Branch.
//
// Only resources with registry_hostnames equal to the hostname of the BSR instance you are
// calling can be referenced, other registry_hostnames will result in an error.
ResourceRef resource_ref = 3 [(buf.validate.field).required = true];
// Only return Commits that have one or more associated Tags.
bool has_tag = 4;
Expand All @@ -111,6 +120,9 @@ message ListCommitHistoryResponse {
/// If empty, there are no more pages.
string next_page_token = 1;
// The listed Commits.
//
// Only Commits with registry_hostnames equal to the hostname of the BSR instance you are
// calling will be returned.
repeated Commit commits = 2;
}

Expand Down Expand Up @@ -189,6 +201,9 @@ message CreateCommitsResponse {
//
// If the digest was found for an pre-existing Commit, this pre-existing Commit will be returned
// instead of a new Commit being created.
//
// Only Commits with registry_hostnames equal to the hostname of the BSR instance you are
// calling will be returned.
repeated Commit commits = 1 [(buf.validate.field).repeated.min_items = 1];
}

Expand All @@ -205,6 +220,9 @@ message GetFileNodesRequest {
// - If a Tag is referenced, files are returned from the Commit associated with the Tag.
// - If a VCSCommit is referenced, files are returned from the Commit associated with the VCSCommit.
// - Is a Branch is referenced, files are returned from the latest Commit on the Branch.
//
// Only resources with registry_hostnames equal to the hostname of the BSR instance you are
// calling can be referenced, other registry_hostnames will result in an error.
ResourceRef resource_ref = 1 [(buf.validate.field).required = true];
// Specific file paths to retrieve.
//
Expand Down Expand Up @@ -232,7 +250,12 @@ message GetFileNodesRequest {
message GetFileNodesResponse {
// A single set of FileNodes and their associated commits.
message Value {
// The FileNodes for the Commit.
repeated buf.registry.storage.v1beta1.FileNode file_nodes = 1 [(buf.validate.field).repeated.min_items = 1];
// The Commit associated with the FileNodes.

// Only Commits with registry_hostnames equal to the hostname of the BSR instance you are
// calling will be returned.
Commit commit = 2 [(buf.validate.field).required = true];
}
// The returned File sets in the same order as requested.
Expand Down
Loading

0 comments on commit a628f73

Please sign in to comment.