feat: implement IdentitySchema for user resource to define unique identification fields
This commit is contained in:
parent
71dae54b8b
commit
e2f7370849
1 changed files with 26 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
|
||||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
|
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
|
||||||
postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
|
postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
|
||||||
postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/resources_gen"
|
postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/resources_gen"
|
||||||
|
|
@ -31,6 +32,7 @@ var (
|
||||||
_ resource.ResourceWithConfigure = &userResource{}
|
_ resource.ResourceWithConfigure = &userResource{}
|
||||||
_ resource.ResourceWithImportState = &userResource{}
|
_ resource.ResourceWithImportState = &userResource{}
|
||||||
_ resource.ResourceWithModifyPlan = &userResource{}
|
_ resource.ResourceWithModifyPlan = &userResource{}
|
||||||
|
_ resource.ResourceWithIdentity = &userResource{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// ResourceModel represents the Terraform resource state for a PostgreSQL Flex user.
|
// ResourceModel represents the Terraform resource state for a PostgreSQL Flex user.
|
||||||
|
|
@ -387,6 +389,30 @@ func (r *userResource) Delete(
|
||||||
tflog.Info(ctx, "Postgres Flex user deleted")
|
tflog.Info(ctx, "Postgres Flex user deleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IdentitySchema defines the fields that are required to uniquely identify a resource.
|
||||||
|
func (r *userResource) IdentitySchema(
|
||||||
|
_ context.Context,
|
||||||
|
_ resource.IdentitySchemaRequest,
|
||||||
|
response *resource.IdentitySchemaResponse,
|
||||||
|
) {
|
||||||
|
response.IdentitySchema = identityschema.Schema{
|
||||||
|
Attributes: map[string]identityschema.Attribute{
|
||||||
|
"project_id": identityschema.StringAttribute{
|
||||||
|
RequiredForImport: true,
|
||||||
|
},
|
||||||
|
"region": identityschema.StringAttribute{
|
||||||
|
RequiredForImport: true,
|
||||||
|
},
|
||||||
|
"instance_id": identityschema.StringAttribute{
|
||||||
|
RequiredForImport: true,
|
||||||
|
},
|
||||||
|
"user_id": identityschema.Int64Attribute{
|
||||||
|
RequiredForImport: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ImportState imports a resource into the Terraform state on success.
|
// ImportState imports a resource into the Terraform state on success.
|
||||||
// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
|
// The expected format of the resource import identifier is: project_id,zone_id,record_set_id
|
||||||
func (r *userResource) ImportState(
|
func (r *userResource) ImportState(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue