|
@@ -5,10 +5,11 @@ import (
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
|
|
|
- "github.com/hashicorp/terraform-plugin-framework/diag"
|
|
|
"github.com/hashicorp/terraform-plugin-framework/path"
|
|
|
"github.com/hashicorp/terraform-plugin-framework/resource"
|
|
|
- "github.com/hashicorp/terraform-plugin-framework/tfsdk"
|
|
|
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema"
|
|
|
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
|
|
|
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
|
|
|
"github.com/hashicorp/terraform-plugin-framework/types"
|
|
|
"github.com/hashicorp/terraform-plugin-log/tflog"
|
|
|
)
|
|
@@ -36,27 +37,25 @@ func (r *ExampleResource) Metadata(ctx context.Context, req resource.MetadataReq
|
|
|
resp.TypeName = req.ProviderTypeName + "_example"
|
|
|
}
|
|
|
|
|
|
-func (r *ExampleResource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
|
|
|
- return tfsdk.Schema{
|
|
|
+func (r *ExampleResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
|
|
|
+ resp.Schema = schema.Schema{
|
|
|
// This description is used by the documentation generator and the language server.
|
|
|
MarkdownDescription: "Example resource",
|
|
|
|
|
|
- Attributes: map[string]tfsdk.Attribute{
|
|
|
- "configurable_attribute": {
|
|
|
+ Attributes: map[string]schema.Attribute{
|
|
|
+ "configurable_attribute": schema.StringAttribute{
|
|
|
MarkdownDescription: "Example configurable attribute",
|
|
|
Optional: true,
|
|
|
- Type: types.StringType,
|
|
|
},
|
|
|
- "id": {
|
|
|
+ "id": schema.StringAttribute{
|
|
|
Computed: true,
|
|
|
MarkdownDescription: "Example identifier",
|
|
|
- PlanModifiers: tfsdk.AttributePlanModifiers{
|
|
|
- resource.UseStateForUnknown(),
|
|
|
+ PlanModifiers: []planmodifier.String{
|
|
|
+ stringplanmodifier.UseStateForUnknown(),
|
|
|
},
|
|
|
- Type: types.StringType,
|
|
|
},
|
|
|
},
|
|
|
- }, nil
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func (r *ExampleResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|