Skip to content

Commit

Permalink
Merge pull request #31377 from hashicorp/td-remove-deprecated-generat…
Browse files Browse the repository at this point in the history
…ed-autoscaling-tagging-code

Tech debt: Remove deprecated generated `autoscaling` tagging code
  • Loading branch information
ewbankkit authored May 12, 2023
2 parents 672080a + 18a1e3a commit 2fc799f
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 102 deletions.
2 changes: 0 additions & 2 deletions internal/generate/tags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ type TemplateData struct {
InternalTypesPkg bool
NamesPkg bool
SkipTypesImp bool
StrConvPkg bool
TfResourcePkg bool
}

Expand Down Expand Up @@ -249,7 +248,6 @@ func main() {
InternalTypesPkg: *listTags || *serviceTagsMap || *serviceTagsSlice,
NamesPkg: *updateTags && !*skipNamesImp,
SkipTypesImp: *skipTypesImp,
StrConvPkg: awsPkg == "autoscaling",
TfResourcePkg: *getTag,

CreateTagsFunc: createTagsFunc,
Expand Down
3 changes: 0 additions & 3 deletions internal/generate/tags/templates/v1/header_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import (
{{- if .FmtPkg }}
"fmt"
{{- end }}
{{- if .StrConvPkg }}
"strconv"
{{- end }}

"github.com/aws/aws-sdk-go/aws"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
Expand Down
33 changes: 0 additions & 33 deletions internal/generate/tags/templates/v1/service_tags_slice_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,6 @@ func ListOfMap(tags tftags.KeyValueTags) []any {
}
{{- end }}

{{ if eq .ServicePackage "autoscaling" }}
// ListOfStringMap returns a list of {{ .ServicePackage }} tags in flattened map of only string values.
//
// Compatible with setting Terraform state for legacy []map[string]string schema.
// Deprecated: Will be removed in a future major version without replacement.
func ListOfStringMap(tags tftags.KeyValueTags) []any {
var result []any

for _, key := range tags.Keys() {
m := map[string]string{
"key": key,
"value": aws.StringValue(tags.KeyValue(key)),
{{ if .TagTypeAddBoolElem }}
"{{ .TagTypeAddBoolElemSnake }}": strconv.FormatBool(aws.BoolValue(tags.KeyAdditionalBoolValue(key, "{{ .TagTypeAddBoolElem }}"))),
{{ end }}
}

result = append(result, m)
}

return result
}
{{- end }}

{{- if .TagKeyType }}
// TagKeys returns {{ .ServicePackage }} service tag keys.
func TagKeys(tags tftags.KeyValueTags) []*{{ .TagPackage }}.{{ .TagKeyType }} {
Expand Down Expand Up @@ -218,15 +194,6 @@ func KeyValueTags(ctx context.Context, tags any{{ if .TagTypeIDElem }}, identifi
tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = &v
}
{{- end }}
{{ if eq .ServicePackage "autoscaling" }}
// Deprecated: Legacy map handling
{{- if .TagTypeAddBoolElem }}
if v, ok := tfMap["{{ .TagTypeAddBoolElemSnake }}"].(string); ok {
b, _ := strconv.ParseBool(v)
tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = &b
}
{{- end }}
{{- end }}
{{- end }}

{{ if .TagTypeIDElem }}
Expand Down
3 changes: 0 additions & 3 deletions internal/generate/tags/templates/v2/header_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import (
{{- if .FmtPkg }}
"fmt"
{{- end }}
{{- if .StrConvPkg }}
"strconv"
{{- end }}

"github.com/aws/aws-sdk-go-v2/aws"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
Expand Down
33 changes: 0 additions & 33 deletions internal/generate/tags/templates/v2/service_tags_slice_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,6 @@ func ListOfMap(tags tftags.KeyValueTags) []any {
}
{{- end }}

{{ if eq .ServicePackage "autoscaling" }}
// ListOfStringMap returns a list of {{ .ServicePackage }} tags in flattened map of only string values.
//
// Compatible with setting Terraform state for legacy []map[string]string schema.
// Deprecated: Will be removed in a future major version without replacement.
func ListOfStringMap(tags tftags.KeyValueTags) []any {
var result []any

for _, key := range tags.Keys() {
m := map[string]string{
"key": key,
"value": aws.ToString(tags.KeyValue(key)),
{{ if .TagTypeAddBoolElem }}
"{{ .TagTypeAddBoolElemSnake }}": strconv.FormatBool(aws.ToBool(tags.KeyAdditionalBoolValue(key, "{{ .TagTypeAddBoolElem }}"))),
{{ end }}
}

result = append(result, m)
}

return result
}
{{- end }}

{{- if .TagKeyType }}
// TagKeys returns {{ .ServicePackage }} service tag keys.
func TagKeys(tags tftags.KeyValueTags) []*{{ .AWSService }}.{{ .TagKeyType }} {
Expand Down Expand Up @@ -218,15 +194,6 @@ func KeyValueTags(ctx context.Context, tags any{{ if .TagTypeIDElem }}, identifi
tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = &v
}
{{- end }}
{{ if eq .ServicePackage "autoscaling" }}
// Deprecated: Legacy map handling
{{- if .TagTypeAddBoolElem }}
if v, ok := tfMap["{{ .TagTypeAddBoolElemSnake }}"].(string); ok {
b, _ := strconv.ParseBool(v)
tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = &b
}
{{- end }}
{{- end }}
{{- end }}

{{ if .TagTypeIDElem }}
Expand Down
28 changes: 0 additions & 28 deletions internal/service/autoscaling/tags_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2fc799f

Please sign in to comment.