Skip to content

Commit 515d414

Browse files
committed
Remove links to source code and make examples generic in migrating - attributes & blocks - default values (#418)
1 parent 4e37b59 commit 515d414

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

website/docs/plugin/framework/migrating/attributes-blocks/default-values.mdx

+9-17
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,16 @@ In the Framework, you must implement an attribute plan modifier to set default v
6161
6262
## Example
6363
64-
The following examples show how to migrate portions of the [tls](https://github.com/hashicorp/terraform-provider-tls)
65-
provider.
66-
67-
For a complete example, clone the
68-
`terraform-provider-tls` repository and compare the `resource_private_key.go` file in
69-
[v3.4.0](https://github.com/hashicorp/terraform-provider-tls/blob/v3.4.0/internal/provider/resource_private_key.go) with the file
70-
[after the migration](https://github.com/hashicorp/terraform-provider-tls/blob/4dafb105818e45a88532f917e7b170ee2a9bb092/internal/provider/resource_private_key.go).
71-
7264
### SDKv2
7365
74-
The following example from the `resource_private_key.go` file shows the implementation of the `Default` field for the
75-
`rsa_bits` attribute on the `tls_private_key` resource with SDKv2.
66+
The following example shows the implementation of the `Default` field for the
67+
`example_attribute` attribute on the `exampleResource` resource with SDKv2.
7668
7769
```go
78-
func resourcePrivateKey() *schema.Resource {
70+
func exampleResource() *schema.Resource {
7971
return &schema.Resource{
8072
Schema: map[string]*schema.Schema{
81-
"rsa_bits": {
73+
"example_attribute": {
8274
Default: 2048,
8375
/* ... */
8476
},
@@ -89,13 +81,13 @@ func resourcePrivateKey() *schema.Resource {
8981
9082
The following shows the same section of code after the migration.
9183
92-
This code implements the `PlanModifiers` field for the `rsa_bits` attribute with the Framework.
84+
This code implements the `PlanModifiers` field for the `example_attribute` attribute with the Framework.
9385
9486
```go
95-
func (r *privateKeyResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
87+
func (r *exampleResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
9688
resp.Schema = schema.Schema{
9789
Attributes: map[string]schema.Attribute{
98-
"rsa_bits": schema.Int64Attribute{
90+
"example_attribute": schema.Int64Attribute{
9991
PlanModifiers: []planmodifier.Int64{
10092
attribute_plan_modifier.Int64DefaultValue(types.Int64Value(2048)),
10193
/* ... */
@@ -108,8 +100,8 @@ func (r *privateKeyResource) Schema(ctx context.Context, req resource.SchemaRequ
108100
}
109101
```
110102
111-
The following example from the `attribute_plan_modifiers.go` file implements the `DefaultValue` attribute plan modifier
112-
that the `rsa_bits` attribute uses.
103+
The following example implements the `Int64DefaultValue` attribute plan modifier
104+
that the `example_attribute` attribute uses.
113105
114106
```go
115107
func Int64DefaultValue(v types.Int64) planmodifier.Int64 {

0 commit comments

Comments
 (0)