Skip to content

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

fix: several fix (#16125)

ecmadaofb61d2e827a1
diff --git a/backend/api/v1/database_group_service.go b/backend/api/v1/database_group_service.go
index a05859ff3b..c0c9a005bf 100644
--- a/backend/api/v1/database_group_service.go
+++ b/backend/api/v1/database_group_service.go
@@ -136,7 +136,7 @@ func (s *DatabaseGroupService) UpdateDatabaseGroup(ctx context.Context, request
var updateDatabaseGroup store.UpdateDatabaseGroupMessage
for _, path := range request.UpdateMask.Paths {
switch path {
- case "database_placeholder":
+ case "title":
if request.DatabaseGroup.Title == "" {
return nil, status.Errorf(codes.InvalidArgument, "database group database placeholder is required")
}
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
index 571a3a6cbe..5bf3b90434 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
@@ -237,7 +237,7 @@ const doConfirm = async () => {
const updateMask: string[] = [];
if (!isEqual(props.databaseGroup.title, formState.placeholder)) {
- updateMask.push("database_placeholder");
+ updateMask.push("title");
}
if (
!isEqual(
diff --git a/frontend/src/components/SQLReview/SQLReviewCreation.vue b/frontend/src/components/SQLReview/SQLReviewCreation.vue
index 1ab6c9bb41..ece190fc53 100644
--- a/frontend/src/components/SQLReview/SQLReviewCreation.vue
+++ b/frontend/src/components/SQLReview/SQLReviewCreation.vue
@@ -16,7 +16,6 @@
<SQLReviewInfo
:name="state.name"
:resource-id="state.resourceId"
- :attached-resources="state.attachedResources"
:selected-template-id="
state.pendingApplyTemplate?.id ?? state.selectedTemplateId
"
diff --git a/frontend/src/components/SQLReview/SQLReviewInfo.vue b/frontend/src/components/SQLReview/SQLReviewInfo.vue
index 7999ba1237..239b91d1e9 100644
--- a/frontend/src/components/SQLReview/SQLReviewInfo.vue
+++ b/frontend/src/components/SQLReview/SQLReviewInfo.vue
@@ -131,15 +131,20 @@ import {
import { DatabaseSelect, EnvironmentSelect, ProjectSelect } from "../v2";
import { SQLReviewTemplateSelector } from "./components";
-const props = defineProps<{
- name: string;
- resourceId: string;
- attachedResources: string[];
- isCreate: boolean;
- selectedTemplateId?: string;
- isEdit: boolean;
- allowChangeAttachedResource: boolean;
-}>();
+const props = withDefaults(
+ defineProps<{
+ name: string;
+ resourceId: string;
+ attachedResources?: string[];
+ isCreate: boolean;
+ selectedTemplateId?: string;
+ isEdit: boolean;
+ allowChangeAttachedResource: boolean;
+ }>(),
+ {
+ attachedResources: () => [],
+ }
+);
const emit = defineEmits<{
(event: "name-change", name: string): void;
diff --git a/frontend/src/types/proto/v1/database_group_service.ts b/frontend/src/types/proto/v1/database_group_service.ts
index de4266df1d..7df71e5200 100644
--- a/frontend/src/types/proto/v1/database_group_service.ts
+++ b/frontend/src/types/proto/v1/database_group_service.ts
@@ -169,7 +169,19 @@ export interface DatabaseGroup {
name: string;
/** The short name used in actual databases specified by users. */
title: string;
- /** The condition that is associated with this database group. */
+ /**
+ * The condition that is associated with this database group.
+ * The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ *
+ * Support variables:
+ * resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ * resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ * resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ * All variables should join with "&&" condition.
+ *
+ * For example:
+ * resource.environment_name == "test" && resource.database_name.startsWith("sample_")
+ */
databaseExpr:
| Expr
| undefined;
diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
index f9198b5068..c2ad32a47b 100644
--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
@@ -7,6 +7,7 @@
:policy="reviewPolicy"
:name="reviewPolicy.name"
:selected-rule-list="ruleListOfPolicy"
+ :selected-resources="reviewPolicy.resources"
@cancel="state.editMode = false"
/>
<div v-else>
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 230ccc6845..b9e91bccec 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -9266,7 +9266,18 @@ components:
databaseExpr:
allOf:
- $ref: '#/components/schemas/Expr'
- description: The condition that is associated with this database group.
+ description: |-
+ The condition that is associated with this database group.
+ The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+
+ Support variables:
+ resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ All variables should join with "&&" condition.
+
+ For example:
+ resource.environment_name == "test" && resource.database_name.startsWith("sample_")
matchedDatabases:
readOnly: true
type: array
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 28a595f2ef..ec95302942 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -6166,7 +6166,11 @@ This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |
| ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the database group. Format: projects/{project}/databaseGroups/{databaseGroup} |
| title | [string](#string) | | The short name used in actual databases specified by users. |
-| database_expr | [google.type.Expr](#google-type-Expr) | | The condition that is associated with this database group. |
+| database_expr | [google.type.Expr](#google-type-Expr) | | The condition that is associated with this database group. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+
+Support variables: resource.environment_name: the environment resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34; operations. resource.instance_id: the instance resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations. resource.database_name: the database name. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations. All variables should join with &#34;&amp;&amp;&#34; condition.
+
+For example: resource.environment_name == &#34;test&#34; &amp;&amp; resource.database_name.startsWith(&#34;sample_&#34;) |
| matched_databases | [DatabaseGroup.Database](#bytebase-v1-DatabaseGroup-Database) | repeated | The list of databases that match the database group condition. |
| unmatched_databases | [DatabaseGroup.Database](#bytebase-v1-DatabaseGroup-Database) | repeated | The list of databases that match the database group condition. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 63a1f22ad7..338822689f 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -17473,7 +17473,17 @@ Format: projects/{project}/databaseGroups/{databaseGroup} </p></td>
<td>database_expr</td>
<td><a href="#google.type.Expr">google.type.Expr</a></td>
<td></td>
- <td><p>The condition that is associated with this database group. </p></td>
+ <td><p>The condition that is associated with this database group.
+The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+
+Support variables:
+resource.environment_name: the environment resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34; operations.
+resource.instance_id: the instance resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations.
+resource.database_name: the database name. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations.
+All variables should join with &#34;&amp;&amp;&#34; condition.
+
+For example:
+resource.environment_name == &#34;test&#34; &amp;&amp; resource.database_name.startsWith(&#34;sample_&#34;) </p></td>
</tr>
<tr>
diff --git a/proto/generated-go/v1/database_group_service.pb.go b/proto/generated-go/v1/database_group_service.pb.go
index af6e0039b7..098f748334 100644
--- a/proto/generated-go/v1/database_group_service.pb.go
+++ b/proto/generated-go/v1/database_group_service.pb.go
@@ -449,6 +449,16 @@ type DatabaseGroup struct {
// The short name used in actual databases specified by users.
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
// The condition that is associated with this database group.
+ // The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ //
+ // Support variables:
+ // resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ // resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ // resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ // All variables should join with "&&" condition.
+ //
+ // For example:
+ // resource.environment_name == "test" && resource.database_name.startsWith("sample_")
DatabaseExpr *expr.Expr `protobuf:"bytes,3,opt,name=database_expr,json=databaseExpr,proto3" json:"database_expr,omitempty"`
// The list of databases that match the database group condition.
MatchedDatabases []*DatabaseGroup_Database `protobuf:"bytes,4,rep,name=matched_databases,json=matchedDatabases,proto3" json:"matched_databases,omitempty"`
diff --git a/proto/v1/v1/database_group_service.proto b/proto/v1/v1/database_group_service.proto
index 3d87e454c2..00a315f520 100644
--- a/proto/v1/v1/database_group_service.proto
+++ b/proto/v1/v1/database_group_service.proto
@@ -172,6 +172,16 @@ message DatabaseGroup {
string title = 2;
// The condition that is associated with this database group.
+ // The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ //
+ // Support variables:
+ // resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ // resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ // resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ // All variables should join with "&&" condition.
+ //
+ // For example:
+ // resource.environment_name == "test" && resource.database_name.startsWith("sample_")
google.type.Expr database_expr = 3;
message Database {