Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/tags: Used shared memory allocation for shared tag schemas #32250

Merged
merged 1 commit into from
Jun 28, 2023
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
2 changes: 1 addition & 1 deletion internal/service/ec2/ec2_spot_instance_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func ResourceSpotInstanceRequest() *schema.Resource {
if v.Computed && !v.Optional {
continue
}
if k == names.AttrTags {
if k == names.AttrTags || k == "volume_tags" {
continue
}
v.ForceNew = true
Expand Down
10 changes: 6 additions & 4 deletions internal/service/ec2/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ func tagsFromTagDescriptions(tds []*ec2.TagDescription) []*ec2.Tag {
}

func tagsSchemaConflictsWith(conflictsWith []string) *schema.Schema {
v := tftags.TagsSchema()
v.ConflictsWith = conflictsWith

return v
return &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
ConflictsWith: conflictsWith,
}
}
28 changes: 17 additions & 11 deletions internal/tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,35 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

// TagsSchema returns the schema to use for tags.
func TagsSchema() *schema.Schema {
return &schema.Schema{
var (
tagsSchema *schema.Schema = &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
}
}

func TagsSchemaComputed() *schema.Schema {
return &schema.Schema{
tagsSchemaComputed *schema.Schema = &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
}
}

func TagsSchemaForceNew() *schema.Schema {
return &schema.Schema{
tagsSchemaForceNew *schema.Schema = &schema.Schema{
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
}
)

// TagsSchema returns the schema to use for tags.
func TagsSchema() *schema.Schema {
return tagsSchema
}

func TagsSchemaComputed() *schema.Schema {
return tagsSchemaComputed
}

func TagsSchemaForceNew() *schema.Schema {
return tagsSchemaForceNew
}