Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: refactor issue proto (#16380)

Danny Xuf2e2d0df2a7a
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 5a2fcdb6ac..092599de18 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -456,12 +456,12 @@ func (s *IssueService) createIssueDatabaseChange(ctx context.Context, request *v
PlanUID: planUID,
PipelineUID: rolloutUID,
Title: request.Issue.Title,
- Status: storepb.IssueStatus_OPEN,
+ Status: storepb.Issue_OPEN,
Type: base.IssueDatabaseGeneral,
Description: request.Issue.Description,
}
- issueCreateMessage.Payload = &storepb.IssuePayload{
+ issueCreateMessage.Payload = &storepb.Issue{
Approval: &storepb.IssuePayloadApproval{
ApprovalFindingDone: false,
ApprovalTemplates: nil,
@@ -533,7 +533,7 @@ func (s *IssueService) createIssueGrantRequest(ctx context.Context, request *v1p
PlanUID: nil,
PipelineUID: nil,
Title: request.Issue.Title,
- Status: storepb.IssueStatus_OPEN,
+ Status: storepb.Issue_OPEN,
Type: base.IssueGrantRequest,
Description: request.Issue.Description,
}
@@ -543,7 +543,7 @@ func (s *IssueService) createIssueGrantRequest(ctx context.Context, request *v1p
return nil, status.Errorf(codes.Internal, "failed to convert GrantRequest, error: %v", err)
}
- issueCreateMessage.Payload = &storepb.IssuePayload{
+ issueCreateMessage.Payload = &storepb.Issue{
GrantRequest: convertedGrantRequest,
Approval: &storepb.IssuePayloadApproval{
ApprovalFindingDone: false,
@@ -640,12 +640,12 @@ func (s *IssueService) createIssueDatabaseDataExport(ctx context.Context, reques
PlanUID: planUID,
PipelineUID: rolloutUID,
Title: request.Issue.Title,
- Status: storepb.IssueStatus_OPEN,
+ Status: storepb.Issue_OPEN,
Type: base.IssueDatabaseDataExport,
Description: request.Issue.Description,
}
- issueCreateMessage.Payload = &storepb.IssuePayload{
+ issueCreateMessage.Payload = &storepb.Issue{
Approval: &storepb.IssuePayloadApproval{
ApprovalFindingDone: false,
ApprovalTemplates: nil,
@@ -750,7 +750,7 @@ func (s *IssueService) ApproveIssue(ctx context.Context, request *v1pb.ApproveIs
payload.Approval.Approvers = append(payload.Approval.Approvers, newApprovers...)
issue, err = s.store.UpdateIssueV2(ctx, issue.UID, &store.UpdateIssueMessage{
- PayloadUpsert: &storepb.IssuePayload{
+ PayloadUpsert: &storepb.Issue{
Approval: payload.Approval,
},
})
@@ -868,7 +868,7 @@ func (s *IssueService) ApproveIssue(ctx context.Context, request *v1pb.ApproveIs
return errors.Wrap(err, "failed to check if the approval is approved")
}
if approved {
- if err := webhook.ChangeIssueStatus(ctx, s.store, s.webhookManager, issue, storepb.IssueStatus_DONE, s.store.GetSystemBotUser(ctx), ""); err != nil {
+ if err := webhook.ChangeIssueStatus(ctx, s.store, s.webhookManager, issue, storepb.Issue_DONE, s.store.GetSystemBotUser(ctx), ""); err != nil {
return errors.Wrap(err, "failed to update issue status")
}
}
@@ -947,7 +947,7 @@ func (s *IssueService) RejectIssue(ctx context.Context, request *v1pb.RejectIssu
})
issue, err = s.store.UpdateIssueV2(ctx, issue.UID, &store.UpdateIssueMessage{
- PayloadUpsert: &storepb.IssuePayload{
+ PayloadUpsert: &storepb.Issue{
Approval: payload.Approval,
},
})
@@ -1035,7 +1035,7 @@ func (s *IssueService) RequestIssue(ctx context.Context, request *v1pb.RequestIs
payload.Approval.Approvers = append(payload.Approval.Approvers, newApprovers...)
issue, err = s.store.UpdateIssueV2(ctx, issue.UID, &store.UpdateIssueMessage{
- PayloadUpsert: &storepb.IssuePayload{
+ PayloadUpsert: &storepb.Issue{
Approval: payload.Approval,
},
})
@@ -1130,7 +1130,7 @@ func (s *IssueService) UpdateIssue(ctx context.Context, request *v1pb.UpdateIssu
}
if patch.PayloadUpsert == nil {
- patch.PayloadUpsert = &storepb.IssuePayload{}
+ patch.PayloadUpsert = &storepb.Issue{}
}
patch.PayloadUpsert.Approval = &storepb.IssuePayloadApproval{
ApprovalFindingDone: false,
@@ -1233,7 +1233,7 @@ func (s *IssueService) UpdateIssue(ctx context.Context, request *v1pb.UpdateIssu
patch.RemoveLabels = true
} else {
if patch.PayloadUpsert == nil {
- patch.PayloadUpsert = &storepb.IssuePayload{}
+ patch.PayloadUpsert = &storepb.Issue{}
}
patch.PayloadUpsert.Labels = request.Issue.Labels
}
diff --git a/backend/api/v1/issue_service_convert.go b/backend/api/v1/issue_service_convert.go
index 5cec1390f4..830b2191ba 100644
--- a/backend/api/v1/issue_service_convert.go
+++ b/backend/api/v1/issue_service_convert.go
@@ -98,7 +98,7 @@ func (s *IssueService) convertToIssueReleasers(ctx context.Context, issue *store
if issue.Type != base.IssueDatabaseGeneral {
return nil, nil
}
- if issue.Status != storepb.IssueStatus_OPEN {
+ if issue.Status != storepb.Issue_OPEN {
return nil, nil
}
if issue.PipelineUID == nil {
@@ -172,26 +172,26 @@ func convertToAPIIssueType(t v1pb.Issue_Type) (base.IssueType, error) {
}
}
-func convertToAPIIssueStatus(status v1pb.IssueStatus) (storepb.IssueStatus, error) {
+func convertToAPIIssueStatus(status v1pb.IssueStatus) (storepb.Issue_Status, error) {
switch status {
case v1pb.IssueStatus_OPEN:
- return storepb.IssueStatus_OPEN, nil
+ return storepb.Issue_OPEN, nil
case v1pb.IssueStatus_DONE:
- return storepb.IssueStatus_DONE, nil
+ return storepb.Issue_DONE, nil
case v1pb.IssueStatus_CANCELED:
- return storepb.IssueStatus_CANCELED, nil
+ return storepb.Issue_CANCELED, nil
default:
- return storepb.IssueStatus_ISSUE_STATUS_UNSPECIFIED, errors.Errorf("invalid issue status %v", status)
+ return storepb.Issue_ISSUE_STATUS_UNSPECIFIED, errors.Errorf("invalid issue status %v", status)
}
}
-func convertToIssueStatus(status storepb.IssueStatus) v1pb.IssueStatus {
+func convertToIssueStatus(status storepb.Issue_Status) v1pb.IssueStatus {
switch status {
- case storepb.IssueStatus_OPEN:
+ case storepb.Issue_OPEN:
return v1pb.IssueStatus_OPEN
- case storepb.IssueStatus_DONE:
+ case storepb.Issue_DONE:
return v1pb.IssueStatus_DONE
- case storepb.IssueStatus_CANCELED:
+ case storepb.Issue_CANCELED:
return v1pb.IssueStatus_CANCELED
default:
return v1pb.IssueStatus_ISSUE_STATUS_UNSPECIFIED
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index a9fecd3e48..6ac5d94990 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -649,7 +649,7 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
}
if issue != nil {
// Do not allow to update task if issue is done or canceled.
- if issue.Status == storepb.IssueStatus_DONE || issue.Status == storepb.IssueStatus_CANCELED {
+ if issue.Status == storepb.Issue_DONE || issue.Status == storepb.Issue_CANCELED {
return nil, status.Errorf(codes.FailedPrecondition, "cannot update task because issue %q is %s", issue.Title, issue.Status)
}
}
@@ -716,7 +716,7 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
if issue != nil && doUpdateSheet {
if err := func() error {
issue, err := s.store.UpdateIssueV2(ctx, issue.UID, &store.UpdateIssueMessage{
- PayloadUpsert: &storepb.IssuePayload{
+ PayloadUpsert: &storepb.Issue{
Approval: &storepb.IssuePayloadApproval{
ApprovalFindingDone: false,
},
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index c18aeb9fb9..59afa7c24f 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -465,7 +465,7 @@ func (s *ProjectService) DeleteProject(ctx context.Context, request *v1pb.Delete
// We don't close the issues because they might be open still.
} else {
// Return the open issue error first because that's more important than transferring out databases.
- openIssues, err := s.store.ListIssueV2(ctx, &store.FindIssueMessage{ProjectIDs: &[]string{project.ResourceID}, StatusList: []storepb.IssueStatus{storepb.IssueStatus_OPEN}})
+ openIssues, err := s.store.ListIssueV2(ctx, &store.FindIssueMessage{ProjectIDs: &[]string{project.ResourceID}, StatusList: []storepb.Issue_Status{storepb.Issue_OPEN}})
if err != nil {
return nil, err
}
diff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.go
index b9a029f05f..ac98f3a259 100644
--- a/backend/component/webhook/manager.go
+++ b/backend/component/webhook/manager.go
@@ -414,7 +414,7 @@ func maybeGetPhoneFromUser(user *store.UserMessage) (string, error) {
}
// ChangeIssueStatus changes the status of an issue.
-func ChangeIssueStatus(ctx context.Context, stores *store.Store, webhookManager *Manager, issue *store.IssueMessage, newStatus storepb.IssueStatus, updater *store.UserMessage, comment string) error {
+func ChangeIssueStatus(ctx context.Context, stores *store.Store, webhookManager *Manager, issue *store.IssueMessage, newStatus storepb.Issue_Status, updater *store.UserMessage, comment string) error {
updateIssueMessage := &store.UpdateIssueMessage{Status: &newStatus}
updatedIssue, err := stores.UpdateIssueV2(ctx, issue.UID, updateIssueMessage)
if err != nil {
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 1194fee057..7a75d70eeb 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -113,7 +113,7 @@ func (r *Runner) runOnce(ctx context.Context) {
func (r *Runner) retryFindApprovalTemplate(ctx context.Context) {
issues, err := r.store.ListIssueV2(ctx, &store.FindIssueMessage{
- StatusList: []storepb.IssueStatus{storepb.IssueStatus_OPEN},
+ StatusList: []storepb.Issue_Status{storepb.Issue_OPEN},
})
if err != nil {
err := errors.Wrap(err, "failed to list issues")
@@ -180,7 +180,7 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
if err := utils.UpdateProjectPolicyFromGrantIssue(ctx, r.store, issue, payload.GrantRequest); err != nil {
return false, err
}
- if err := webhook.ChangeIssueStatus(ctx, r.store, r.webhookManager, issue, storepb.IssueStatus_DONE, r.store.GetSystemBotUser(ctx), ""); err != nil {
+ if err := webhook.ChangeIssueStatus(ctx, r.store, r.webhookManager, issue, storepb.Issue_DONE, r.store.GetSystemBotUser(ctx), ""); err != nil {
return false, errors.Wrap(err, "failed to update issue status")
}
}
@@ -753,7 +753,7 @@ func getRiskSourceFromPlan(config *storepb.PlanConfig) store.RiskSource {
func updateIssueApprovalPayload(ctx context.Context, s *store.Store, issue *store.IssueMessage, approval *storepb.IssuePayloadApproval) error {
if _, err := s.UpdateIssueV2(ctx, issue.UID, &store.UpdateIssueMessage{
- PayloadUpsert: &storepb.IssuePayload{
+ PayloadUpsert: &storepb.Issue{
Approval: approval,
},
}); err != nil {
diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.go
index d56789f68e..a9e66214d5 100644
--- a/backend/runner/taskrun/schedulerv2.go
+++ b/backend/runner/taskrun/schedulerv2.go
@@ -183,7 +183,7 @@ func (s *SchedulerV2) scheduleAutoRolloutTask(ctx context.Context, taskUID int)
return err
}
if issue != nil {
- if issue.Status != storepb.IssueStatus_OPEN {
+ if issue.Status != storepb.Issue_OPEN {
return nil
}
approved, err := utils.CheckIssueApproved(issue)
@@ -876,7 +876,7 @@ func (s *SchedulerV2) ListenTaskSkippedOrDone(ctx context.Context) {
return nil
}
- newStatus := storepb.IssueStatus_DONE
+ newStatus := storepb.Issue_DONE
updatedIssue, err := s.store.UpdateIssueV2(ctx, issue.UID, &store.UpdateIssueMessage{Status: &newStatus})
if err != nil {
return errors.Wrapf(err, "failed to update issue status")
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 2f512e875d..ceaa1bbb1d 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -36,10 +36,10 @@ func init() {
type IssueMessage struct {
Project *ProjectMessage
Title string
- Status storepb.IssueStatus
+ Status storepb.Issue_Status
Type base.IssueType
Description string
- Payload *storepb.IssuePayload
+ Payload *storepb.Issue
Subscribers []*UserMessage
PipelineUID *int
PlanUID *int64
@@ -60,10 +60,10 @@ type IssueMessage struct {
// UpdateIssueMessage is the message for updating an issue.
type UpdateIssueMessage struct {
Title *string
- Status *storepb.IssueStatus
+ Status *storepb.Issue_Status
Description *string
// PayloadUpsert upserts the presented top-level keys.
- PayloadUpsert *storepb.IssuePayload
+ PayloadUpsert *storepb.Issue
RemoveLabels bool
Subscribers *[]*UserMessage
@@ -85,7 +85,7 @@ type FindIssueMessage struct {
CreatedAtAfter *time.Time
Types *[]base.IssueType
- StatusList []storepb.IssueStatus
+ StatusList []storepb.Issue_Status
TaskTypes *[]base.TaskType
// Any of the task in the issue changes the instance with InstanceResourceID.
InstanceResourceID *string
@@ -137,7 +137,7 @@ func (s *Store) GetIssueV2(ctx context.Context, find *FindIssueMessage) (*IssueM
// CreateIssueV2 creates a new issue.
func (s *Store) CreateIssueV2(ctx context.Context, create *IssueMessage, creatorID int) (*IssueMessage, error) {
- create.Status = storepb.IssueStatus_OPEN
+ create.Status = storepb.Issue_OPEN
payload, err := protojson.Marshal(create.Payload)
if err != nil {
@@ -493,7 +493,7 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
defer rows.Close()
for rows.Next() {
issue := IssueMessage{
- Payload: &storepb.IssuePayload{},
+ Payload: &storepb.Issue{},
}
var payload []byte
var subscriberUIDs pgtype.Int4Array
@@ -517,8 +517,8 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
); err != nil {
return nil, err
}
- if statusValue, ok := storepb.IssueStatus_value[statusString]; ok {
- issue.Status = storepb.IssueStatus(statusValue)
+ if statusValue, ok := storepb.Issue_Status_value[statusString]; ok {
+ issue.Status = storepb.Issue_Status(statusValue)
} else {
return nil, errors.Errorf("invalid status string: %s", statusString)
}
@@ -571,7 +571,7 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
}
// BatchUpdateIssueStatuses updates the status of multiple issues.
-func (s *Store) BatchUpdateIssueStatuses(ctx context.Context, issueUIDs []int, status storepb.IssueStatus) error {
+func (s *Store) BatchUpdateIssueStatuses(ctx context.Context, issueUIDs []int, status storepb.Issue_Status) error {
var ids []string
for _, id := range issueUIDs {
ids = append(ids, fmt.Sprintf("%d", id))
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 43fec9a2a5..b153f51f16 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -8959,6 +8959,63 @@ components:
type: string
description: The identity_increment is for identity columns, MSSQL only.
description: ColumnMetadata is the metadata for columns.
+ Constant:
+ type: object
+ properties:
+ nullValue:
+ enum:
+ - NULL_VALUE
+ type: string
+ description: null value.
+ format: enum
+ boolValue:
+ type: boolean
+ description: boolean value.
+ int64Value:
+ type: string
+ description: int64 value.
+ uint64Value:
+ type: string
+ description: uint64 value.
+ doubleValue:
+ type: number
+ description: double value.
+ format: double
+ stringValue:
+ type: string
+ description: string value.
+ bytesValue:
+ type: string
+ description: bytes value.
+ format: bytes
+ durationValue:
+ pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$
+ type: string
+ description: |-
+ protobuf.Duration value.
+
+ Deprecated: duration is no longer considered a builtin cel type.
+ timestampValue:
+ type: string
+ description: |-
+ protobuf.Timestamp value.
+
+ Deprecated: timestamp is no longer considered a builtin cel type.
+ format: date-time
+ description: |-
+ Represents a primitive literal.
+
+ Named 'Constant' here for backwards compatibility.
+
+ This is similar as the primitives supported in the well-known type
+ `google.protobuf.Value`, but richer so it can represent CEL's full range of
+ primitives.
+
+ Lists and structs are not included as constants as these aggregate types may
+ contain [Expr][google.api.expr.v1alpha1.Expr] elements which require evaluation and are thus not constant.
+
+ Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
+ `true`, `null`.
Content_Part:
type: object
properties:
@@ -8992,6 +9049,35 @@ components:
allOf:
- $ref: '#/components/schemas/Sheet'
description: The sheet to create.
+ CreateStruct_Entry:
+ type: object
+ properties:
+ id:
+ type: string
+ description: |-
+ Required. An id assigned to this node by the parser which is unique
+ in a given expression tree. This is used to associate type
+ information and other attributes to the node.
+ fieldKey:
+ type: string
+ description: The field key for a message creator statement.
+ mapKey:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: The key expression for a map creation statement.
+ value:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: |-
+ Required. The value assigned to the key.
+
+ If the optional_entry field is true, the expression must resolve to an
+ optional-typed value. If the optional value is present, the key will be
+ set; however, if the optional value is absent, the key will be unset.
+ optionalEntry:
+ type: boolean
+ description: Whether the key-value pair is optional.
+ description: Represents an entry.
DataClassificationConfig_DataClassification:
type: object
properties:
@@ -9675,59 +9761,223 @@ components:
Expr:
type: object
properties:
- expression:
+ id:
type: string
description: |-
- Textual representation of an expression in Common Expression Language
- syntax.
- title:
- type: string
+ Required. An id assigned to this node by the parser which is unique in a
+ given expression tree. This is used to associate type information and other
+ attributes to a node in the parse tree.
+ constExpr:
+ allOf:
+ - $ref: '#/components/schemas/Constant'
+ description: A literal expression.
+ identExpr:
+ allOf:
+ - $ref: '#/components/schemas/Expr_Ident'
+ description: An identifier expression.
+ selectExpr:
+ allOf:
+ - $ref: '#/components/schemas/Expr_Select'
+ description: A field selection expression, e.g. `request.auth`.
+ callExpr:
+ allOf:
+ - $ref: '#/components/schemas/Expr_Call'
+ description: A call expression, including calls to predefined functions and operators.
+ listExpr:
+ allOf:
+ - $ref: '#/components/schemas/Expr_CreateList'
+ description: A list creation expression.
+ structExpr:
+ allOf:
+ - $ref: '#/components/schemas/Expr_CreateStruct'
+ description: A map or message creation expression.
+ comprehensionExpr:
+ allOf:
+ - $ref: '#/components/schemas/Expr_Comprehension'
+ description: A comprehension expression.
+ description: |-
+ An abstract representation of a common expression.
+
+ Expressions are abstractly represented as a collection of identifiers,
+ select statements, function calls, literals, and comprehensions. All
+ operators with the exception of the '.' operator are modelled as function
+ calls. This makes it easy to represent new operators into the existing AST.
+
+ All references within expressions must resolve to a [Decl][google.api.expr.v1alpha1.Decl] provided at
+ type-check for an expression to be valid. A reference may either be a bare
+ identifier `name` or a qualified identifier `google.api.name`. References
+ may either refer to a value or a function declaration.
+
+ For example, the expression `google.api.name.startsWith('expr')` references
+ the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and
+ the function declaration `startsWith`.
+ Expr_Call:
+ type: object
+ properties:
+ target:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
description: |-
- Optional. Title for the expression, i.e. a short string describing
- its purpose. This can be used e.g. in UIs which allow to enter the
- expression.
- description:
+ The target of an method call-style expression. For example, `x` in
+ `x.f()`.
+ function:
type: string
- description: |-
- Optional. Description of the expression. This is a longer text which
- describes the expression, e.g. when hovered over it in a UI.
- location:
+ description: Required. The name of the function or method being called.
+ args:
+ type: array
+ items:
+ $ref: '#/components/schemas/Expr'
+ description: The arguments.
+ description: |-
+ A call expression, including calls to predefined functions and operators.
+
+ For example, `value == 10`, `size(map_value)`.
+ Expr_Comprehension:
+ type: object
+ properties:
+ iterVar:
+ type: string
+ description: The name of the iteration variable.
+ iterRange:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: The range over which var iterates.
+ accuVar:
type: string
+ description: The name of the variable used for accumulation of the result.
+ accuInit:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: The initial value of the accumulator.
+ loopCondition:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: |-
+ An expression which can contain iter_var and accu_var.
+
+ Returns false when the result has been computed and may be used as
+ a hint to short-circuit the remainder of the comprehension.
+ loopStep:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: |-
+ An expression which can contain iter_var and accu_var.
+
+ Computes the next value of accu_var.
+ result:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
description: |-
- Optional. String indicating the location of the expression for error
- reporting, e.g. a file name and a position in the file.
+ An expression which can contain accu_var.
+
+ Computes the result.
description: |-
- Represents a textual expression in the Common Expression Language (CEL)
- syntax. CEL is a C-like expression language. The syntax and semantics of CEL
- are documented at https://github.com/google/cel-spec.
+ A comprehension expression applied to a list or map.
- Example (Comparison):
+ Comprehensions are not part of the core syntax, but enabled with macros.
+ A macro matches a specific call signature within a parsed AST and replaces
+ the call with an alternate AST block. Macro expansion happens at parse
+ time.
- title: "Summary size limit"
- description: "Determines if a summary is less than 100 chars"
- expression: "document.summary.size() < 100"
+ The following macros are supported within CEL:
- Example (Equality):
+ Aggregate type macros may be applied to all elements in a list or all keys
+ in a map:
- title: "Requestor is owner"
- description: "Determines if requestor is the document owner"
- expression: "document.owner == request.auth.claims.email"
+ * `all`, `exists`, `exists_one` - test a predicate expression against
+ the inputs and return `true` if the predicate is satisfied for all,
+ any, or only one value `list.all(x, x < 10)`.
+ * `filter` - test a predicate expression against the inputs and return
+ the subset of elements which satisfy the predicate:
+ `payments.filter(p, p > 1000)`.
+ * `map` - apply an expression to all elements in the input and return the
+ output aggregate type: `[1, 2, 3].map(i, i * i)`.
- Example (Logic):
+ The `has(m.x)` macro tests whether the property `x` is present in struct
+ `m`. The semantics of this macro depend on the type of `m`. For proto2
+ messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the
+ macro tests whether the property is set to its default. For map and struct
+ types, the macro tests whether the property `x` is defined on `m`.
+ Expr_CreateList:
+ type: object
+ properties:
+ elements:
+ type: array
+ items:
+ $ref: '#/components/schemas/Expr'
+ description: The elements part of the list.
+ optionalIndices:
+ type: array
+ items:
+ type: integer
+ format: int32
+ description: |-
+ The indices within the elements list which are marked as optional
+ elements.
- title: "Public documents"
- description: "Determine whether the document should be publicly visible"
- expression: "document.type != 'private' && document.type != 'internal'"
+ When an optional-typed value is present, the value it contains
+ is included in the list. If the optional-typed value is absent, the list
+ element is omitted from the CreateList result.
+ description: |-
+ A list creation expression.
- Example (Data Manipulation):
+ Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogeneous, e.g.
+ `dyn([1, 'hello', 2.0])`
+ Expr_CreateStruct:
+ type: object
+ properties:
+ messageName:
+ type: string
+ description: |-
+ The type name of the message to be created, empty when creating map
+ literals.
+ entries:
+ type: array
+ items:
+ $ref: '#/components/schemas/CreateStruct_Entry'
+ description: The entries in the creation expression.
+ description: |-
+ A map or message creation expression.
- title: "Notification string"
- description: "Create a notification string with a timestamp."
- expression: "'New message received at ' + string(document.create_time)"
+ Maps are constructed as `{'key_name': 'value'}`. Message construction is
+ similar, but prefixed with a type name and composed of field ids:
+ `types.MyType{field_id: 'value'}`.
+ Expr_Ident:
+ type: object
+ properties:
+ name:
+ type: string
+ description: |-
+ Required. Holds a single, unqualified identifier, possibly preceded by a
+ '.'.
- The exact variables and functions that may be referenced within an expression
- are determined by the service that evaluates it. See the service
- documentation for additional information.
+ Qualified names are represented by the [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression.
+ description: An identifier expression. e.g. `request`.
+ Expr_Select:
+ type: object
+ properties:
+ operand:
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: |-
+ Required. The target of the selection expression.
+
+ For example, in the select expression `request.auth`, the `request`
+ portion of the expression is the `operand`.
+ field:
+ type: string
+ description: |-
+ Required. The name of the field to select.
+
+ For example, in the select expression `request.auth`, the `auth` portion
+ of the expression would be the `field`.
+ testOnly:
+ type: boolean
+ description: |-
+ Whether the select is to be interpreted as a field presence test.
+
+ This results from the macro `has(request.auth)`.
+ description: A field selection expression. e.g. `request.auth`.
Feature:
type: object
properties:
@@ -9843,11 +10093,9 @@ components:
type: string
description: |-
The user to be granted.
- Format: users/{email}.
+ Format: users/{userUID}.
condition:
- allOf:
- - $ref: '#/components/schemas/Expr'
- description: The condition for the role. Same as the condtion in IAM Binding message.
+ $ref: '#/components/schemas/Expr'
expiration:
pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$
type: string
@@ -10152,117 +10400,10 @@ components:
Issue:
type: object
properties:
- name:
- type: string
- description: |-
- The name of the issue.
- Format: projects/{project}/issues/{issue}
- title:
- type: string
- description:
- type: string
- type:
- enum:
- - TYPE_UNSPECIFIED
- - DATABASE_CHANGE
- - GRANT_REQUEST
- - DATABASE_DATA_EXPORT
- type: string
- format: enum
- status:
- enum:
- - ISSUE_STATUS_UNSPECIFIED
- - OPEN
- - DONE
- - CANCELED
- type: string
- format: enum
- approvers:
- type: array
- items:
- $ref: '#/components/schemas/Issue_Approver'
- approvalTemplates:
- type: array
- items:
- $ref: '#/components/schemas/ApprovalTemplate'
- approvalFindingDone:
- type: boolean
- description: |-
- If the value is `false`, it means that the backend is still finding matching approval templates.
- If `true`, approval_templates & approvers & approval_finding_error are available.
- approvalFindingError:
- type: string
- subscribers:
- type: array
- items:
- type: string
- description: |-
- The subscribers.
- Format: users/[email protected]
- creator:
- readOnly: true
- type: string
- description: 'Format: users/[email protected]'
- createTime:
- readOnly: true
- type: string
- format: date-time
- updateTime:
- readOnly: true
- type: string
- format: date-time
- plan:
- type: string
- description: |-
- The plan associated with the issue.
- Can be empty.
- Format: projects/{project}/plans/{plan}
- rollout:
- type: string
- description: |-
- The rollout associated with the issue.
- Can be empty.
- Format: projects/{project}/rollouts/{rollout}
+ approval:
+ $ref: '#/components/schemas/IssuePayloadApproval'
grantRequest:
- allOf:
- - $ref: '#/components/schemas/GrantRequest'
- description: Used if the issue type is GRANT_REQUEST.
- releasers:
- type: array
- items:
- type: string
- description: |-
- The releasers of the pending stage of the issue rollout, judging
- from the rollout policy.
- Format:
- - roles/workspaceOwner
- - roles/workspaceDBA
- - roles/projectOwner
- - roles/projectReleaser
- - users/{email}
- riskLevel:
- enum:
- - RISK_LEVEL_UNSPECIFIED
- - LOW
- - MODERATE
- - HIGH
- type: string
- format: enum
- taskStatusCount:
- type: object
- additionalProperties:
- type: integer
- format: int32
- description: |-
- The status count of the issue.
- Keys are the following:
- - NOT_STARTED
- - SKIPPED
- - PENDING
- - RUNNING
- - DONE
- - FAILED
- - CANCELED
+ $ref: '#/components/schemas/GrantRequest'
labels:
type: array
items:
@@ -10391,7 +10532,36 @@ components:
- CANCELED
type: string
format: enum
- Issue_Approver:
+ IssuePayloadApproval:
+ type: object
+ properties:
+ approvalTemplates:
+ type: array
+ items:
+ $ref: '#/components/schemas/ApprovalTemplate'
+ approvers:
+ type: array
+ items:
+ $ref: '#/components/schemas/IssuePayloadApproval_Approver'
+ approvalFindingDone:
+ type: boolean
+ description: |-
+ If the value is `false`, it means that the backend is still finding matching approval templates.
+ If `true`, other fields are available.
+ approvalFindingError:
+ type: string
+ riskLevel:
+ enum:
+ - RISK_LEVEL_UNSPECIFIED
+ - LOW
+ - MODERATE
+ - HIGH
+ type: string
+ format: enum
+ description: |-
+ IssuePayloadApproval is a part of the payload of an issue.
+ IssuePayloadApproval records the approval template used and the approval history.
+ IssuePayloadApproval_Approver:
type: object
properties:
status:
@@ -10403,9 +10573,10 @@ components:
type: string
description: The new status.
format: enum
- principal:
- type: string
- description: 'Format: users/[email protected]'
+ principalId:
+ type: integer
+ description: The principal id of the approver.
+ format: int32
Item_Table:
type: object
properties:
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 34b8bb4dbb..e89337a108 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -149,9 +149,9 @@
- [store/issue.proto](#store_issue-proto)
- [GrantRequest](#bytebase-store-GrantRequest)
- - [IssuePayload](#bytebase-store-IssuePayload)
+ - [Issue](#bytebase-store-Issue)
- - [IssueStatus](#bytebase-store-IssueStatus)
+ - [Issue.Status](#bytebase-store-Issue-Status)
- [store/issue_comment.proto](#store_issue_comment-proto)
- [IssueCommentPayload](#bytebase-store-IssueCommentPayload)
@@ -2574,9 +2574,9 @@ InstanceRole is the API message for instance role.
-<a name="bytebase-store-IssuePayload"></a>
+<a name="bytebase-store-Issue"></a>
-### IssuePayload
+### Issue
@@ -2593,9 +2593,9 @@ InstanceRole is the API message for instance role.
-<a name="bytebase-store-IssueStatus"></a>
+<a name="bytebase-store-Issue-Status"></a>
-### IssueStatus
+### Issue.Status
| Name | Number | Description |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index efd1e21d3c..c567e1de22 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -769,12 +769,12 @@
</li>
<li>
- <a href="#bytebase.store.IssuePayload"><span class="badge">M</span>IssuePayload</a>
+ <a href="#bytebase.store.Issue"><span class="badge">M</span>Issue</a>
</li>
<li>
- <a href="#bytebase.store.IssueStatus"><span class="badge">E</span>IssueStatus</a>
+ <a href="#bytebase.store.Issue.Status"><span class="badge">E</span>Issue.Status</a>
</li>
@@ -7386,7 +7386,7 @@ Format: users/{userUID}. </p></td>
- <h3 id="bytebase.store.IssuePayload">IssuePayload</h3>
+ <h3 id="bytebase.store.Issue">Issue</h3>
<p></p>
@@ -7426,7 +7426,7 @@ Format: users/{userUID}. </p></td>
- <h3 id="bytebase.store.IssueStatus">IssueStatus</h3>
+ <h3 id="bytebase.store.Issue.Status">Issue.Status</h3>
<p></p>
<table class="enum-table">
<thead>
diff --git a/proto/generated-go/store/issue.pb.go b/proto/generated-go/store/issue.pb.go
index 461da0910c..39b3cd919b 100644
--- a/proto/generated-go/store/issue.pb.go
+++ b/proto/generated-go/store/issue.pb.go
@@ -23,24 +23,24 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
-type IssueStatus int32
+type Issue_Status int32
const (
- IssueStatus_ISSUE_STATUS_UNSPECIFIED IssueStatus = 0
- IssueStatus_OPEN IssueStatus = 1
- IssueStatus_DONE IssueStatus = 2
- IssueStatus_CANCELED IssueStatus = 3
+ Issue_ISSUE_STATUS_UNSPECIFIED Issue_Status = 0
+ Issue_OPEN Issue_Status = 1
+ Issue_DONE Issue_Status = 2
+ Issue_CANCELED Issue_Status = 3
)
-// Enum value maps for IssueStatus.
+// Enum value maps for Issue_Status.
var (
- IssueStatus_name = map[int32]string{
+ Issue_Status_name = map[int32]string{
0: "ISSUE_STATUS_UNSPECIFIED",
1: "OPEN",
2: "DONE",
3: "CANCELED",
}
- IssueStatus_value = map[string]int32{
+ Issue_Status_value = map[string]int32{
"ISSUE_STATUS_UNSPECIFIED": 0,
"OPEN": 1,
"DONE": 2,
@@ -48,34 +48,34 @@ var (
}
)
-func (x IssueStatus) Enum() *IssueStatus {
- p := new(IssueStatus)
+func (x Issue_Status) Enum() *Issue_Status {
+ p := new(Issue_Status)
*p = x
return p
}
-func (x IssueStatus) String() string {
+func (x Issue_Status) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
-func (IssueStatus) Descriptor() protoreflect.EnumDescriptor {
+func (Issue_Status) Descriptor() protoreflect.EnumDescriptor {
return file_store_issue_proto_enumTypes[0].Descriptor()
}
-func (IssueStatus) Type() protoreflect.EnumType {
+func (Issue_Status) Type() protoreflect.EnumType {
return &file_store_issue_proto_enumTypes[0]
}
-func (x IssueStatus) Number() protoreflect.EnumNumber {
+func (x Issue_Status) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
-// Deprecated: Use IssueStatus.Descriptor instead.
-func (IssueStatus) EnumDescriptor() ([]byte, []int) {
- return file_store_issue_proto_rawDescGZIP(), []int{0}
+// Deprecated: Use Issue_Status.Descriptor instead.
+func (Issue_Status) EnumDescriptor() ([]byte, []int) {
+ return file_store_issue_proto_rawDescGZIP(), []int{0, 0}
}
-type IssuePayload struct {
+type Issue struct {
state protoimpl.MessageState `protogen:"open.v1"`
Approval *IssuePayloadApproval `protobuf:"bytes,1,opt,name=approval,proto3" json:"approval,omitempty"`
GrantRequest *GrantRequest `protobuf:"bytes,2,opt,name=grant_request,json=grantRequest,proto3" json:"grant_request,omitempty"`
@@ -84,20 +84,20 @@ type IssuePayload struct {
sizeCache protoimpl.SizeCache
}
-func (x *IssuePayload) Reset() {
- *x = IssuePayload{}
+func (x *Issue) Reset() {
+ *x = Issue{}
mi := &file_store_issue_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
-func (x *IssuePayload) String() string {
+func (x *Issue) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*IssuePayload) ProtoMessage() {}
+func (*Issue) ProtoMessage() {}
-func (x *IssuePayload) ProtoReflect() protoreflect.Message {
+func (x *Issue) ProtoReflect() protoreflect.Message {
mi := &file_store_issue_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -109,26 +109,26 @@ func (x *IssuePayload) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use IssuePayload.ProtoReflect.Descriptor instead.
-func (*IssuePayload) Descriptor() ([]byte, []int) {
+// Deprecated: Use Issue.ProtoReflect.Descriptor instead.
+func (*Issue) Descriptor() ([]byte, []int) {
return file_store_issue_proto_rawDescGZIP(), []int{0}
}
-func (x *IssuePayload) GetApproval() *IssuePayloadApproval {
+func (x *Issue) GetApproval() *IssuePayloadApproval {
if x != nil {
return x.Approval
}
return nil
}
-func (x *IssuePayload) GetGrantRequest() *GrantRequest {
+func (x *Issue) GetGrantRequest() *GrantRequest {
if x != nil {
return x.GrantRequest
}
return nil
}
-func (x *IssuePayload) GetLabels() []string {
+func (x *Issue) GetLabels() []string {
if x != nil {
return x.Labels
}
@@ -211,23 +211,23 @@ var File_store_issue_proto protoreflect.FileDescriptor
const file_store_issue_proto_rawDesc = "" +
"\n" +
- "\x11store/issue.proto\x12\x0ebytebase.store\x1a\x1egoogle/protobuf/duration.proto\x1a\x16google/type/expr.proto\x1a\x14store/approval.proto\"\xab\x01\n" +
- "\fIssuePayload\x12@\n" +
+ "\x11store/issue.proto\x12\x0ebytebase.store\x1a\x1egoogle/protobuf/duration.proto\x1a\x16google/type/expr.proto\x1a\x14store/approval.proto\"\xee\x01\n" +
+ "\x05Issue\x12@\n" +
"\bapproval\x18\x01 \x01(\v2$.bytebase.store.IssuePayloadApprovalR\bapproval\x12A\n" +
"\rgrant_request\x18\x02 \x01(\v2\x1c.bytebase.store.GrantRequestR\fgrantRequest\x12\x16\n" +
- "\x06labels\x18\x03 \x03(\tR\x06labels\"\xa2\x01\n" +
+ "\x06labels\x18\x03 \x03(\tR\x06labels\"H\n" +
+ "\x06Status\x12\x1c\n" +
+ "\x18ISSUE_STATUS_UNSPECIFIED\x10\x00\x12\b\n" +
+ "\x04OPEN\x10\x01\x12\b\n" +
+ "\x04DONE\x10\x02\x12\f\n" +
+ "\bCANCELED\x10\x03\"\xa2\x01\n" +
"\fGrantRequest\x12\x12\n" +
"\x04role\x18\x01 \x01(\tR\x04role\x12\x12\n" +
"\x04user\x18\x02 \x01(\tR\x04user\x12/\n" +
"\tcondition\x18\x03 \x01(\v2\x11.google.type.ExprR\tcondition\x129\n" +
"\n" +
"expiration\x18\x04 \x01(\v2\x19.google.protobuf.DurationR\n" +
- "expiration*M\n" +
- "\vIssueStatus\x12\x1c\n" +
- "\x18ISSUE_STATUS_UNSPECIFIED\x10\x00\x12\b\n" +
- "\x04OPEN\x10\x01\x12\b\n" +
- "\x04DONE\x10\x02\x12\f\n" +
- "\bCANCELED\x10\x03B\x14Z\x12generated-go/storeb\x06proto3"
+ "expirationB\x14Z\x12generated-go/storeb\x06proto3"
var (
file_store_issue_proto_rawDescOnce sync.Once
@@ -244,16 +244,16 @@ func file_store_issue_proto_rawDescGZIP() []byte {
var file_store_issue_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_store_issue_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_store_issue_proto_goTypes = []any{
- (IssueStatus)(0), // 0: bytebase.store.IssueStatus
- (*IssuePayload)(nil), // 1: bytebase.store.IssuePayload
+ (Issue_Status)(0), // 0: bytebase.store.Issue.Status
+ (*Issue)(nil), // 1: bytebase.store.Issue
(*GrantRequest)(nil), // 2: bytebase.store.GrantRequest
(*IssuePayloadApproval)(nil), // 3: bytebase.store.IssuePayloadApproval
(*expr.Expr)(nil), // 4: google.type.Expr
(*durationpb.Duration)(nil), // 5: google.protobuf.Duration
}
var file_store_issue_proto_depIdxs = []int32{
- 3, // 0: bytebase.store.IssuePayload.approval:type_name -> bytebase.store.IssuePayloadApproval
- 2, // 1: bytebase.store.IssuePayload.grant_request:type_name -> bytebase.store.GrantRequest
+ 3, // 0: bytebase.store.Issue.approval:type_name -> bytebase.store.IssuePayloadApproval
+ 2, // 1: bytebase.store.Issue.grant_request:type_name -> bytebase.store.GrantRequest
4, // 2: bytebase.store.GrantRequest.condition:type_name -> google.type.Expr
5, // 3: bytebase.store.GrantRequest.expiration:type_name -> google.protobuf.Duration
4, // [4:4] is the sub-list for method output_type
diff --git a/proto/store/store/issue.proto b/proto/store/store/issue.proto
index 610cbc30d8..f898d2a4aa 100644
--- a/proto/store/store/issue.proto
+++ b/proto/store/store/issue.proto
@@ -8,14 +8,14 @@ import "store/approval.proto";
option go_package = "generated-go/store";
-enum IssueStatus {
- ISSUE_STATUS_UNSPECIFIED = 0;
- OPEN = 1;
- DONE = 2;
- CANCELED = 3;
-}
+message Issue {
+ enum Status {
+ ISSUE_STATUS_UNSPECIFIED = 0;
+ OPEN = 1;
+ DONE = 2;
+ CANCELED = 3;
+ }
-message IssuePayload {
IssuePayloadApproval approval = 1;
GrantRequest grant_request = 2;
repeated string labels = 3;