Skip to content

Commit c790110

Browse files
committed
add grafana user
1 parent 3ab0943 commit c790110

8 files changed

+22
-5
lines changed

ovh/data_cloud_project_database_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func dataSourceCloudProjectDatabaseUser() *schema.Resource {
2222
Type: schema.TypeString,
2323
Description: "Name of the engine of the service",
2424
Required: true,
25-
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect"}),
25+
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect", "grafana"}),
2626
},
2727
"cluster_id": {
2828
Type: schema.TypeString,

ovh/data_cloud_project_database_user_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ func TestAccCloudProjectDatabaseUserDataSource_basic(t *testing.T) {
4545
flavor := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_FLAVOR_TEST")
4646
description := acctest.RandomWithPrefix(test_prefix)
4747
name := "johndoe"
48+
if engine == "grafana" {
49+
name = "avnadmin"
50+
}
4851

4952
config := fmt.Sprintf(
5053
testAccCloudProjectDatabaseUserDatasourceConfig_Basic,

ovh/data_cloud_project_database_users_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func TestAccCloudProjectDatabaseUsersDataSource_basic(t *testing.T) {
4343
region := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_REGION_TEST")
4444
flavor := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_FLAVOR_TEST")
4545
description := acctest.RandomWithPrefix(test_prefix)
46+
name := "johndoe"
47+
if engine == "grafana" {
48+
name = "avnadmin"
49+
}
4650

4751
config := fmt.Sprintf(
4852
testAccCloudProjectDatabaseUsersDatasourceConfig_Basic,
@@ -52,7 +56,7 @@ func TestAccCloudProjectDatabaseUsersDataSource_basic(t *testing.T) {
5256
version,
5357
region,
5458
flavor,
55-
"johndoe",
59+
name,
5660
)
5761

5862
resource.Test(t, resource.TestCase{

ovh/resource_cloud_project_database_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func resourceCloudProjectDatabaseUser() *schema.Resource {
4040
Description: "Name of the engine of the service",
4141
ForceNew: true,
4242
Required: true,
43-
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect"}),
43+
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect", "grafana"}),
4444
},
4545
"cluster_id": {
4646
Type: schema.TypeString,

ovh/resource_cloud_project_database_user_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func TestAccCloudProjectDatabaseUser_basic(t *testing.T) {
3838
flavor := os.Getenv("OVH_CLOUD_PROJECT_DATABASE_FLAVOR_TEST")
3939
description := acctest.RandomWithPrefix(test_prefix)
4040
name := "johndoe"
41+
if engine == "grafana" {
42+
name = "avnadmin"
43+
}
4144

4245
config := fmt.Sprintf(
4346
testAccCloudProjectDatabaseUserConfig,

ovh/types_cloud_project_database.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ func postCloudProjectDatabaseUser(d *schema.ResourceData, meta interface{}, engi
569569
}
570570
return updateFunc(d, meta)
571571
}
572+
if engine == "grafana" && name != "avnadmin" {
573+
return fmt.Errorf("The Grafana engine does not allow to create a user resource other than avnadmin")
574+
}
572575

573576
serviceName := d.Get("service_name").(string)
574577
clusterId := d.Get("cluster_id").(string)

website/docs/d/cloud_project_database_user.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Available engines:
3333
* `kafka`
3434
* `kafkaConnect`
3535
* `mysql`
36+
* `grafana`
3637

3738
* `cluster_id` - (Required) Cluster ID
3839

website/docs/r/cloud_project_database_user.html.markdown

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ subcategory : "Managed Databases"
66

77
Creates an user for a database cluster associated with a public cloud project.
88

9-
With this resource you can create a user for the following database engine:
9+
With this resource you can create a user and map "avnadmin" for the following database engine:
1010

1111
* `cassandra`
1212
* `kafka`
1313
* `kafkaConnect`
1414
* `mysql`
15+
* `grafana`
1516

1617
## Example Usage
1718

@@ -74,10 +75,12 @@ Available engines:
7475
* `kafka`
7576
* `kafkaConnect`
7677
* `mysql`
78+
* `grafana`
79+
7780

7881
* `cluster_id` - (Required, Forces new resource) Cluster ID.
7982

80-
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of create a new user.
83+
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of create a new user. The "Grafana" engine only allows the "avnadmin" mapping.
8184

8285
* `password_reset` - (Optional) Arbitrary string to change to trigger a password update. Use the `terraform refresh` command after executing `terraform apply` to update the output with the new password.
8386

0 commit comments

Comments
 (0)