Skip to content

Commit e1d8049

Browse files
authored
chore: update docs and examples for review rules (#114)
* chore: update docs and examples for review rules * chore: update docs
1 parent e45e306 commit e1d8049

File tree

7 files changed

+30
-10
lines changed

7 files changed

+30
-10
lines changed

docs/data-sources/setting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The setting data source.
1717

1818
### Required
1919

20-
- `name` (String)
20+
- `name` (String) The setting name in settings/{name} format. The name support "WORKSPACE_APPROVAL", "WORKSPACE_PROFILE", "DATA_CLASSIFICATION", "SEMANTIC_TYPES" and "ENVIRONMENT". Check the proto https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/setting_service.proto#L109 for details
2121

2222
### Optional
2323

docs/resources/review_config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Required:
3737

3838
- `engine` (String) The rule for the database engine.
3939
- `level` (String) The rule level.
40-
- `type` (String) The rule unique type. Check https://www.bytebase.com/docs/sql-review/review-rules for all rules
40+
- `type` (String) The rule unique type. Check https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/SQL_REVIEW_RULES_DOCUMENTATION.md#rule-categories for all rules
4141

4242
Optional:
4343

4444
- `comment` (String) The comment for the rule.
45-
- `payload` (String) The payload for the rule.
45+
- `payload` (String) The payload is a JSON string that varies by rule type. Check https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/SQL_REVIEW_RULES_DOCUMENTATION.md#payload-structure-types for all details
4646

4747

docs/resources/setting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The setting resource.
1717

1818
### Required
1919

20-
- `name` (String)
20+
- `name` (String) The setting name in settings/{name} format. The name support "WORKSPACE_APPROVAL", "WORKSPACE_PROFILE", "DATA_CLASSIFICATION", "SEMANTIC_TYPES" and "ENVIRONMENT". Check the proto https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/setting_service.proto#L109 for details
2121

2222
### Optional
2323

examples/setup/sql_review.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,27 @@ resource "bytebase_review_config" "sample" {
1515
engine = "MYSQL"
1616
level = "WARNING"
1717
}
18+
rules {
19+
type = "column.required"
20+
engine = "MYSQL"
21+
level = "ERROR"
22+
payload = "{\"list\":[\"id\",\"created_ts\",\"updated_ts\",\"creator_id\",\"updater_id\"]}"
23+
}
1824
rules {
1925
type = "table.require-pk"
2026
engine = "MYSQL"
2127
level = "ERROR"
2228
}
29+
rules {
30+
type = "naming.column"
31+
engine = "MYSQL"
32+
level = "ERROR"
33+
payload = "{\"format\":\"^[a-z]+(_[a-z]+)*$\",\"maxLength\":64}"
34+
}
35+
rules {
36+
type = "statement.maximum-limit-value"
37+
engine = "MYSQL"
38+
level = "ERROR"
39+
payload = "{\"number\":1000}"
40+
}
2341
}

provider/data_source_setting.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ func dataSourceSetting() *schema.Resource {
2323
ReadContext: dataSourceSettingRead,
2424
Schema: map[string]*schema.Schema{
2525
"name": {
26-
Type: schema.TypeString,
27-
Required: true,
26+
Type: schema.TypeString,
27+
Required: true,
28+
Description: `The setting name in settings/{name} format. The name support "WORKSPACE_APPROVAL", "WORKSPACE_PROFILE", "DATA_CLASSIFICATION", "SEMANTIC_TYPES" and "ENVIRONMENT". Check the proto https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/setting_service.proto#L109 for details`,
2829
ValidateDiagFunc: internal.ResourceNameValidation(
2930
regexp.MustCompile(fmt.Sprintf("^%s%s$", internal.SettingNamePrefix, v1pb.Setting_WORKSPACE_APPROVAL.String())),
3031
regexp.MustCompile(fmt.Sprintf("^%s%s$", internal.SettingNamePrefix, v1pb.Setting_WORKSPACE_PROFILE.String())),

provider/resource_review_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func resourceReviewConfig() *schema.Resource {
6262
"type": {
6363
Type: schema.TypeString,
6464
Required: true,
65-
Description: "The rule unique type. Check https://www.bytebase.com/docs/sql-review/review-rules for all rules",
65+
Description: "The rule unique type. Check https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/SQL_REVIEW_RULES_DOCUMENTATION.md#rule-categories for all rules",
6666
},
6767
"engine": {
6868
Type: schema.TypeString,
@@ -84,7 +84,7 @@ func resourceReviewConfig() *schema.Resource {
8484
Type: schema.TypeString,
8585
Optional: true,
8686
Computed: true,
87-
Description: "The payload for the rule.",
87+
Description: "The payload is a JSON string that varies by rule type. Check https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/SQL_REVIEW_RULES_DOCUMENTATION.md#payload-structure-types for all details",
8888
},
8989
"comment": {
9090
Type: schema.TypeString,

provider/resource_setting.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ func resourceSetting() *schema.Resource {
2929
},
3030
Schema: map[string]*schema.Schema{
3131
"name": {
32-
Type: schema.TypeString,
33-
Required: true,
32+
Type: schema.TypeString,
33+
Required: true,
34+
Description: `The setting name in settings/{name} format. The name support "WORKSPACE_APPROVAL", "WORKSPACE_PROFILE", "DATA_CLASSIFICATION", "SEMANTIC_TYPES" and "ENVIRONMENT". Check the proto https://github.com/bytebase/bytebase/blob/main/proto/v1/v1/setting_service.proto#L109 for details`,
3435
ValidateDiagFunc: internal.ResourceNameValidation(
3536
regexp.MustCompile(fmt.Sprintf("^%s%s$", internal.SettingNamePrefix, v1pb.Setting_WORKSPACE_APPROVAL.String())),
3637
regexp.MustCompile(fmt.Sprintf("^%s%s$", internal.SettingNamePrefix, v1pb.Setting_WORKSPACE_PROFILE.String())),

0 commit comments

Comments
 (0)