Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/11.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:note
all: This Go module has been updated for deprecations in terraform-plugin-framework version 0.15.0
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/google/go-cmp v0.5.9
github.com/hashicorp/terraform-plugin-framework v0.14.0
github.com/hashicorp/terraform-plugin-framework v0.15.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw=
github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/terraform-plugin-framework v0.14.0 h1:Mwj55u+Jc/QGM6fLBPCe1P+ZF3cuYs6wbCdB15lx/Dg=
github.com/hashicorp/terraform-plugin-framework v0.14.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8=
github.com/hashicorp/terraform-plugin-framework v0.15.0 h1:6f4UY2yfp5UsSX9JhUA6RSptjd+ojStBGWA4jrPhB6Q=
github.com/hashicorp/terraform-plugin-framework v0.15.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8=
github.com/hashicorp/terraform-plugin-go v0.14.0 h1:ttnSlS8bz3ZPYbMb84DpcPhY4F5DsQtcAS7cHo8uvP4=
github.com/hashicorp/terraform-plugin-go v0.14.0/go.mod h1:2nNCBeRLaenyQEi78xrGrs9hMbulveqG/zDMQSvVJTE=
github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs=
Expand Down
6 changes: 3 additions & 3 deletions internal/validators/timeduration.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func (validator timeDurationValidator) MarkdownDescription(ctx context.Context)
func (validator timeDurationValidator) Validate(ctx context.Context, request tfsdk.ValidateAttributeRequest, response *tfsdk.ValidateAttributeResponse) {
s := request.AttributeConfig.(types.String)

if s.Unknown || s.Null {
if s.IsUnknown() || s.IsNull() {
return
}

if _, err := time.ParseDuration(s.Value); err != nil {
if _, err := time.ParseDuration(s.ValueString()); err != nil {
response.Diagnostics.Append(diag.NewAttributeErrorDiagnostic(
request.AttributePath,
"Invalid Attribute Value Time Duration",
fmt.Sprintf("%q %s", s.Value, validator.Description(ctx))),
fmt.Sprintf("%q %s", s.ValueString(), validator.Description(ctx))),
)
return
}
Expand Down
56 changes: 32 additions & 24 deletions timeouts/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@ import (
// entry for "create" that can be parsed then time.Duration is returned. If object.Attrs
// does not contain "create" the supplied default will be returned.
func Create(ctx context.Context, obj types.Object, def time.Duration) time.Duration {
if _, ok := obj.Attrs[attributeNameCreate]; !ok {
createTimeoutValue, ok := obj.Attributes()[attributeNameCreate]

if !ok {
return def
}

createTimeout := obj.Attrs[attributeNameCreate]

if createTimeout.IsNull() {
if createTimeoutValue.IsNull() {
return def
}

// Although the schema mutation functions guarantee that the type for create timeout
// is a string, this function accepts any types.Object.
if _, ok := createTimeout.(types.String); !ok {
createTimeoutString, ok := createTimeoutValue.(types.String)

if !ok {
return def
}

// Although the schema validation guarantees that the type for create timeout
// is parseable as a time.Duration, this function accepts any types.Object.
duration, err := time.ParseDuration(createTimeout.(types.String).Value)
duration, err := time.ParseDuration(createTimeoutString.ValueString())
if err != nil {
return def
}
Expand All @@ -41,25 +43,27 @@ func Create(ctx context.Context, obj types.Object, def time.Duration) time.Durat
// entry for "read" that can be parsed then time.Duration is returned. If object.Attrs
// does not contain "read" the supplied default will be returned.
func Read(ctx context.Context, obj types.Object, def time.Duration) time.Duration {
if _, ok := obj.Attrs[attributeNameRead]; !ok {
readTimeoutValue, ok := obj.Attributes()[attributeNameRead]

if !ok {
return def
}

readTimeout := obj.Attrs[attributeNameRead]

if readTimeout.IsNull() {
if readTimeoutValue.IsNull() {
return def
}

// Although the schema mutation functions guarantee that the type for read timeout
// is a string, this function accepts any types.Object.
if _, ok := readTimeout.(types.String); !ok {
readTimeoutString, ok := readTimeoutValue.(types.String)

if !ok {
return def
}

// Although the schema validation guarantees that the type for read timeout
// is parseable as a time.Duration, this function accepts any types.Object.
duration, err := time.ParseDuration(readTimeout.(types.String).Value)
duration, err := time.ParseDuration(readTimeoutString.ValueString())
if err != nil {
return def
}
Expand All @@ -71,25 +75,27 @@ func Read(ctx context.Context, obj types.Object, def time.Duration) time.Duratio
// entry for "update" that can be parsed then time.Duration is returned. If object.Attrs
// does not contain "update" the supplied default will be returned.
func Update(ctx context.Context, obj types.Object, def time.Duration) time.Duration {
if _, ok := obj.Attrs[attributeNameUpdate]; !ok {
updateTimeoutValue, ok := obj.Attributes()[attributeNameUpdate]

if !ok {
return def
}

updateTimeout := obj.Attrs[attributeNameUpdate]

if updateTimeout.IsNull() {
if updateTimeoutValue.IsNull() {
return def
}

// Although the schema mutation functions guarantee that the type for update timeout
// is a string, this function accepts any types.Object.
if _, ok := updateTimeout.(types.String); !ok {
updateTimeoutString, ok := updateTimeoutValue.(types.String)

if !ok {
return def
}

// Although the schema validation guarantees that the type for update timeout
// is parseable as a time.Duration, this function accepts any types.Object.
duration, err := time.ParseDuration(updateTimeout.(types.String).Value)
duration, err := time.ParseDuration(updateTimeoutString.ValueString())
if err != nil {
return def
}
Expand All @@ -101,25 +107,27 @@ func Update(ctx context.Context, obj types.Object, def time.Duration) time.Durat
// entry for "delete" that can be parsed then time.Duration is returned. If object.Attrs
// does not contain "delete" the supplied default will be returned.
func Delete(ctx context.Context, obj types.Object, def time.Duration) time.Duration {
if _, ok := obj.Attrs[attributeNameDelete]; !ok {
deleteTimeoutValue, ok := obj.Attributes()[attributeNameDelete]

if !ok {
return def
}

deleteTimeout := obj.Attrs[attributeNameDelete]

if deleteTimeout.IsNull() {
if deleteTimeoutValue.IsNull() {
return def
}

// Although the schema mutation functions guarantee that the type for delete timeout
// is a string, this function accepts any types.Object.
if _, ok := deleteTimeout.(types.String); !ok {
deleteTimeoutString, ok := deleteTimeoutValue.(types.String)

if !ok {
return def
}

// Although the schema validation guarantees that the type for delete timeout
// is parseable as a time.Duration, this function accepts any types.Object.
duration, err := time.ParseDuration(deleteTimeout.(types.String).Value)
duration, err := time.ParseDuration(deleteTimeoutString.ValueString())
if err != nil {
return def
}
Expand Down