Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.19
1.0.20
10 changes: 10 additions & 0 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,14 @@ type Client interface {
GetWorkspaceIAMPolicy(ctx context.Context) (*v1pb.IamPolicy, error)
// SetWorkspaceIAMPolicy sets the workspace IAM policy.
SetWorkspaceIAMPolicy(ctx context.Context, setIamPolicyRequest *v1pb.SetIamPolicyRequest) (*v1pb.IamPolicy, error)

// Review config
// ListReviewConfig will return review configs.
ListReviewConfig(ctx context.Context) (*v1pb.ListReviewConfigsResponse, error)
// GetReviewConfig gets the review config by full name.
GetReviewConfig(ctx context.Context, reviewName string) (*v1pb.ReviewConfig, error)
// UpsertReviewConfig updates or creates the review config.
UpsertReviewConfig(ctx context.Context, patch *v1pb.ReviewConfig, updateMasks []string) (*v1pb.ReviewConfig, error)
// DeleteReviewConfig deletes the review config.
DeleteReviewConfig(ctx context.Context, reviewName string) error
}
2 changes: 1 addition & 1 deletion client/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"google.golang.org/protobuf/encoding/protojson"
)

// ListInstance will return instances in environment.
// ListInstance will return instances.
func (c *client) ListInstance(ctx context.Context, showDeleted bool) (*v1pb.ListInstancesResponse, error) {
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/%s/instances?showDeleted=%v", c.url, c.version, showDeleted), nil)
if err != nil {
Expand Down
64 changes: 64 additions & 0 deletions client/review_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package client

import (
"context"
"fmt"
"net/http"

v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)

// ListReviewConfig will return review configs.
func (c *client) ListReviewConfig(ctx context.Context) (*v1pb.ListReviewConfigsResponse, error) {
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/%s/reviewConfigs", c.url, c.version), nil)
if err != nil {
return nil, err
}

body, err := c.doRequest(req)
if err != nil {
return nil, err
}

var res v1pb.ListReviewConfigsResponse
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
return nil, err
}

return &res, nil
}

// GetReviewConfig gets the review config by full name.
func (c *client) GetReviewConfig(ctx context.Context, reviewName string) (*v1pb.ReviewConfig, error) {
body, err := c.getResource(ctx, reviewName)
if err != nil {
return nil, err
}

var res v1pb.ReviewConfig
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
return nil, err
}

return &res, nil
}

// UpsertReviewConfig updates or creates the review config.
func (c *client) UpsertReviewConfig(ctx context.Context, patch *v1pb.ReviewConfig, updateMasks []string) (*v1pb.ReviewConfig, error) {
body, err := c.updateResource(ctx, patch.Name, patch, updateMasks, true /* allow missing */)
if err != nil {
return nil, err
}

var res v1pb.ReviewConfig
if err := ProtojsonUnmarshaler.Unmarshal(body, &res); err != nil {
return nil, err
}

return &res, nil
}

