Skip to content

Commit 68903e8

Browse files
committed
refactor: Shorten names of public plan modifier
1 parent ff24b02 commit 68903e8

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

internal/common/customplanmodifier/create_only_bool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/types"
1313
)
1414

15-
// CreateOnlyBoolPlanModifier creates a plan modifier that prevents updates to boolean attributes.
15+
// CreateOnlyBool creates a plan modifier that prevents updates to boolean attributes.
1616
// This is useful for attributes only supported in create and not in update.
1717
// It shows a helpful error message helping the user to update their config to match the state.
1818
// Never use a schema.Default for create only attributes, instead use `WithDefault`, the default will lead to plan changes that are not expected after import.
1919
// Implement CopyFromPlan if the attribute is not in the API Response.
20-
func CreateOnlyBoolPlanModifier() planmodifier.Bool {
20+
func CreateOnlyBool() planmodifier.Bool {
2121
return &createOnlyBoolPlanModifier{}
2222
}
2323

24-
// CreateOnlyBoolWithDefaultPlanModifier sets a default value on create operation that will show in the plan.
24+
// CreateOnlyBoolWithDefault sets a default value on create operation that will show in the plan.
2525
// This avoids any custom logic in the resource "Create" handler.
2626
// On update the default has no impact and the UseStateForUnknown behavior is observed instead.
2727
// Always use Optional+Computed when using a default value.
28-
func CreateOnlyBoolWithDefaultPlanModifier(b bool) planmodifier.Bool {
28+
func CreateOnlyBoolWithDefault(b bool) planmodifier.Bool {
2929
return &createOnlyBoolPlanModifier{defaultBool: &b}
3030
}
3131

internal/common/customplanmodifier/create_only_string.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
planmodifier "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1111
)
1212

13-
// CreateOnlyStringPlanModifier creates a plan modifier that prevents updates to string attributes.
13+
// CreateOnlyString creates a plan modifier that prevents updates to string attributes.
1414
// This is useful for attributes only supported in create and not in update.
1515
// It shows a helpful error message helping the user to update their config to match the state.
1616
// Never use a schema.Default for create only attributes, instead use `WithDefault`, the default will lead to plan changes that are not expected after import.
1717
// No default value implemented for string until we have a use case.
1818
// Implement CopyFromPlan if the attribute is not in the API Response.
19-
func CreateOnlyStringPlanModifier() planmodifier.String {
19+
func CreateOnlyString() planmodifier.String {
2020
return &createOnlyStringPlanModifier{}
2121
}
2222

internal/service/encryptionatrestprivateendpoint/resource_schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
4848
"delete_on_create_timeout": schema.BoolAttribute{
4949
Optional: true,
5050
PlanModifiers: []planmodifier.Bool{
51-
customplanmodifier.CreateOnlyBoolPlanModifier(),
51+
customplanmodifier.CreateOnlyBool(),
5252
},
5353
MarkdownDescription: "Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`.",
5454
},

internal/service/flexcluster/resource_schema.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ func ResourceSchema(ctx context.Context) schema.Schema {
2222
"project_id": schema.StringAttribute{
2323
Required: true,
2424
PlanModifiers: []planmodifier.String{
25-
customplanmodifier.CreateOnlyStringPlanModifier(),
25+
customplanmodifier.CreateOnlyString(),
2626
},
2727
MarkdownDescription: "Unique 24-hexadecimal character string that identifies the project.",
2828
},
2929
"name": schema.StringAttribute{
3030
Required: true,
3131
PlanModifiers: []planmodifier.String{
32-
customplanmodifier.CreateOnlyStringPlanModifier(),
32+
customplanmodifier.CreateOnlyString(),
3333
},
3434
MarkdownDescription: "Human-readable label that identifies the instance.",
3535
},
@@ -38,7 +38,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
3838
"backing_provider_name": schema.StringAttribute{
3939
Required: true,
4040
PlanModifiers: []planmodifier.String{
41-
customplanmodifier.CreateOnlyStringPlanModifier(),
41+
customplanmodifier.CreateOnlyString(),
4242
},
4343
MarkdownDescription: "Cloud service provider on which MongoDB Cloud provisioned the flex cluster.",
4444
},
@@ -59,7 +59,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
5959
"region_name": schema.StringAttribute{
6060
Required: true,
6161
PlanModifiers: []planmodifier.String{
62-
customplanmodifier.CreateOnlyStringPlanModifier(),
62+
customplanmodifier.CreateOnlyString(),
6363
},
6464
MarkdownDescription: "Human-readable label that identifies the geographic location of your MongoDB flex cluster. The region you choose can affect network latency for clients accessing your databases. For a complete list of region names, see [AWS](https://docs.atlas.mongodb.com/reference/amazon-aws/#std-label-amazon-aws), [GCP](https://docs.atlas.mongodb.com/reference/google-gcp/), and [Azure](https://docs.atlas.mongodb.com/reference/microsoft-azure/).",
6565
},
@@ -150,7 +150,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
150150
Optional: true,
151151
Computed: true,
152152
PlanModifiers: []planmodifier.Bool{
153-
customplanmodifier.CreateOnlyBoolWithDefaultPlanModifier(true),
153+
customplanmodifier.CreateOnlyBoolWithDefault(true),
154154
},
155155
MarkdownDescription: "Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`.",
156156
},

internal/service/project/resource_project_schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ func ResourceSchema(ctx context.Context) schema.Schema {
5353
"project_owner_id": schema.StringAttribute{
5454
Optional: true,
5555
PlanModifiers: []planmodifier.String{
56-
customplanmodifier.CreateOnlyStringPlanModifier(),
56+
customplanmodifier.CreateOnlyString(),
5757
},
5858
},
5959
"with_default_alerts_settings": schema.BoolAttribute{
6060
// Default values also must be Computed otherwise Terraform throws error:
6161
// Provider produced invalid plan: planned an invalid value for a non-computed attribute.
6262
Optional: true,
6363
Computed: true,
64-
PlanModifiers: []planmodifier.Bool{customplanmodifier.CreateOnlyBoolWithDefaultPlanModifier(true)},
64+
PlanModifiers: []planmodifier.Bool{customplanmodifier.CreateOnlyBoolWithDefault(true)},
6565
},
6666
"is_collect_database_specifics_statistics_enabled": schema.BoolAttribute{
6767
Computed: true,

internal/service/pushbasedlogexport/resource_schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
5959
"delete_on_create_timeout": schema.BoolAttribute{
6060
Optional: true,
6161
PlanModifiers: []planmodifier.Bool{
62-
customplanmodifier.CreateOnlyBoolPlanModifier(),
62+
customplanmodifier.CreateOnlyBool(),
6363
},
6464
MarkdownDescription: "Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`.",
6565
},

internal/service/streamprocessor/resource_schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func ResourceSchema(ctx context.Context) schema.Schema {
8181
"delete_on_create_timeout": schema.BoolAttribute{
8282
Optional: true,
8383
PlanModifiers: []planmodifier.Bool{
84-
customplanmodifier.CreateOnlyBoolPlanModifier(),
84+
customplanmodifier.CreateOnlyBool(),
8585
},
8686
MarkdownDescription: "Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`.",
8787
},

0 commit comments

Comments
 (0)