Skip to content

Commit ddc0f64

Browse files
authored
Merge pull request #43898 from hashicorp/td-tags-resolve-duplicates-framework
Decouples `tags.ResolveDuplicatesFramework` from `resource.ReadResponse`
2 parents 8aa7301 + 3410701 commit ddc0f64

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

internal/provider/framework/tags_interceptor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (r tagsResourceInterceptor) read(ctx context.Context, opts interceptorOptio
155155
response.State.GetAttribute(ctx, path.Root(names.AttrTags), &stateTags)
156156
// Remove any provider configured ignore_tags and system tags from those returned from the service API.
157157
// The resource's configured tags do not include any provider configured default_tags.
158-
if v := apiTags.IgnoreSystem(sp.ServicePackageName()).IgnoreConfig(c.IgnoreTagsConfig(ctx)).ResolveDuplicatesFramework(ctx, c.DefaultTagsConfig(ctx), c.IgnoreTagsConfig(ctx), response, &opts.response.Diagnostics).Map(); len(v) > 0 {
158+
if v := apiTags.IgnoreSystem(sp.ServicePackageName()).IgnoreConfig(c.IgnoreTagsConfig(ctx)).ResolveDuplicatesFramework(ctx, c.DefaultTagsConfig(ctx), c.IgnoreTagsConfig(ctx), stateTags, &opts.response.Diagnostics).Map(); len(v) > 0 {
159159
stateTags = tftags.NewMapFromMapValue(fwflex.FlattenFrameworkStringValueMapLegacy(ctx, v))
160160
}
161161
opts.response.Diagnostics.Append(response.State.SetAttribute(ctx, path.Root(names.AttrTags), &stateTags)...)

internal/tags/key_value_tags.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515

1616
"github.com/hashicorp/go-cty/cty"
1717
fwdiag "github.com/hashicorp/terraform-plugin-framework/diag"
18-
"github.com/hashicorp/terraform-plugin-framework/path"
19-
"github.com/hashicorp/terraform-plugin-framework/resource"
2018
"github.com/hashicorp/terraform-plugin-framework/types"
2119
"github.com/hashicorp/terraform-provider-aws/internal/create"
2220
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
@@ -887,13 +885,10 @@ func (tags KeyValueTags) ResolveDuplicates(ctx context.Context, defaultConfig *D
887885
}
888886

889887
// ResolveDuplicatesFramework resolves differences between incoming tags, defaultTags, and ignoreConfig
890-
func (tags KeyValueTags) ResolveDuplicatesFramework(ctx context.Context, defaultConfig *DefaultConfig, ignoreConfig *IgnoreConfig, resp *resource.ReadResponse, diags *fwdiag.Diagnostics) KeyValueTags {
888+
func (tags KeyValueTags) ResolveDuplicatesFramework(ctx context.Context, defaultConfig *DefaultConfig, ignoreConfig *IgnoreConfig, tagsAll Map, diags *fwdiag.Diagnostics) KeyValueTags {
891889
// remove default config.
892890
t := tags.RemoveDefaultConfig(defaultConfig)
893891

894-
var tagsAll Map
895-
diags.Append(resp.State.GetAttribute(ctx, path.Root("tags"), &tagsAll)...)
896-
897892
if diags.HasError() {
898893
return KeyValueTags{}
899894
}

0 commit comments

Comments
 (0)