Implement PostgreSQL Flex database resource and data source (#453)

* Implement db resource

* Implement db data source

* Extend acc test

* Improve logs in other resources

* Add examples

* Generate docs

* Fix linter
This commit is contained in:
João Palet 2024-07-09 14:05:58 +01:00 committed by GitHub
parent 3fb28d1248
commit 34388eb361
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 923 additions and 29 deletions

View file

@ -84,13 +84,13 @@ func (r *userDataSource) Configure(ctx context.Context, req datasource.Configure
}
r.client = apiClient
tflog.Info(ctx, "PostgresFlex user client configured")
tflog.Info(ctx, "Postgres Flex user client configured")
}
// Schema defines the schema for the data source.
func (r *userDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
descriptions := map[string]string{
"main": "PostgresFlex user data source schema. Must have a `region` specified in the provider configuration.",
"main": "Postgres Flex user data source schema. Must have a `region` specified in the provider configuration.",
"id": "Terraform's internal data source. ID. It is structured as \"`project_id`,`instance_id`,`user_id`\".",
"user_id": "User ID.",
"instance_id": "ID of the PostgresFlex instance.",
@ -182,7 +182,7 @@ func (r *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
if resp.Diagnostics.HasError() {
return
}
tflog.Info(ctx, "PostgresFlex user read")
tflog.Info(ctx, "Postgres Flex user read")
}
func mapDataSourceFields(userResp *postgresflex.GetUserResponse, model *DataSourceModel) error {

View file

@ -96,7 +96,7 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ
}
r.client = apiClient
tflog.Info(ctx, "PostgresFlex user client configured")
tflog.Info(ctx, "Postgres Flex user client configured")
}
// Schema defines the schema for the resource.
@ -104,7 +104,7 @@ func (r *userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
rolesOptions := []string{"login", "createdb"}
descriptions := map[string]string{
"main": "PostgresFlex user resource schema. Must have a `region` specified in the provider configuration.",
"main": "Postgres Flex user resource schema. Must have a `region` specified in the provider configuration.",
"id": "Terraform's internal resource ID. It is structured as \"`project_id`,`instance_id`,`user_id`\".",
"user_id": "User ID.",
"instance_id": "ID of the PostgresFlex instance.",
@ -242,7 +242,7 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
if resp.Diagnostics.HasError() {
return
}
tflog.Info(ctx, "PostgresFlex user created")
tflog.Info(ctx, "Postgres Flex user created")
}
// Read refreshes the Terraform state with the latest data.
@ -284,7 +284,7 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
if resp.Diagnostics.HasError() {
return
}
tflog.Info(ctx, "PostgresFlex user read")
tflog.Info(ctx, "Postgres Flex user read")
}
// Update updates the resource and sets the updated Terraform state on success.
@ -320,7 +320,7 @@ func (r *userResource) Delete(ctx context.Context, req resource.DeleteRequest, r
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting user", fmt.Sprintf("Instance deletion waiting: %v", err))
return
}
tflog.Info(ctx, "PostgresFlex user deleted")
tflog.Info(ctx, "Postgres Flex user deleted")
}
// ImportState imports a resource into the Terraform state on success.