From b92292535789716cdf79f5791391be9989dfb52b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Oct 2022 14:25:13 +0000 Subject: [PATCH 1/2] Bump github.com/hashicorp/terraform-plugin-framework Bumps [github.com/hashicorp/terraform-plugin-framework](https://github.com/hashicorp/terraform-plugin-framework) from 0.14.0 to 0.15.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-framework/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-framework/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-framework/compare/v0.14.0...v0.15.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-framework dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 58aff42..b3938b6 100644 --- a/go.mod +++ b/go.mod @@ -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 ( diff --git a/go.sum b/go.sum index c1432ae..dcb73c7 100644 --- a/go.sum +++ b/go.sum @@ -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= From 4be668fc3a13083551d763c6b135cdaa8cf82262 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Wed, 26 Oct 2022 12:09:50 -0400 Subject: [PATCH 2/2] all: Handle terraform-plugin-framework@v0.15.0 deprecations --- .changelog/11.txt | 3 ++ internal/validators/timeduration.go | 6 ++-- timeouts/parser.go | 56 ++++++++++++++++------------- 3 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 .changelog/11.txt diff --git a/.changelog/11.txt b/.changelog/11.txt new file mode 100644 index 0000000..48836f4 --- /dev/null +++ b/.changelog/11.txt @@ -0,0 +1,3 @@ +```release-note:note +all: This Go module has been updated for deprecations in terraform-plugin-framework version 0.15.0 +``` diff --git a/internal/validators/timeduration.go b/internal/validators/timeduration.go index 7847638..9de04bc 100644 --- a/internal/validators/timeduration.go +++ b/internal/validators/timeduration.go @@ -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 } diff --git a/timeouts/parser.go b/timeouts/parser.go index 7eeab79..0068356 100644 --- a/timeouts/parser.go +++ b/timeouts/parser.go @@ -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 } @@ -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 } @@ -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 } @@ -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 }