Skip to content

Commit

Permalink
Merge branch 'breaking-review-labels' of https://github.com/bufbuild/…
Browse files Browse the repository at this point in the history
…registry-proto into breaking-review-labels
  • Loading branch information
bufdev committed Feb 26, 2024
2 parents d126dac + da077c5 commit 4546866
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 34 deletions.
66 changes: 46 additions & 20 deletions buf/registry/module/v1beta1/label.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ message Label {
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// The id of the currently passed or accepted Commit currently associated with the Label.
// The id of the Commit currently associated with the Label.
//
// Labels will only point to passed or accepted commits, and never point to rejected or pending Commits.
// If policy checks are enabled, this will point to the most recent Commit that passed or was approved.
// To get the history of the Commits that have been associated with a Label, use ListLabelHistory.
string commit_id = 8 [
(buf.validate.field).required = true,
Expand All @@ -72,29 +72,55 @@ message Label {
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
];
// Whether or not governance review is enabled for this Label.
// Whether or not policy checks are enabled for this Label.
//
// Governance is an enterprise-only feature - contact us to learn more!
bool review_enabled = 10;
// The current review state of the Label.
// Policy checks are an enterprise-only feature - contact us to learn more!
bool policy_checks_enabled = 10;
// The PolicyCheckState for the Commit the Label points to.
//
// This field will only be set if review is enabled.
LabelReviewState review_state = 11 [(buf.validate.field).enum.defined_only = true];
// This field will be set if either:
// - Policy checks were enabled on this Label when this Commit was pushed.
// - This Commit transitively depends on a Commit that has a PolicyCheckState.
PolicyCheckState policy_check_state = 11;
}

// The label state in the governance review flow.
// The state of a Commit's policy checks for a particular Label.
//
// Governance is an enterprise-only feature - contact us to learn more!
enum LabelReviewState {
LABEL_REVIEW_STATE_UNSPECIFIED = 0;
// The last Commit pushed to the Label did not fail any governance checks and therefore did not need review.
LABEL_REVIEW_STATE_PASSED = 1;
// The last Commit pushed to the Label was reviewed after failing governance checks and was accepted.
LABEL_REVIEW_STATE_ACCEPTED = 2;
// The last Commit pushed to the Label was reviewed after failing governance checks and was rejected.
LABEL_REVIEW_STATE_REJECTED = 3;
// The last Commit pushed to the Label has not yet been reviewed after failing governance checks and is pending.
LABEL_REVIEW_STATE_PENDING = 4;
// Policy checks are an enterprise-only feature - contact us to learn more!
message PolicyCheckState {
// The status of the policy checks.
PolicyCheckStatus status = 1 [(buf.validate.field).enum.defined_only = true];

// The time the status was last updated.
google.protobuf.Timestamp status_updated_at = 3 [(buf.validate.field).required = true];

// The ids of Commits that have policy checks blocking these policy checks.
//
// This field will only be set if the status is blocked.
repeated string blocked_on_commit_ids = 2 [(buf.validate.field).string.uuid = true];
}

// The status of a PolicyCheckState.
//
// Policy checks are an enterprise-only feature - contact us to learn more!
enum PolicyCheckStatus {
POLICY_CHECK_STATUS_UNSPECIFIED = 0;
// The Commit did not fail any policy checks and therefore did not need review.
POLICY_CHECK_STATUS_PASSED = 1;
// The Commit was reviewed after failing policy checks and was approved.
POLICY_CHECK_STATUS_APPROVED = 2;
// The Commit was reviewed after failing policy checks and was rejected.
POLICY_CHECK_STATUS_REJECTED = 3;
// The Commit has not yet been reviewed after failing policy checks and is pending.
POLICY_CHECK_STATUS_PENDING = 4;
// The policy checks for this Commit are blocked on pending policy checks for at least one other Commit.
//
// If at least one dependent Commit is rejected, this Commit will inherit the rejected status.
// If all dependent Commits are passed or approved, then the status for this Commit will transition to:
// - Passed if policy checks are not enabled for this Label.
// - Passed if policy checks are enabled for this Label and all checks passed.
// - Pending if policy checks are enabled for this Label and some checks failed.
POLICY_CHECK_STATUS_BLOCKED = 5;
}

// LabelRef is a reference to a Label, either an id or a fully-qualified name.
Expand Down
24 changes: 10 additions & 14 deletions buf/registry/module/v1beta1/label_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import "buf/registry/module/v1beta1/digest.proto";
import "buf/registry/module/v1beta1/label.proto";
import "buf/registry/module/v1beta1/resource.proto";
import "buf/validate/validate.proto";
import "google/protobuf/timestamp.proto";

option go_package = "buf.build/gen/go/bufbuild/registry/protocolbuffers/go/buf/registry/module/v1beta1";

Expand Down Expand Up @@ -97,9 +96,8 @@ message ListLabelsRequest {
// Once the resource is resolved, the following Labels are listed:
// - If a Module is referenced, all Labels for the Module are returned.
// - If a Label is referenced, this Label is returned.
// - If a Commit is referenced, all Labels for the Commit are returned. Note that this will
// not return any Labels where the Commit is currently rejected or pending, it will only
// return Labels for Commits that are passed or accepted.
// - If a Commit is referenced, all Labels that currently point to the Commit are returned.
// Labels where this Commit has a PolicyCheckStatus that is neither approved nor passed will not be returned.
ResourceRef resource_ref = 3 [(buf.validate.field).required = true];
// The order to return the Labels.
//
Expand All @@ -109,10 +107,10 @@ message ListLabelsRequest {
// TODO: We are purposefully not making the default the zero enum value, however
// we may want to consider this.
Order order = 4 [(buf.validate.field).enum.defined_only = true];
// Only return Labels that have these governance review states.
// Only return Labels that point to a Commit with one of these PolicyCheckStatus values.
//
// By default, Labels with any governance review state are returned.
repeated LabelReviewState review_states = 5;
// If not set, Labels that point to a Commit with any PolicyCheckStatus value are returned.
repeated PolicyCheckStatus policy_check_statuses = 5 [(buf.validate.field).repeated.items.enum.defined_only = true];
}

message ListLabelsResponse {
Expand Down Expand Up @@ -168,14 +166,12 @@ message ListLabelHistoryResponse {
// The Commit.
Commit commit = 1 [(buf.validate.field).required = true];

// The Label's review state.
// The PolicyCheckState for this Commit on this Label.
//
// This field will only be set if governance is enabled for the Label.
LabelReviewState review_state = 2 [(buf.validate.field).enum.defined_only = true];
// When the review state was last updated.
//
// This field will only be set if governance is enabled for the Label.
google.protobuf.Timestamp review_state_updated_at = 3;
// This field will be set if either:
// - Policy checks were enabled on this Label when this Commit was pushed.
// - This Commit transitively depends on a Commit that has a PolicyCheckState.
PolicyCheckState policy_check_state = 2;
}

// The next page token.
Expand Down

0 comments on commit 4546866

Please sign in to comment.