Skip to content

Commit

Permalink
refactor: replace planmodifiers with static defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Oct 19, 2023
1 parent 85e2da2 commit 2c8551e
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 159 deletions.
49 changes: 0 additions & 49 deletions internal/helpers/planmodifier_bool.go

This file was deleted.

49 changes: 0 additions & 49 deletions internal/helpers/planmodifier_int.go

This file was deleted.

50 changes: 0 additions & 50 deletions internal/helpers/planmodifier_string.go

This file was deleted.

1 change: 1 addition & 0 deletions internal/provider/interfaces/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/hashicorp/terraform-plugin-framework/resource"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
)
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/domain/process_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/domain/process_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/domain/process_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/domain/process_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/servicevcl/process_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/servicevcl/process_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
)

Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/servicevcl/process_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resources/servicevcl/process_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/interfaces"
Expand Down
16 changes: 5 additions & 11 deletions internal/provider/resources/servicevcl/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"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/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/interfaces"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/resources/domain"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/schemas"
Expand Down Expand Up @@ -77,9 +77,7 @@ func (r *Resource) Schema(_ context.Context, _ resource.SchemaRequest, resp *res
Computed: true,
MarkdownDescription: "The default Time-to-live (TTL) for requests",
Optional: true,
PlanModifiers: []planmodifier.Int64{
helpers.Int64DefaultModifier{Default: 3600},
},
Default: int64default.StaticInt64(3600),
}
attrs["default_host"] = schema.StringAttribute{
MarkdownDescription: "The default hostname",
Expand All @@ -89,17 +87,13 @@ func (r *Resource) Schema(_ context.Context, _ resource.SchemaRequest, resp *res
Computed: true,
MarkdownDescription: "Enables serving a stale object if there is an error",
Optional: true,
PlanModifiers: []planmodifier.Bool{
helpers.BoolDefaultModifier{Default: false},
},
Default: booldefault.StaticBool(false),
}
attrs["stale_if_error_ttl"] = schema.Int64Attribute{
Computed: true,
MarkdownDescription: "The default time-to-live (TTL) for serving the stale object for the version",
Optional: true,
PlanModifiers: []planmodifier.Int64{
helpers.Int64DefaultModifier{Default: 43200},
},
Default: int64default.StaticInt64(43200),
}

resp.Schema = schema.Schema{
Expand Down

0 comments on commit 2c8551e

Please sign in to comment.