Skip to content

Commit 3f15511

Browse files
d-bytebaseclaude
andauthored
feat: add approval template id field for Bytebase 3.11 compatibility (#156)
* feat: add approval template id field for Bytebase 3.12 compatibility Add support for the new ApprovalTemplate.id field introduced in Bytebase API to support both built-in and custom approval templates. Changes: - Add required 'id' field to approval flow schema with validation - Update convertToV1ApprovalSetting to set template ID - Update flattenWorkspaceApprovalSetting to include template ID - Update Bytebase protobuf dependencies to latest version Built-in templates use 'bb.*' prefix (e.g., 'bb.project-owner', 'bb.workspace-dba'), while custom templates use UUIDs. Related: bytebase/bytebase#17689 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * test: add required id field to approval flow test cases Update all approval flow test cases to include the new required 'id' field. Use custom flow IDs (e.g., 'test-flow', 'test-ddl-approval-flow') instead of built-in 'bb.*' prefixed IDs for test cases. Fixes test failures caused by adding the required id field to ApprovalTemplate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: update examples and documentation for approval template id field Update all examples and tutorials to include the required 'id' field in approval flow configurations. Regenerate documentation to reflect the new schema changes. Changes: - Add id field to examples/setup/approval_flow.tf - Add id field to tutorials/4-3-approval-flow.tf - Regenerate docs/resources/setting.md with updated schema - Regenerate docs/data-sources/setting.md with updated schema All examples now use the built-in template ID format: 'bb.project-owner-workspace-dba-workspace-admin' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore: bump version to 3.11.2 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent a9542b5 commit 3f15511

File tree

12 files changed

+25
-9
lines changed

12 files changed

+25
-9
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.11.1
1+
3.11.2

docs/data-sources/risk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The risk data source.
2424
- `active` (Boolean) The risk active.
2525
- `condition` (String) The risk condition.
2626
- `id` (String) The ID of this resource.
27-
- `level` (Number) The risk level.
27+
- `level` (String) The risk level.
2828
- `source` (String) The risk source.
2929
- `title` (String) The risk title.
3030

docs/data-sources/risk_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Read-Only:
2727

2828
- `active` (Boolean)
2929
- `condition` (String)
30-
- `level` (Number)
30+
- `level` (String)
3131
- `name` (String)
3232
- `source` (String)
3333
- `title` (String)

docs/data-sources/setting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ Read-Only:
214214
Read-Only:
215215

216216
- `description` (String)
217+
- `id` (String)
217218
- `roles` (List of String)
218219
- `title` (String)
219220

docs/resources/setting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Optional:
5555

5656
Required:
5757

58+
- `id` (String) The approval template ID. Built-in templates use 'bb.*' prefix (e.g., 'bb.project-owner', 'bb.workspace-dba'), custom templates use UUIDs.
5859
- `roles` (List of String) The role require to review in this step
5960
- `title` (String)
6061

examples/setup/approval_flow.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resource "bytebase_setting" "approval_flow" {
33
approval_flow {
44
rules {
55
flow {
6+
id = "bb.project-owner-workspace-dba-workspace-admin"
67
title = "Project Owner -> DBA -> Admin"
78
description = "Need DBA and workspace admin approval"
89

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.24.4
55
toolchain go1.24.5
66

77
require (
8-
buf.build/gen/go/bytebase/bytebase/connectrpc/go v1.19.1-20251010051414-0534aa930702.1
9-
buf.build/gen/go/bytebase/bytebase/protocolbuffers/go v1.36.10-20251010051414-0534aa930702.1
8+
buf.build/gen/go/bytebase/bytebase/connectrpc/go v1.19.1-20251010220308-691f96ff880a.1
9+
buf.build/gen/go/bytebase/bytebase/protocolbuffers/go v1.36.10-20251010220308-691f96ff880a.1
1010
connectrpc.com/connect v1.19.1
1111
github.com/hashicorp/go-cty v1.5.0
1212
github.com/hashicorp/terraform-plugin-docs v0.13.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
buf.build/gen/go/bytebase/bytebase/connectrpc/go v1.19.1-20251010051414-0534aa930702.1 h1:T4v2vd8e4RkC6ccfOdsvmDZ7YnW2YyAT6OFMdwcPgOA=
2-
buf.build/gen/go/bytebase/bytebase/connectrpc/go v1.19.1-20251010051414-0534aa930702.1/go.mod h1:A57O99YuSmuL9rUI39AMITcbFfJc6Ikv48Qb6Y2EgCw=
3-
buf.build/gen/go/bytebase/bytebase/protocolbuffers/go v1.36.10-20251010051414-0534aa930702.1 h1:5bZgEFfHz4kUG6fkHH9wmBG3dxyaA5rKpaprSP0csTo=
4-
buf.build/gen/go/bytebase/bytebase/protocolbuffers/go v1.36.10-20251010051414-0534aa930702.1/go.mod h1:hCjM3DsxzHQGb3QEnCNYrln9ZgB16AZLOVfRJZRKC0E=
1+
buf.build/gen/go/bytebase/bytebase/connectrpc/go v1.19.1-20251010220308-691f96ff880a.1 h1:lHkgDYgiCUVEYxeBhBfwe53D90a/jr1kJskRHSls/WQ=
2+
buf.build/gen/go/bytebase/bytebase/connectrpc/go v1.19.1-20251010220308-691f96ff880a.1/go.mod h1:MQOZqauUrfWO1ApLaYR4F9cjujYikybwynvA3e0og5I=
3+
buf.build/gen/go/bytebase/bytebase/protocolbuffers/go v1.36.10-20251010220308-691f96ff880a.1 h1:l7ZT3ubbTddSaTBPfgGntWuhQgX/CMGGwxMRrYa6pr8=
4+
buf.build/gen/go/bytebase/bytebase/protocolbuffers/go v1.36.10-20251010220308-691f96ff880a.1/go.mod h1:hCjM3DsxzHQGb3QEnCNYrln9ZgB16AZLOVfRJZRKC0E=
55
connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14=
66
connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w=
77
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=

provider/data_source_setting.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,12 @@ func getWorkspaceApprovalSetting(computed bool) *schema.Schema {
502502
Type: schema.TypeList,
503503
Elem: &schema.Resource{
504504
Schema: map[string]*schema.Schema{
505+
"id": {
506+
Type: schema.TypeString,
507+
Required: true,
508+
ValidateFunc: validation.StringIsNotEmpty,
509+
Description: "The approval template ID. Built-in templates use 'bb.*' prefix (e.g., 'bb.project-owner', 'bb.workspace-dba'), custom templates use UUIDs.",
510+
},
505511
"title": {
506512
Type: schema.TypeString,
507513
Required: true,
@@ -733,6 +739,7 @@ func flattenWorkspaceApprovalSetting(ctx context.Context, client api.Client, set
733739
"conditions": conditionList,
734740
"flow": []interface{}{
735741
map[string]interface{}{
742+
"id": rule.Template.Id,
736743
"title": rule.Template.Title,
737744
"description": rule.Template.Description,
738745
"roles": roleList,

provider/resource_setting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ func convertToV1ApprovalSetting(d *schema.ResourceData) (*v1pb.WorkspaceApproval
371371
rawFlow := flowList[0].(map[string]interface{})
372372
approvalRule := &v1pb.WorkspaceApprovalSetting_Rule{
373373
Template: &v1pb.ApprovalTemplate{
374+
Id: rawFlow["id"].(string),
374375
Title: rawFlow["title"].(string),
375376
Description: rawFlow["description"].(string),
376377
Flow: &v1pb.ApprovalFlow{},

0 commit comments

Comments
 (0)