Skip to content

Commit 77a118e

Browse files
authored
chore: database role to instance role and role title to role name (#37)
* chore: database role to instance role and role title to role name * chore: update
1 parent 9d5033f commit 77a118e

17 files changed

+86
-86
lines changed

api/database_role.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ type RoleAttribute struct {
1414
// Role is the API message for role.
1515
type Role struct {
1616
Name string `json:"name"`
17-
Title string `json:"title"`
17+
RoleName string `json:"roleName"`
1818
ConnectionLimit int `json:"connectionLimit"`
1919
ValidUntil *string `json:"validUntil"`
2020
Attribute *RoleAttribute `json:"attribute"`
2121
}
2222

2323
// RoleUpsert is the API message for upserting a new role.
2424
type RoleUpsert struct {
25-
Title string `json:"title"`
25+
RoleName string `json:"roleName"`
2626
Password *string `json:"password"`
2727
ConnectionLimit *int `json:"connectionLimit"`
2828
ValidUntil *string `json:"validUntil"`

client/database_role.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ func (c *client) UpdateRole(ctx context.Context, environmentID, instanceID, role
8989
}
9090

9191
paths := []string{}
92-
if patch.Title != roleName {
93-
paths = append(paths, "role.title")
92+
if patch.RoleName != roleName {
93+
paths = append(paths, "role.role_name")
9494
}
9595
if patch.Password != nil {
9696
paths = append(paths, "role.password")

docs/data-sources/database_role.md renamed to docs/data-sources/instance_role.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
22
# generated by https://github.com/hashicorp/terraform-plugin-docs
3-
page_title: "bytebase_database_role Data Source - terraform-provider-bytebase"
3+
page_title: "bytebase_instance_role Data Source - terraform-provider-bytebase"
44
subcategory: ""
55
description: |-
6-
The database role data source.
6+
The instance role data source.
77
---
88

9-
# bytebase_database_role (Data Source)
9+
# bytebase_instance_role (Data Source)
1010

1111
> Requires the Bytebase version > 1.9.1 or use the release-ci.
1212
13-
The database role data source. You can get a single role in a specific instance through the `bytebase_database_role` data source.
13+
The instance role data source. You can get a single role in a specific instance through the `bytebase_instance_role` data source.
1414

1515
## Example Usage
1616

1717
```terraform
18-
data "bytebase_database_role" "find_role" {
18+
data "bytebase_instance_role" "find_role" {
1919
name = "<role name>"
2020
instance = "<the instance resource id>"
2121
environment = "<the environment resource id>"

docs/data-sources/database_role_list.md renamed to docs/data-sources/instance_role_list.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
22
# generated by https://github.com/hashicorp/terraform-plugin-docs
3-
page_title: "bytebase_database_role_list Data Source - terraform-provider-bytebase"
3+
page_title: "bytebase_instance_role_list Data Source - terraform-provider-bytebase"
44
subcategory: ""
55
description: |-
6-
The database role list data source.
6+
The instance role list data source.
77
---
88

9-
# bytebase_database_role_list (Data Source)
9+
# bytebase_instance_role_list (Data Source)
1010

1111
> Requires the Bytebase version > 1.9.1 or use the release-ci.
1212
13-
The database role list data source. You can list roles in a specific instance through the `bytebase_database_role_list` data source.
13+
The instance role list data source. You can list roles in a specific instance through the `bytebase_instance_role_list` data source.
1414

1515
## Example Usage
1616

1717
```terraform
18-
data "bytebase_database_role_list" "list_role" {
18+
data "bytebase_instance_role_list" "list_role" {
1919
instance = "<the instance resource id>"
2020
environment = "<the environment resource id>"
2121
}
@@ -37,4 +37,4 @@ data "bytebase_database_role_list" "list_role" {
3737

3838
### Nested Schema for `roles`
3939

40-
See [Role Schema](https://registry.terraform.io/providers/bytebase/bytebase/latest/docs/data-sources/database_role#schema).
40+
See [Role Schema](https://registry.terraform.io/providers/bytebase/bytebase/latest/docs/data-sources/instance_role#schema).

docs/resources/database_role.md renamed to docs/resources/instance_role.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
22
# generated by https://github.com/hashicorp/terraform-plugin-docs
3-
page_title: "bytebase_database_role Resource - terraform-provider-bytebase"
3+
page_title: "bytebase_instance_role Resource - terraform-provider-bytebase"
44
subcategory: ""
55
description: |-
6-
The database role resource.
6+
The instance role resource.
77
---
88

9-
# bytebase_database_role (Resource)
9+
# bytebase_instance_role (Resource)
1010

1111
> Requires the Bytebase version > 1.9.1 or use the release-ci.
1212
13-
Database role resource. You can read, create, update or delete a single role in a specific instance through `bytebase_database_role` resource.
13+
Instance role resource. You can read, create, update or delete a single role in a specific instance through `bytebase_instance_role` resource.
1414

1515
## Example Usage
1616

1717
```terraform
18-
resource "bytebase_database_role" "admin" {
18+
resource "bytebase_instance_role" "admin" {
1919
name = "admin"
2020
instance = "<the instance resource id>"
2121
environment = "<the environment resource id>"

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Examples of using the Terraform Bytebase Provider to manage your resource:
55
- [setup](./setup): Initialize the data.
66
- [environments](./environments): Use the Bytebase provider to query the environment.
77
- [instances](./instances): Use the Bytebase provider to query the instance.
8-
- [role](./role): Use the Bytebase provider to manage database role in your instance.
8+
- [role](./role): Use the Bytebase provider to manage instance role in your instance.
99

1010
To run this provider on your local machine:
1111

examples/roles/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Example of database role resource
1+
# Example of instance role resource
22

3-
This is an example of using the Terraform Bytebase Provider to query the database role in a specific instance.
3+
This is an example of using the Terraform Bytebase Provider to query the instance role in a specific instance.
44

55
You should replace the provider initial variables with your own and exec the [setup](../setup/) before running this example.
66

@@ -9,15 +9,15 @@ You should replace the provider initial variables with your own and exec the [se
99
## List roles
1010

1111
```terraform
12-
data "bytebase_database_role_list" "all" {
12+
data "bytebase_instance_role_list" "all" {
1313
instance = "<the instance name>"
1414
}
1515
```
1616

1717
## Find role by name
1818

1919
```terraform
20-
data "bytebase_database_role" "dev" {
20+
data "bytebase_instance_role" "dev" {
2121
name = "<the role name>"
2222
instance = "<the instance name>"
2323
}

examples/roles/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ data "bytebase_instance" "test" {
3030
}
3131

3232
# Find the role "role_test_terraform" in the instance "test-instance"
33-
data "bytebase_database_role" "test" {
33+
data "bytebase_instance_role" "test" {
3434
name = local.role_name
3535
instance = data.bytebase_instance.test.resource_id
3636
environment = data.bytebase_instance.test.environment
3737
}
3838

3939
output "role" {
40-
value = data.bytebase_database_role.test
40+
value = data.bytebase_instance_role.test
4141
}
4242

4343
# List all roles in the instance "test-instance"
44-
data "bytebase_database_role_list" "all" {
44+
data "bytebase_instance_role_list" "all" {
4545
instance = data.bytebase_instance.test.resource_id
4646
environment = data.bytebase_instance.test.environment
4747
}
4848

4949
output "list_role" {
50-
value = data.bytebase_database_role_list.all
50+
value = data.bytebase_instance_role_list.all
5151
}

examples/setup/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ resource "bytebase_instance" "prod" {
8989
}
9090

9191
# Create a new role named "role_test_terraform" in the instance "test-instance"
92-
resource "bytebase_database_role" "test" {
92+
resource "bytebase_instance_role" "test" {
9393
name = local.role_name
9494
instance = bytebase_instance.test.resource_id
9595
environment = bytebase_instance.test.environment

provider/data_source_database_role.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"github.com/bytebase/terraform-provider-bytebase/provider/internal"
1212
)
1313

14-
func dataSourceDatabaseRole() *schema.Resource {
14+
func dataSourceInstanceRole() *schema.Resource {
1515
return &schema.Resource{
16-
Description: "The database role data source.",
16+
Description: "The instance role data source.",
1717
ReadContext: dataSourceRoleRead,
1818
Schema: map[string]*schema.Schema{
1919
"name": {

0 commit comments

Comments
 (0)