Skip to content

Commit 87a42a5

Browse files
authored
feat: support semantic type setting (#94)
* chore: use set for unordered collection * chore: update doc * fix: list all databases in the project * chore: update * fix: lint * chore: add databases for instance * chore: more error log * chore: update * chore: update * feat: database resource * fix: lint * feat: support semantic type setting * fix: lint * chore: update
1 parent 5522574 commit 87a42a5

File tree

20 files changed

+552
-27
lines changed

20 files changed

+552
-27
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.14
1+
1.0.15

api/setting.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const (
1212
SettingWorkspaceExternalApproval SettingName = "bb.workspace.approval.external"
1313
// SettingDataClassification is the setting name for data classification.
1414
SettingDataClassification SettingName = "bb.workspace.data-classification"
15+
// SettingSemanticTypes is the setting name for semantic types.
16+
SettingSemanticTypes SettingName = "bb.workspace.semantic-types"
1517
)
1618

1719
// RiskLevel is the approval risk level.

client/cel.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"net/http"
77
"strings"
88

9-
"github.com/hashicorp/terraform-plugin-log/tflog"
10-
119
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
1210
"github.com/pkg/errors"
1311
v1alpha1 "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
@@ -33,8 +31,6 @@ func (c *client) ParseExpression(ctx context.Context, expression string) (*v1alp
3331
return nil, err
3432
}
3533

36-
tflog.Debug(ctx, fmt.Sprintf("parse cel response:\n%v", string(body)))
37-
3834
var res v1pb.BatchParseResponse
3935
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
4036
return nil, err

docs/data-sources/setting.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The setting data source.
2222
### Optional
2323

2424
- `classification` (Block List, Max: 1) Classification for data masking. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--classification))
25+
- `semantic_types` (Block Set) Semantic types for data masking. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--semantic_types))
2526
- `workspace_profile` (Block List, Max: 1) (see [below for nested schema](#nestedblock--workspace_profile))
2627

2728
### Read-Only
@@ -63,6 +64,73 @@ Optional:
6364

6465

6566

67+
<a id="nestedblock--semantic_types"></a>
68+
### Nested Schema for `semantic_types`
69+
70+
Optional:
71+
72+
- `algorithm` (Block List, Max: 1) The semantic type algorithm. Required. (see [below for nested schema](#nestedblock--semantic_types--algorithm))
73+
- `description` (String) The semantic type description. Optional.
74+
- `id` (String) The semantic type unique uuid.
75+
- `title` (String) The semantic type title. Required.
76+
77+
<a id="nestedblock--semantic_types--algorithm"></a>
78+
### Nested Schema for `semantic_types.algorithm`
79+
80+
Optional:
81+
82+
- `full_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--full_mask))
83+
- `inner_outer_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--inner_outer_mask))
84+
- `md5_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--md5_mask))
85+
- `range_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--range_mask))
86+
87+
<a id="nestedblock--semantic_types--algorithm--full_mask"></a>
88+
### Nested Schema for `semantic_types.algorithm.full_mask`
89+
90+
Optional:
91+
92+
- `substitution` (String) Substitution is the string used to replace the original value, the max length of the string is 16 bytes.
93+
94+
95+
<a id="nestedblock--semantic_types--algorithm--inner_outer_mask"></a>
96+
### Nested Schema for `semantic_types.algorithm.inner_outer_mask`
97+
98+
Optional:
99+
100+
- `prefix_len` (Number)
101+
- `substitution` (String)
102+
- `suffix_len` (Number)
103+
- `type` (String)
104+
105+
106+
<a id="nestedblock--semantic_types--algorithm--md5_mask"></a>
107+
### Nested Schema for `semantic_types.algorithm.md5_mask`
108+
109+
Optional:
110+
111+
- `salt` (String) Salt is the salt value to generate a different hash that with the word alone.
112+
113+
114+
<a id="nestedblock--semantic_types--algorithm--range_mask"></a>
115+
### Nested Schema for `semantic_types.algorithm.range_mask`
116+
117+
Optional:
118+
119+
- `slices` (Block List) (see [below for nested schema](#nestedblock--semantic_types--algorithm--range_mask--slices))
120+
121+
<a id="nestedblock--semantic_types--algorithm--range_mask--slices"></a>
122+
### Nested Schema for `semantic_types.algorithm.range_mask.slices`
123+
124+
Optional:
125+
126+
- `end` (Number) End is the stop index of the original value, should be less than the length of the original value.
127+
- `start` (Number) Start is the start index of the original value, start from 0 and should be less than stop.
128+
- `substitution` (String) Substitution is the string used to replace the OriginalValue[start:end).
129+
130+
131+
132+
133+
66134
<a id="nestedblock--workspace_profile"></a>
67135
### Nested Schema for `workspace_profile`
68136

docs/resources/setting.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The setting resource.
2424
- `approval_flow` (Block List) Configure risk level and approval flow for different tasks. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--approval_flow))
2525
- `classification` (Block List, Max: 1) Classification for data masking. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--classification))
2626
- `external_approval_nodes` (Block List) Configure external nodes in the approval flow. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--external_approval_nodes))
27+
- `semantic_types` (Block Set) Semantic types for data masking. Require ENTERPRISE subscription. (see [below for nested schema](#nestedblock--semantic_types))
2728
- `workspace_profile` (Block List, Max: 1) (see [below for nested schema](#nestedblock--workspace_profile))
2829

2930
### Read-Only
@@ -136,6 +137,73 @@ Required:
136137

137138

138139

140+
<a id="nestedblock--semantic_types"></a>
141+
### Nested Schema for `semantic_types`
142+
143+
Optional:
144+
145+
- `algorithm` (Block List, Max: 1) The semantic type algorithm. Required. (see [below for nested schema](#nestedblock--semantic_types--algorithm))
146+
- `description` (String) The semantic type description. Optional.
147+
- `id` (String) The semantic type unique uuid.
148+
- `title` (String) The semantic type title. Required.
149+
150+
<a id="nestedblock--semantic_types--algorithm"></a>
151+
### Nested Schema for `semantic_types.algorithm`
152+
153+
Optional:
154+
155+
- `full_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--full_mask))
156+
- `inner_outer_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--inner_outer_mask))
157+
- `md5_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--md5_mask))
158+
- `range_mask` (Block List, Max: 1) (see [below for nested schema](#nestedblock--semantic_types--algorithm--range_mask))
159+
160+
<a id="nestedblock--semantic_types--algorithm--full_mask"></a>
161+
### Nested Schema for `semantic_types.algorithm.full_mask`
162+
163+
Optional:
164+
165+
- `substitution` (String) Substitution is the string used to replace the original value, the max length of the string is 16 bytes.
166+
167+
168+
<a id="nestedblock--semantic_types--algorithm--inner_outer_mask"></a>
169+
### Nested Schema for `semantic_types.algorithm.inner_outer_mask`
170+
171+
Optional:
172+
173+
- `prefix_len` (Number)
174+
- `substitution` (String)
175+
- `suffix_len` (Number)
176+
- `type` (String)
177+
178+
179+
<a id="nestedblock--semantic_types--algorithm--md5_mask"></a>
180+
### Nested Schema for `semantic_types.algorithm.md5_mask`
181+
182+
Optional:
183+
184+
- `salt` (String) Salt is the salt value to generate a different hash that with the word alone.
185+
186+
187+
<a id="nestedblock--semantic_types--algorithm--range_mask"></a>
188+
### Nested Schema for `semantic_types.algorithm.range_mask`
189+
190+
Optional:
191+
192+
- `slices` (Block List) (see [below for nested schema](#nestedblock--semantic_types--algorithm--range_mask--slices))
193+
194+
<a id="nestedblock--semantic_types--algorithm--range_mask--slices"></a>
195+
### Nested Schema for `semantic_types.algorithm.range_mask.slices`
196+
197+
Optional:
198+
199+
- `end` (Number) End is the stop index of the original value, should be less than the length of the original value.
200+
- `start` (Number) Start is the start index of the original value, start from 0 and should be less than stop.
201+
- `substitution` (String) Substitution is the string used to replace the OriginalValue[start:end).
202+
203+
204+
205+
206+
139207
<a id="nestedblock--workspace_profile"></a>
140208
### Nested Schema for `workspace_profile`
141209

examples/environments/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
terraform {
33
required_providers {
44
bytebase = {
5-
version = "1.0.14"
5+
version = "1.0.15"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

examples/groups/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "1.0.14"
4+
version = "1.0.15"
55
# For local development, please use "terraform.local/bytebase/bytebase" instead
66
source = "registry.terraform.io/bytebase/bytebase"
77
}

examples/instances/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
terraform {
33
required_providers {
44
bytebase = {
5-
version = "1.0.14"
5+
version = "1.0.15"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

examples/policies/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "1.0.14"
4+
version = "1.0.15"
55
# For local development, please use "terraform.local/bytebase/bytebase" instead
66
source = "registry.terraform.io/bytebase/bytebase"
77
}

examples/projects/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
terraform {
33
required_providers {
44
bytebase = {
5-
version = "1.0.14"
5+
version = "1.0.15"
66
# For local development, please use "terraform.local/bytebase/bytebase" instead
77
source = "registry.terraform.io/bytebase/bytebase"
88
}

0 commit comments

Comments
 (0)