Skip to content

Commit 01fb2c8

Browse files
committed
Remove links to source code and make examples generic in migrating - attributes & blocks - force new (#418)
1 parent 515d414 commit 01fb2c8

File tree

1 file changed

+9
-16
lines changed
  • website/docs/plugin/framework/migrating/attributes-blocks

1 file changed

+9
-16
lines changed

website/docs/plugin/framework/migrating/attributes-blocks/force-new.mdx

+9-16
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,18 @@ the plan has already been modified.
6060
6161
## Example
6262
63-
The following examples show how to migrate portions of the
64-
[random](https://github.com/hashicorp/terraform-provider-random) provider.
65-
66-
For a complete example, clone the
67-
`terraform-random-provider` repository and compare the `resource_password.go` file in
68-
[v3.3.2](https://github.com/hashicorp/terraform-provider-random/blob/v3.3.2/internal/provider/resource_password.go)
69-
with the file [after the migration](https://github.com/hashicorp/terraform-provider-random/blob/04292d3e31f71ff16b82512082baed037bb1069c/internal/provider/resource_password.go).
70-
7163
### SDKv2
7264
73-
The following example from the `resource_password.go` file shows the implementation of the `ForceNew` field of the
74-
`random_password` resource's `keepers` attribute with SDKv2.
65+
The following example shows the implementation of the `ForceNew` field of the
66+
`exampleResource` resource's `example_attribute` attribute with SDKv2.
7567
7668
```go
77-
func resourcePassword() *schema.Resource {
69+
func exampleResource() *schema.Resource {
7870
return &schema.Resource{
7971
Schema: map[string]*schema.Schema{
80-
"keepers": {
72+
"example_attribute": {
8173
ForceNew: true,
74+
Type: schema.TypeMap,
8275
/* ... */
8376
},
8477
/* ... */
@@ -92,14 +85,14 @@ func resourcePassword() *schema.Resource {
9285
9386
The following shows the same section of provider code after the migration.
9487
95-
This code forces the replacement of a `random_password` resource when the value of the `keepers` attribute is changed.
96-
The example does this using the `PlanModifiers` field within the `random_password` attribute's schema.
88+
This code forces the replacement of a `exampleResource` resource when the value of the `example_attribute` attribute is changed.
89+
The example does this using the `PlanModifiers` field within the `exampleResource` attribute's schema.
9790
9891
```go
99-
func (r *passwordResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
92+
func (r *exampleResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
10093
resp.Schema = schema.Schema{
10194
Attributes: map[string]schema.Attribute{
102-
"keepers": schema.MapAttribute{
95+
"example_attribute": schema.MapAttribute{
10396
PlanModifiers: []planmodifier.Map{
10497
mapplanmodifier.RequiresReplace(),
10598
},

0 commit comments

Comments
 (0)