// DeleteReviewConfig deletes the review config.
func (c *client) DeleteReviewConfig(ctx context.Context, reviewName string) error {
return c.deleteResource(ctx, reviewName)
}
1 change: 1 addition & 0 deletions docs/data-sources/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The group data source.
- `description` (String) The group description.
- `id` (String) The ID of this resource.
- `members` (Set of Object) The members in the group. (see [below for nested schema](#nestedatt--members))
- `roles` (Set of String) The group's roles in the workspace level
- `source` (String) Source means where the group comes from. For now we support Entra ID SCIM sync, so the source could be Entra ID.
- `title` (String) The group title.

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/group_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Read-Only:
- `description` (String)
- `members` (Set of Object) (see [below for nested schema](#nestedobjatt--groups--members))
- `name` (String)
- `roles` (Set of String)
- `source` (String)
- `title` (String)

Expand Down
38 changes: 38 additions & 0 deletions docs/data-sources/review_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "bytebase_review_config Data Source - terraform-provider-bytebase"
subcategory: ""
description: |-
The review config data source.
---

# bytebase_review_config (Data Source)

The review config data source.



<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `enabled` (Boolean) Enable the SQL review config
- `id` (String) The ID of this resource.
- `resource_id` (String) The unique resource id for the review config.
- `resources` (Set of String) Resources using the config. We support attach the review config for environments or projects with format {resurce}/{resource id}. For example, environments/test, projects/sample.
- `rules` (Set of Object) The SQL review rules. (see [below for nested schema](#nestedatt--rules))
- `title` (String) The title for the review config.

<a id="nestedatt--rules"></a>
### Nested Schema for `rules`

Read-Only:

- `comment` (String)
- `engine` (String)
- `level` (String)
- `payload` (String)
- `type` (String)


45 changes: 45 additions & 0 deletions docs/data-sources/review_config_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "bytebase_review_config_list Data Source - terraform-provider-bytebase"
subcategory: ""
description: |-
The review config data source list.
---

# bytebase_review_config_list (Data Source)

The review config data source list.



<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `id` (String) The ID of this resource.
- `review_configs` (List of Object) (see [below for nested schema](#nestedatt--review_configs))

<a id="nestedatt--review_configs"></a>
### Nested Schema for `review_configs`

Read-Only:

- `enabled` (Boolean)
- `resource_id` (String)
- `resources` (Set of String)
- `rules` (Set of Object) (see [below for nested schema](#nestedobjatt--review_configs--rules))
- `title` (String)

<a id="nestedobjatt--review_configs--rules"></a>
### Nested Schema for `review_configs.rules`

Read-Only:

- `comment` (String)
- `engine` (String)
- `level` (String)
- `payload` (String)
- `type` (String)


1 change: 1 addition & 0 deletions docs/resources/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The group resource. Workspace domain is required for creating groups.
### Optional

- `description` (String) The group description.
- `roles` (Set of String) The group's roles in the workspace level

### Read-Only

Expand Down
47 changes: 47 additions & 0 deletions docs/resources/review_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "bytebase_review_config Resource - terraform-provider-bytebase"
subcategory: ""
description: |-
The review config resource.
---

# bytebase_review_config (Resource)

The review config resource.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `enabled` (Boolean) Enable the SQL review config
- `resource_id` (String) The unique resource id for the review config.
- `rules` (Block Set, Min: 1) The SQL review rules. (see [below for nested schema](#nestedblock--rules))
- `title` (String) The title for the review config.

### Optional

- `resources` (Set of String) Resources using the config. We support attach the review config for environments or projects with format {resurce}/{resource id}. For example, environments/test, projects/sample.

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--rules"></a>
### Nested Schema for `rules`

Required:

- `engine` (String) The rule for the database engine.
- `level` (String) The rule level.
- `type` (String) The rule unique type. Check https://www.bytebase.com/docs/sql-review/review-rules for all rules

Optional:

- `comment` (String) The comment for the rule.
- `payload` (String) The payload for the rule.


3 changes: 2 additions & 1 deletion docs/resources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The user resource.
- `password` (String, Sensitive) The user login password.
- `phone` (String) The user phone.
- `roles` (Set of String) The user's roles in the workspace level
- `type` (String) The user type.

### Read-Only

Expand All @@ -33,8 +34,8 @@ The user resource.
- `last_login_time` (String) The user last login time.
- `mfa_enabled` (Boolean) The mfa_enabled flag means if the user has enabled MFA.
- `name` (String) The user name in users/{user id or email} format.
- `service_key` (String) The service key for service account.
- `source` (String) Source means where the user comes from. For now we support Entra ID SCIM sync, so the source could be Entra ID.
- `state` (String) The user is deleted or not.
- `type` (String) The user type.


2 changes: 1 addition & 1 deletion examples/environments/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/groups/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/policies/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/projects/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/roles/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/settings/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/setup/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
bytebase = {
version = "1.0.19"
version = "1.0.20"
# For local development, please use "terraform.local/bytebase/bytebase" instead
source = "registry.terraform.io/bytebase/bytebase"
}
Expand Down
24 changes: 24 additions & 0 deletions examples/setup/sql_review.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "bytebase_review_config" "sample" {
depends_on = [
bytebase_environment.test,
bytebase_environment.prod
]

resource_id = "review-config-sample"
title = "Sample SQL Review Config"
enabled = true
resources = toset([
bytebase_environment.test.name,
bytebase_environment.prod.name
])
rules {
type = "column.no-null"
engine = "MYSQL"
level = "WARNING"
}
rules {
type = "table.require-pk"
engine = "MYSQL"
level = "ERROR"
}
}
Loading