From f68270c10326f2aae44cfd99b225b79cbee44865 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 09:55:01 -0400 Subject: [PATCH 01/24] internal/generate/tags: Remove AWS SDK for Go v1 support. --- internal/generate/tags/main.go | 45 +-- .../tags/templates/v1/get_tag_body.gtpl | 68 ----- .../tags/templates/v1/header_body.gtpl | 56 ---- .../tags/templates/v1/list_tags_body.gtpl | 149 ---------- .../templates/v1/service_tags_map_body.gtpl | 41 --- .../templates/v1/service_tags_slice_body.gtpl | 264 ------------------ .../tags/templates/v1/update_tags_body.gtpl | 224 --------------- internal/generate/tags/templates/v1/v1.go | 29 -- .../v1/wait_tags_propagated_body.gtpl | 43 --- 9 files changed, 10 insertions(+), 909 deletions(-) delete mode 100644 internal/generate/tags/templates/v1/get_tag_body.gtpl delete mode 100644 internal/generate/tags/templates/v1/header_body.gtpl delete mode 100644 internal/generate/tags/templates/v1/list_tags_body.gtpl delete mode 100644 internal/generate/tags/templates/v1/service_tags_map_body.gtpl delete mode 100644 internal/generate/tags/templates/v1/service_tags_slice_body.gtpl delete mode 100644 internal/generate/tags/templates/v1/update_tags_body.gtpl delete mode 100644 internal/generate/tags/templates/v1/v1.go delete mode 100644 internal/generate/tags/templates/v1/wait_tags_propagated_body.gtpl diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index 6f1feaf4a84..76923003ab0 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -15,13 +15,11 @@ import ( "github.com/YakDriver/regexache" "github.com/hashicorp/terraform-provider-aws/internal/generate/common" - v1 "github.com/hashicorp/terraform-provider-aws/internal/generate/tags/templates/v1" v2 "github.com/hashicorp/terraform-provider-aws/internal/generate/tags/templates/v2" "github.com/hashicorp/terraform-provider-aws/names/data" ) const ( - sdkV1 = 1 sdkV2 = 2 ) @@ -121,16 +119,6 @@ type TemplateBody struct { func newTemplateBody(version int, kvtValues bool) *TemplateBody { switch version { - case sdkV1: - return &TemplateBody{ - getTag: "\n" + v1.GetTagBody, - header: v1.HeaderBody, - listTags: "\n" + v1.ListTagsBody, - serviceTagsMap: "\n" + v1.ServiceTagsMapBody, - serviceTagsSlice: "\n" + v1.ServiceTagsSliceBody, - updateTags: "\n" + v1.UpdateTagsBody, - waitTagsPropagated: "\n" + v1.WaitTagsPropagatedBody, - } case sdkV2: if kvtValues { return &TemplateBody{ @@ -158,11 +146,10 @@ func newTemplateBody(version int, kvtValues bool) *TemplateBody { } type TemplateData struct { - AWSService string - AWSServiceIfacePackage string - ClientType string - ProviderNameUpper string - ServicePackage string + AWSService string + ClientType string + ProviderNameUpper string + ServicePackage string CreateTagsFunc string EmptyMap bool @@ -251,7 +238,7 @@ func main() { g := common.NewGenerator() - if *sdkVersion != sdkV1 && *sdkVersion != sdkV2 { + if *sdkVersion != sdkV2 { g.Fatalf("AWS SDK Go Version %d not supported", *sdkVersion) } @@ -269,11 +256,6 @@ func main() { awsPkg := service.GoPackageName() - var awsIntfPkg string - if *sdkVersion == sdkV1 && (*getTag || *listTags || *updateTags) { - awsIntfPkg = fmt.Sprintf("%[1]s/%[1]siface", awsPkg) - } - createTagsFunc := *createTagsFunc if *createTags && !*updateTags { g.Infof("CreateTags only valid with UpdateTags") @@ -283,13 +265,7 @@ func main() { } clientTypeName := service.ClientTypeName(*sdkVersion) - var clientType string - if *sdkVersion == sdkV1 { - clientType = fmt.Sprintf("%siface.%sAPI", awsPkg, clientTypeName) - } else { - clientType = fmt.Sprintf("*%s.%s", awsPkg, clientTypeName) - } - + clientType := fmt.Sprintf("*%s.%s", awsPkg, clientTypeName) tagPackage := awsPkg var cleanRetryErrorCodes []string @@ -304,11 +280,10 @@ func main() { providerNameUpper := service.ProviderNameUpper() templateData := TemplateData{ - AWSService: awsPkg, - AWSServiceIfacePackage: awsIntfPkg, - ClientType: clientType, - ProviderNameUpper: providerNameUpper, - ServicePackage: servicePackage, + AWSService: awsPkg, + ClientType: clientType, + ProviderNameUpper: providerNameUpper, + ServicePackage: servicePackage, ConnsPkg: (*listTags && *listTagsFunc == defaultListTagsFunc) || (*updateTags && *updateTagsFunc == defaultUpdateTagsFunc), FmtPkg: *updateTags, diff --git a/internal/generate/tags/templates/v1/get_tag_body.gtpl b/internal/generate/tags/templates/v1/get_tag_body.gtpl deleted file mode 100644 index 0c8c66a60f8..00000000000 --- a/internal/generate/tags/templates/v1/get_tag_body.gtpl +++ /dev/null @@ -1,68 +0,0 @@ -// {{ .GetTagFunc }} fetches an individual {{ .ServicePackage }} service tag for a resource. -// Returns whether the key value and any errors. A NotFoundError is used to signal that no value was found. -// This function will optimise the handling over {{ .ListTagsFunc }}, if possible. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func {{ .GetTagFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}, key string) -{{- if or ( .TagTypeIDElem ) ( .TagTypeAddBoolElem ) -}} -(*tftags.TagData, error) { -{{- else -}} -(*string, error) { -{{- end }} - {{- if .ListTagsInFiltIDName }} - input := &{{ .TagPackage }}.{{ .ListTagsOp }}Input{ - Filters: []*{{ .TagPackage }}.Filter{ - { - Name: aws.String("{{ .ListTagsInFiltIDName }}"), - Values: []*string{aws.String(identifier)}, - }, - { - Name: aws.String(names.AttrKey), - Values: []*string{aws.String(key)}, - }, - }, - } - - {{ if .RetryTagsListTagsType }} - output, err := tfresource.RetryGWhenMessageContains(ctx, {{ .RetryTagsTimeout }}, - func() (*{{ .TagPackage }}.{{ .RetryTagsListTagsType }}, error) { - return conn.{{ .ListTagsOp }}WithContext(ctx, input) - }, - []string{ - {{- range .RetryTagsErrorCodes }} - {{ . }}, - {{- end }} - }, - []string{ - {{- range .RetryTagsErrorMessages }} - "{{ . }}", - {{- end }} - }, - ) - {{ else }} - output, err := conn.{{ .ListTagsOp }}WithContext(ctx, input) - {{- end }} - - if err != nil { - return nil, err - } - - listTags := {{ .KeyValueTagsFunc }}(ctx, output.{{ .ListTagsOutTagsElem }}{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}{{ end }}) - {{- else }} - listTags, err := {{ .ListTagsFunc }}(ctx, conn, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}) - - if err != nil { - return nil, err - } - {{- end }} - - if !listTags.KeyExists(key) { - return nil, tfresource.NewEmptyResultError(nil) - } - - {{ if or ( .TagTypeIDElem ) ( .TagTypeAddBoolElem) }} - return listTags.KeyTagData(key), nil - {{- else }} - return listTags.KeyValue(key), nil - {{- end }} -} diff --git a/internal/generate/tags/templates/v1/header_body.gtpl b/internal/generate/tags/templates/v1/header_body.gtpl deleted file mode 100644 index c100fcfa5dc..00000000000 --- a/internal/generate/tags/templates/v1/header_body.gtpl +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by internal/generate/tags/main.go; DO NOT EDIT. -package {{ .ServicePackage }} - -import ( - "context" - {{- if .FmtPkg }} - "fmt" - {{- end }} - {{- if and .ListTagsOpPaginated .ServiceTagsMap }} - "maps" - {{- end }} - {{- if .TimePkg }} - "time" - {{- end }} - - {{ if not .SkipAWSImp }} - "github.com/aws/aws-sdk-go/aws" - {{- end }} - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - {{- if .AWSService }} - {{- if not .SkipServiceImp }} - "github.com/aws/aws-sdk-go/service/{{ .AWSService }}" - {{- end }} - {{- end }} - {{- if .AWSServiceIfacePackage }} - "github.com/aws/aws-sdk-go/service/{{ .AWSServiceIfacePackage }}" - {{- end }} - {{- if ne .AWSService .TagPackage }} - "github.com/aws/aws-sdk-go/service/{{ .TagPackage }}" - {{- end }} - {{- if .HelperSchemaPkg }} - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - {{- end }} - {{- if .ParentNotFoundErrCode }} - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - {{- end }} - {{- if .TfLogPkg }} - "github.com/hashicorp/terraform-plugin-log/tflog" - {{- end }} - {{- if .ConnsPkg }} - "github.com/hashicorp/terraform-provider-aws/internal/conns" - {{- end }} - {{- if .LoggingPkg }} - "github.com/hashicorp/terraform-provider-aws/internal/logging" - {{- end }} - {{- if .TfResourcePkg }} - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - {{- end }} - {{- if .InternalOptionPkg }} - "github.com/hashicorp/terraform-provider-aws/internal/types/option" - {{- end }} - {{- if .NamesPkg }} - "github.com/hashicorp/terraform-provider-aws/names" - {{- end }} -) diff --git a/internal/generate/tags/templates/v1/list_tags_body.gtpl b/internal/generate/tags/templates/v1/list_tags_body.gtpl deleted file mode 100644 index 292b1095446..00000000000 --- a/internal/generate/tags/templates/v1/list_tags_body.gtpl +++ /dev/null @@ -1,149 +0,0 @@ -// {{ .ListTagsFunc }} lists {{ .ServicePackage }} service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func {{ .ListTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string) (tftags.KeyValueTags, error) { - input := &{{ .TagPackage }}.{{ .ListTagsOp }}Input{ - {{- if .ListTagsInFiltIDName }} - Filters: []*{{ .TagPackage }}.Filter{ - { - Name: aws.String("{{ .ListTagsInFiltIDName }}"), - Values: []*string{aws.String(identifier)}, - }, - }, - {{- else }} - {{- if .ListTagsInIDNeedSlice }} - {{ .ListTagsInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else }} - {{ .ListTagsInIDElem }}: aws.String(identifier), - {{- end }} - {{- if .TagResTypeElem }} - {{ .TagResTypeElem }}: aws.String(resourceType), - {{- end }} - {{- end }} - } -{{- if .ListTagsOpPaginated }} - {{- if .ServiceTagsMap }} - output := make(map[string]*string) - {{- else }} - var output []*{{ .TagPackage }}.{{ or .TagType2 .TagType }} - {{- end }} - - {{ if .RetryTagsListTagsType }} - _, err := tfresource.RetryWhenMessageContains(ctx, {{ .RetryTagsTimeout }}, - func() (string, error) { - return "", conn.{{ .ListTagsOp }}PagesWithContext(ctx, input, func(page *{{ .TagPackage }}.{{ .ListTagsOp }}Output, lastPage bool) bool { - if page == nil { - return !lastPage - } - - {{ if .ServiceTagsMap }} - maps.Copy(output, page.{{ .ListTagsOutTagsElem }}) - {{- else }} - for _, v := range page.{{ .ListTagsOutTagsElem }} { - if v != nil { - output = append(output, v) - } - } - {{- end }} - - return !lastPage - }) - }, - []string{ - {{- range .RetryTagsErrorCodes }} - {{ . }}, - {{- end }} - }, - []string{ - {{- range .RetryTagsErrorMessages }} - "{{ . }}", - {{- end }} - }, - ) - {{ else }} - err := conn.{{ .ListTagsOp }}PagesWithContext(ctx, input, func(page *{{ .TagPackage }}.{{ .ListTagsOp }}Output, lastPage bool) bool { - if page == nil { - return !lastPage - } - - {{ if .ServiceTagsMap }} - maps.Copy(output, page.{{ .ListTagsOutTagsElem }}) - {{- else }} - for _, v := range page.{{ .ListTagsOutTagsElem }} { - if v != nil { - output = append(output, v) - } - } - {{- end }} - - return !lastPage - }) - {{- end }} -{{ else }} - {{- if .RetryTagsListTagsType }} - - output, err := tfresource.RetryGWhenMessageContains(ctx, {{ .RetryTagsTimeout }}, - func() (*{{ .TagPackage }}.{{ .RetryTagsListTagsType }}, error) { - return conn.{{ .ListTagsOp }}WithContext(ctx, input) - }, - []string{ - {{- range .RetryTagsErrorCodes }} - {{ . }}, - {{- end }} - }, - []string{ - {{- range .RetryTagsErrorMessages }} - "{{ . }}", - {{- end }} - }, - ) - {{- else }} - - output, err := conn.{{ .ListTagsOp }}WithContext(ctx, input) - {{- end }} -{{- end }} - - {{ if and ( .ParentNotFoundErrCode ) ( .ParentNotFoundErrMsg ) }} - if tfawserr.ErrMessageContains(err, "{{ .ParentNotFoundErrCode }}", "{{ .ParentNotFoundErrMsg }}") { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: input, - } - } - {{- else if ( .ParentNotFoundErrCode ) }} - if tfawserr.ErrCodeEquals(err, "{{ .ParentNotFoundErrCode }}") { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: input, - } - } - {{- end }} - - if err != nil { - return tftags.New(ctx, nil), err - } - -{{ if .ListTagsOpPaginated }} - return {{ .KeyValueTagsFunc }}(ctx, output{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}{{ end }}), nil -{{- else }} - return {{ .KeyValueTagsFunc }}(ctx, output.{{ .ListTagsOutTagsElem }}{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}{{ end }}), nil -{{- end }} -} - -{{- if .IsDefaultListTags }} -// {{ .ListTagsFunc | Title }} lists {{ .ServicePackage }} service tags and set them in Context. -// It is called from outside this package. -func (p *servicePackage) {{ .ListTagsFunc | Title }}(ctx context.Context, meta any, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string) error { - tags, err := {{ .ListTagsFunc }}(ctx, meta.(*conns.AWSClient).{{ .ProviderNameUpper }}Conn(ctx), identifier{{ if .TagResTypeElem }}, resourceType{{ end }}) - - if err != nil { - return err - } - - if inContext, ok := tftags.FromContext(ctx); ok { - inContext.TagsOut = option.Some(tags) - } - - return nil -} -{{- end }} diff --git a/internal/generate/tags/templates/v1/service_tags_map_body.gtpl b/internal/generate/tags/templates/v1/service_tags_map_body.gtpl deleted file mode 100644 index c640fb00507..00000000000 --- a/internal/generate/tags/templates/v1/service_tags_map_body.gtpl +++ /dev/null @@ -1,41 +0,0 @@ -// map[string]*string handling - -// {{ .TagsFunc }} returns {{ .ServicePackage }} service tags. -func {{ .TagsFunc }}(tags tftags.KeyValueTags) map[string]*string { - return aws.StringMap(tags.Map()) -} - -// {{ .KeyValueTagsFunc }} creates tftags.KeyValueTags from {{ .ServicePackage }} service tags. -func {{ .KeyValueTagsFunc }}(ctx context.Context, tags map[string]*string) tftags.KeyValueTags { - return tftags.New(ctx, tags) -} - -// {{ .GetTagsInFunc }} returns {{ .ServicePackage }} service tags from Context. -// nil is returned if there are no input tags. -func {{ .GetTagsInFunc }}(ctx context.Context) map[string]*string { - if inContext, ok := tftags.FromContext(ctx); ok { - if tags := {{ .TagsFunc }}(inContext.TagsIn.UnwrapOrDefault()); len(tags) > 0 { - return tags - } - } - - return nil -} - -// {{ .SetTagsOutFunc }} sets {{ .ServicePackage }} service tags in Context. -func {{ .SetTagsOutFunc }}(ctx context.Context, tags map[string]*string) { - if inContext, ok := tftags.FromContext(ctx); ok { - inContext.TagsOut = option.Some({{ .KeyValueTagsFunc }}(ctx, tags)) - } -} - -{{- if ne .CreateTagsFunc "" }} -// {{ .CreateTagsFunc }} creates {{ .ServicePackage }} service tags for new resources. -func {{ .CreateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string, tags map[string]*string) error { - if len(tags) == 0 { - return nil - } - - return {{ .UpdateTagsFunc }}(ctx, conn, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}, nil, tags) -} -{{- end }} diff --git a/internal/generate/tags/templates/v1/service_tags_slice_body.gtpl b/internal/generate/tags/templates/v1/service_tags_slice_body.gtpl deleted file mode 100644 index 218d2483b3a..00000000000 --- a/internal/generate/tags/templates/v1/service_tags_slice_body.gtpl +++ /dev/null @@ -1,264 +0,0 @@ -// []*SERVICE.Tag handling - -{{ if and ( .TagTypeIDElem ) ( .TagTypeAddBoolElem ) }} -// ListOfMap returns a list of {{ .ServicePackage }} in flattened map. -// -// Compatible with setting Terraform state for strongly typed configuration blocks. -// -// This function strips tag resource identifier and type. Generally, this is -// the desired behavior so the tag schema does not require those attributes. -// Use (tftags.KeyValueTags).ListOfMap() for full tag information. -func ListOfMap(tags tftags.KeyValueTags) []any { - var result []any - - for _, key := range tags.Keys() { - m := map[string]any{ - names.AttrKey: key, - names.AttrValue: aws.StringValue(tags.KeyValue(key)), - {{ if .TagTypeAddBoolElem }} - "{{ .TagTypeAddBoolElemSnake }}": 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 }} { - result := make([]*{{ .TagPackage }}.{{ .TagKeyType }}, 0, len(tags)) - - for k := range tags.Map() { - tagKey := &{{ .TagPackage }}.{{ .TagKeyType }}{ - {{ .TagTypeKeyElem }}: aws.String(k), - } - - result = append(result, tagKey) - } - - return result -} -{{- end }} - -// {{ .TagsFunc }} returns {{ .ServicePackage }} service tags. -func {{ .TagsFunc }}(tags tftags.KeyValueTags) []*{{ .TagPackage }}.{{ .TagType }} { - {{- if or ( .TagTypeIDElem ) ( .TagTypeAddBoolElem) }} - var result []*{{ .TagPackage }}.{{ .TagType }} - - for _, key := range tags.Keys() { - tag := &{{ .TagPackage }}.{{ .TagType }}{ - {{ .TagTypeKeyElem }}: aws.String(key), - {{ .TagTypeValElem }}: tags.KeyValue(key), - {{- if ( .TagTypeIDElem ) }} - {{ .TagTypeIDElem }}: tags.KeyAdditionalStringValue(key, "{{ .TagTypeIDElem }}"), - {{- if ( .TagResTypeElem ) }} - {{ .TagResTypeElem }}: tags.KeyAdditionalStringValue(key, "{{ .TagResTypeElem }}"), - {{- end }} - {{- end }} - {{- if .TagTypeAddBoolElem }} - {{ .TagTypeAddBoolElem }}: tags.KeyAdditionalBoolValue(key, "{{ .TagTypeAddBoolElem }}"), - {{- end }} - } - - result = append(result, tag) - } - {{- else }} - result := make([]*{{ .TagPackage }}.{{ .TagType }}, 0, len(tags)) - - for k, v := range tags.Map() { - tag := &{{ .TagPackage }}.{{ .TagType }}{ - {{ .TagTypeKeyElem }}: aws.String(k), - {{ .TagTypeValElem }}: aws.String(v), - } - - result = append(result, tag) - } - {{- end }} - - return result -} - -// {{ .KeyValueTagsFunc }} creates tftags.KeyValueTags from {{ .AWSService }} service tags. -{{- if or ( .TagType2 ) ( .TagTypeAddBoolElem ) }} -// -// Accepts the following types: -// - []*{{ .TagPackage }}.{{ .TagType }} -{{- if .TagType2 }} -// - []*{{ .TagPackage }}.{{ .TagType2 }} -{{- end }} -{{- if .TagTypeAddBoolElem }} -// - []any (Terraform TypeList configuration block compatible) -// - *schema.Set (Terraform TypeSet configuration block compatible) -{{- end }} -func {{ .KeyValueTagsFunc }}(ctx context.Context, tags any{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string{{ end }}) tftags.KeyValueTags { - switch tags := tags.(type) { - case []*{{ .TagPackage }}.{{ .TagType }}: - {{- if or ( .TagTypeIDElem ) ( .TagTypeAddBoolElem) }} - m := make(map[string]*tftags.TagData, len(tags)) - - for _, tag := range tags { - tagData := &tftags.TagData{ - Value: tag.{{ .TagTypeValElem }}, - } - - tagData.AdditionalBoolFields = make(map[string]*bool) - {{- if .TagTypeAddBoolElem }} - tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = tag.{{ .TagTypeAddBoolElem }} - {{- end }} - - {{- if .TagTypeIDElem }} - tagData.AdditionalStringFields = make(map[string]*string) - tagData.AdditionalStringFields["{{ .TagTypeIDElem }}"] = &identifier - {{- if .TagResTypeElem }} - tagData.AdditionalStringFields["{{ .TagResTypeElem }}"] = &resourceType - {{- end }} - {{- end }} - - m[aws.StringValue(tag.{{ .TagTypeKeyElem }})] = tagData - } - {{- else }} - m := make(map[string]*string, len(tags)) - - for _, tag := range tags { - m[aws.StringValue(tag.{{ .TagTypeKeyElem }})] = tag.{{ .TagTypeValElem }} - } - {{- end }} - - return tftags.New(ctx, m) - case []*{{ .TagPackage }}.{{ .TagType2 }}: - {{- if or ( .TagTypeIDElem ) ( .TagTypeAddBoolElem) }} - m := make(map[string]*tftags.TagData, len(tags)) - - for _, tag := range tags { - tagData := &tftags.TagData{ - Value: tag.{{ .TagTypeValElem }}, - } - - {{- if .TagTypeAddBoolElem }} - tagData.AdditionalBoolFields = make(map[string]*bool) - tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = tag.{{ .TagTypeAddBoolElem }} - {{- end }} - - {{- if .TagTypeIDElem }} - tagData.AdditionalStringFields = make(map[string]*string) - tagData.AdditionalStringFields["{{ .TagTypeIDElem }}"] = &identifier - {{- if .TagResTypeElem }} - tagData.AdditionalStringFields["{{ .TagResTypeElem }}"] = &resourceType - {{- end }} - {{- end }} - - m[aws.StringValue(tag.{{ .TagTypeKeyElem }})] = tagData - } - {{- else }} - m := make(map[string]*string, len(tags)) - - for _, tag := range tags { - m[aws.StringValue(tag.{{ .TagTypeKeyElem }})] = tag.{{ .TagTypeValElem }} - } - {{- end }} - - return tftags.New(ctx, m) - {{- if .TagTypeAddBoolElem }} - case *schema.Set: - return {{ .KeyValueTagsFunc }}(ctx, tags.List(){{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}{{ end }}) - case []any: - result := make(map[string]*tftags.TagData) - - for _, tfMapRaw := range tags { - tfMap, ok := tfMapRaw.(map[string]any) - - if !ok { - continue - } - - key, ok := tfMap[names.AttrKey].(string) - - if !ok { - continue - } - - tagData := &tftags.TagData{} - - if v, ok := tfMap[names.AttrValue].(string); ok { - tagData.Value = &v - } - - {{ if .TagTypeAddBoolElem }} - tagData.AdditionalBoolFields = make(map[string]*bool) - {{- if .TagTypeAddBoolElem }} - if v, ok := tfMap["{{ .TagTypeAddBoolElemSnake }}"].(bool); ok { - tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = &v - } - {{- end }} - {{- end }} - - {{ if .TagTypeIDElem }} - tagData.AdditionalStringFields = make(map[string]*string) - tagData.AdditionalStringFields["{{ .TagTypeIDElem }}"] = &identifier - {{- if .TagResTypeElem }} - tagData.AdditionalStringFields["{{ .TagResTypeElem }}"] = &resourceType - {{- end }} - {{- end }} - - result[key] = tagData - } - - return tftags.New(ctx, result) - {{- end }} - default: - return tftags.New(ctx, nil) - } -} -{{- else }} -func {{ .KeyValueTagsFunc }}(ctx context.Context, tags []*{{ .TagPackage }}.{{ .TagType }}) tftags.KeyValueTags { - m := make(map[string]*string, len(tags)) - - for _, tag := range tags { - m[aws.StringValue(tag.{{ .TagTypeKeyElem }})] = tag.{{ .TagTypeValElem }} - } - - return tftags.New(ctx, m) -} -{{- end }} - -// {{ .GetTagsInFunc }} returns {{ .ServicePackage }} service tags from Context. -// nil is returned if there are no input tags. -func {{ .GetTagsInFunc }}(ctx context.Context) []*{{ .TagPackage }}.{{ .TagType }} { - if inContext, ok := tftags.FromContext(ctx); ok { - if tags := {{ .TagsFunc }}(inContext.TagsIn.UnwrapOrDefault()); len(tags) > 0 { - return tags - } - } - - return nil -} - -// {{ .SetTagsOutFunc }} sets {{ .ServicePackage }} service tags in Context. -{{- if or ( .TagType2 ) ( .TagTypeAddBoolElem ) }} -func {{ .SetTagsOutFunc }}(ctx context.Context, tags any{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string{{ end }}) { - if inContext, ok := tftags.FromContext(ctx); ok { - inContext.TagsOut = option.Some({{ .KeyValueTagsFunc }}(ctx, tags{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}{{ end }})) - } -} -{{- else }} -func {{ .SetTagsOutFunc }}(ctx context.Context, tags []*{{ .TagPackage }}.{{ .TagType }}) { - if inContext, ok := tftags.FromContext(ctx); ok { - inContext.TagsOut = option.Some({{ .KeyValueTagsFunc }}(ctx, tags)) - } -} -{{- end }} - -{{- if ne .CreateTagsFunc "" }} -// {{ .CreateTagsFunc }} creates {{ .ServicePackage }} service tags for new resources. -func {{ .CreateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string, tags []*{{ .TagPackage }}.{{ .TagType }}) error { - if len(tags) == 0 { - return nil - } - - return {{ .UpdateTagsFunc }}(ctx, conn, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}, nil, {{ .KeyValueTagsFunc }}(ctx, tags)) -} -{{- end }} diff --git a/internal/generate/tags/templates/v1/update_tags_body.gtpl b/internal/generate/tags/templates/v1/update_tags_body.gtpl deleted file mode 100644 index 27d0d5bc01a..00000000000 --- a/internal/generate/tags/templates/v1/update_tags_body.gtpl +++ /dev/null @@ -1,224 +0,0 @@ -// {{ .UpdateTagsFunc }} updates {{ .ServicePackage }} service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -{{if .TagTypeAddBoolElem -}} -func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string, oldTagsSet, newTagsSet any) error { - oldTags := {{ .KeyValueTagsFunc }}(ctx, oldTagsSet, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}) - newTags := {{ .KeyValueTagsFunc }}(ctx, newTagsSet, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}) -{{- else -}} -func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string, oldTagsMap, newTagsMap any) error { - oldTags := tftags.New(ctx, oldTagsMap) - newTags := tftags.New(ctx, newTagsMap) -{{- end }} - - ctx = tflog.SetField(ctx, logging.KeyResourceId, identifier) - - {{- if eq (.TagOp) (.UntagOp) }} - - removedTags := oldTags.Removed(newTags) - {{- if .UpdateTagsIgnoreSystem }} - removedTags = removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}) - {{- end }} - updatedTags := oldTags.Updated(newTags) - {{- if .UpdateTagsIgnoreSystem }} - updatedTags = updatedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}) - {{- end }} - - // Ensure we do not send empty requests. - if len(removedTags) == 0 && len(updatedTags) == 0 { - return nil - } - - input := &{{ .TagPackage }}.{{ .TagOp }}Input{ - {{- if not ( .TagTypeIDElem ) }} - {{- if .TagInIDNeedSlice }} - {{ .TagInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else if .TagInIDNeedValueSlice }} - {{ .TagInIDElem }}: []string{identifier}, - {{- else }} - {{ .TagInIDElem }}: aws.String(identifier), - {{- end }} - {{- if .TagResTypeElem }} - {{ .TagResTypeElem }}: aws.String(resourceType), - {{- end }} - {{- end }} - } - - if len(updatedTags) > 0 { - input.{{ .TagInTagsElem }} = {{ .TagsFunc }}(updatedTags) - } - - if len(removedTags) > 0 { - {{- if .UntagInNeedTagType }} - input.{{ .UntagInTagsElem }} = {{ .TagsFunc }}(removedTags) - {{- else if .UntagInNeedTagKeyType }} - input.{{ .UntagInTagsElem }} = TagKeys(removedTags) - {{- else if .UntagInCustomVal }} - input.{{ .UntagInTagsElem }} = {{ .UntagInCustomVal }} - {{- else }} - input.{{ .UntagInTagsElem }} = aws.StringSlice(removedTags.Keys()) - {{- end }} - } - - {{ if .RetryTagsListTagsType }} - _, err := tfresource.RetryWhenMessageContains(ctx, {{ .RetryTagsTimeout }}, - func() (any, error) { - return conn.{{ .TagOp }}WithContext(ctx, input) - }, - []string{ - {{- range .RetryTagsErrorCodes }} - {{ . }}, - {{- end }} - }, - []string{ - {{- range .RetryTagsErrorMessages }} - "{{ . }}", - {{- end }} - }, - ) - {{ else }} - _, err := conn.{{ .TagOp }}WithContext(ctx, input) - {{- end }} - - if err != nil { - return fmt.Errorf("tagging resource (%s): %w", identifier, err) - } - - {{- else }} - - removedTags := oldTags.Removed(newTags) - {{- if .UpdateTagsIgnoreSystem }} - removedTags = removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}) - {{- end }} - if len(removedTags) > 0 { - {{- if .TagOpBatchSize }} - for _, removedTags := range removedTags.Chunks({{ .TagOpBatchSize }}) { - {{- end }} - input := &{{ .TagPackage }}.{{ .UntagOp }}Input{ - {{- if not ( .TagTypeIDElem ) }} - {{- if .TagInIDNeedSlice }} - {{ .TagInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else if .TagInIDNeedValueSlice }} - {{ .TagInIDElem }}: []string{identifier}, - {{- else }} - {{ .TagInIDElem }}: aws.String(identifier), - {{- end }} - {{- if .TagResTypeElem }} - {{ .TagResTypeElem }}: aws.String(resourceType), - {{- end }} - {{- end }} - {{- if .UntagInNeedTagType }} - {{ .UntagInTagsElem }}: {{ .TagsFunc }}(removedTags), - {{- else if .UntagInNeedTagKeyType }} - {{ .UntagInTagsElem }}: TagKeys(removedTags), - {{- else if .UntagInCustomVal }} - {{ .UntagInTagsElem }}: {{ .UntagInCustomVal }}, - {{- else }} - {{ .UntagInTagsElem }}: aws.StringSlice(removedTags.Keys()), - {{- end }} - } - - {{ if .RetryTagsListTagsType }} - _, err := tfresource.RetryWhenMessageContains(ctx, {{ .RetryTagsTimeout }}, - func() (any, error) { - return conn.{{ .UntagOp }}WithContext(ctx, input) - }, - []string{ - {{- range .RetryTagsErrorCodes }} - {{ . }}, - {{- end }} - }, - []string{ - {{- range .RetryTagsErrorMessages }} - "{{ . }}", - {{- end }} - }, - ) - {{ else }} - _, err := conn.{{ .UntagOp }}WithContext(ctx, input) - {{- end }} - - if err != nil { - return fmt.Errorf("untagging resource (%s): %w", identifier, err) - } - {{- if .TagOpBatchSize }} - } - {{- end }} - } - - updatedTags := oldTags.Updated(newTags) - {{- if .UpdateTagsIgnoreSystem }} - updatedTags = updatedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}) - {{- end }} - if len(updatedTags) > 0 { - {{- if .TagOpBatchSize }} - for _, updatedTags := range updatedTags.Chunks({{ .TagOpBatchSize }}) { - {{- end }} - input := &{{ .TagPackage }}.{{ .TagOp }}Input{ - {{- if not ( .TagTypeIDElem ) }} - {{- if .TagInIDNeedSlice }} - {{ .TagInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else if .TagInIDNeedValueSlice }} - {{ .TagInIDElem }}: []string{identifier}, - {{- else }} - {{ .TagInIDElem }}: aws.String(identifier), - {{- end }} - {{- if .TagResTypeElem }} - {{ .TagResTypeElem }}: aws.String(resourceType), - {{- end }} - {{- end }} - {{- if .TagInCustomVal }} - {{ .TagInTagsElem }}: {{ .TagInCustomVal }}, - {{- else }} - {{ .TagInTagsElem }}: {{ .TagsFunc }}(updatedTags), - {{- end }} - } - - {{ if .RetryTagsListTagsType }} - _, err := tfresource.RetryWhenMessageContains(ctx, {{ .RetryTagsTimeout }}, - func() (any, error) { - return conn.{{ .TagOp }}WithContext(ctx, input) - }, - []string{ - {{- range .RetryTagsErrorCodes }} - {{ . }}, - {{- end }} - }, - []string{ - {{- range .RetryTagsErrorMessages }} - "{{ . }}", - {{- end }} - }, - ) - {{ else }} - _, err := conn.{{ .TagOp }}WithContext(ctx, input) - {{- end }} - - if err != nil { - return fmt.Errorf("tagging resource (%s): %w", identifier, err) - } - {{- if .TagOpBatchSize }} - } - {{- end }} - } - - {{- end }} - - {{ if .WaitForPropagation }} - if len(removedTags) > 0 || len(updatedTags) > 0 { - if err := {{ .WaitTagsPropagatedFunc }}(ctx, conn, identifier, newTags); err != nil { - return fmt.Errorf("waiting for resource (%s) tag propagation: %w", identifier, err) - } - } - {{- end }} - - return nil -} - -{{- if .IsDefaultUpdateTags }} -// {{ .UpdateTagsFunc | Title }} updates {{ .ServicePackage }} service tags. -// It is called from outside this package. -func (p *servicePackage) {{ .UpdateTagsFunc | Title }}(ctx context.Context, meta any, identifier{{ if .TagResTypeElem }}, resourceType{{ end }} string, oldTags, newTags any) error { - return {{ .UpdateTagsFunc }}(ctx, meta.(*conns.AWSClient).{{ .ProviderNameUpper }}Conn(ctx), identifier{{ if .TagResTypeElem }}, resourceType{{ end }}, oldTags, newTags) -} -{{- end }} diff --git a/internal/generate/tags/templates/v1/v1.go b/internal/generate/tags/templates/v1/v1.go deleted file mode 100644 index 3d3fd2761f1..00000000000 --- a/internal/generate/tags/templates/v1/v1.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package v1 - -import ( - _ "embed" -) - -//go:embed header_body.gtpl -var HeaderBody string - -//go:embed get_tag_body.gtpl -var GetTagBody string - -//go:embed list_tags_body.gtpl -var ListTagsBody string - -//go:embed service_tags_map_body.gtpl -var ServiceTagsMapBody string - -//go:embed service_tags_slice_body.gtpl -var ServiceTagsSliceBody string - -//go:embed update_tags_body.gtpl -var UpdateTagsBody string - -//go:embed wait_tags_propagated_body.gtpl -var WaitTagsPropagatedBody string diff --git a/internal/generate/tags/templates/v1/wait_tags_propagated_body.gtpl b/internal/generate/tags/templates/v1/wait_tags_propagated_body.gtpl deleted file mode 100644 index 21d1568fe59..00000000000 --- a/internal/generate/tags/templates/v1/wait_tags_propagated_body.gtpl +++ /dev/null @@ -1,43 +0,0 @@ -// {{ .WaitTagsPropagatedFunc }} waits for {{ .ServicePackage }} service tags to be propagated. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func {{ .WaitTagsPropagatedFunc }}(ctx context.Context, conn {{ .ClientType }}, id string, tags tftags.KeyValueTags) error { - tflog.Debug(ctx, "Waiting for tag propagation", map[string]any{ - names.AttrTags: tags, - }) - - checkFunc := func() (bool, error) { - output, err := {{ .ListTagsFunc }}(ctx, conn, id) - - if tfresource.NotFound(err) { - return false, nil - } - - if err != nil { - return false, err - } - - if inContext, ok := tftags.FromContext(ctx); ok { - tags = tags.IgnoreConfig(inContext.IgnoreConfig) - output = output.IgnoreConfig(inContext.IgnoreConfig) - } - - return output.Equal(tags), nil - } - opts := tfresource.WaitOpts{ - {{- if ne .WaitContinuousOccurence 0 }} - ContinuousTargetOccurence: {{ .WaitContinuousOccurence }}, - {{- end }} - {{- if ne .WaitDelay "" }} - Delay: {{ .WaitDelay }}, - {{- end }} - {{- if ne .WaitMinTimeout "" }} - MinTimeout: {{ .WaitMinTimeout }}, - {{- end }} - {{- if ne .WaitPollInterval "" }} - PollInterval: {{ .WaitPollInterval }}, - {{- end }} - } - - return tfresource.WaitUntil(ctx, {{ .WaitTimeout }}, checkFunc, opts) -} From 14e611070eae2e8238d9b91d230d4f30150e13d9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:28:49 -0400 Subject: [PATCH 02/24] Remove unused '-AWSSDKVersion=2' from tags generation callers. --- internal/service/resiliencehub/generate.go | 2 +- internal/service/route53profiles/generate.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/resiliencehub/generate.go b/internal/service/resiliencehub/generate.go index 5699dd6a0f8..71027572c7b 100644 --- a/internal/service/resiliencehub/generate.go +++ b/internal/service/resiliencehub/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -ListTagsInIDElem=ResourceArn -ListTagsOutTagsElem=Tags -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -ListTagsInIDElem=ResourceArn -ListTagsOutTagsElem=Tags -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/route53profiles/generate.go b/internal/service/route53profiles/generate.go index 8125ae5cf64..0ca90ce6fd8 100644 --- a/internal/service/route53profiles/generate.go +++ b/internal/service/route53profiles/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ListTags -ListTagsInIDElem=ResourceArn -KVTValues -UpdateTags -TagInIDElem=ResourceArn -ServiceTagsMap -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -KVTValues -UpdateTags -TagInIDElem=ResourceArn -ServiceTagsMap -SkipTypesImp //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From 7f114542e34c1447d51c39c043e267c8956ffd2e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:31:15 -0400 Subject: [PATCH 03/24] Remove 'AWSSDKVersion' flag from tags generator. --- internal/generate/tags/main.go | 43 +++++++++++----------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index 76923003ab0..2fda6b0f9fa 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -19,10 +19,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/names/data" ) -const ( - sdkV2 = 2 -) - const ( defaultListTagsFunc = "listTags" defaultUpdateTagsFunc = "updateTags" @@ -91,7 +87,6 @@ var ( parentNotFoundErrMsg = flag.String("ParentNotFoundErrMsg", "", "Parent 'NotFound' Error Message") sdkServicePackage = flag.String("AWSSDKServicePackage", "", "AWS Go SDK package to use. Defaults to the provider service package name.") - sdkVersion = flag.Int("AWSSDKVersion", sdkV2, "Version of the AWS Go SDK to use i.e. 1 or 2") kvtValues = flag.Bool("KVTValues", false, "Whether KVT string map is of string pointers") emptyMap = flag.Bool("EmptyMap", false, "Whether KVT string map should be empty for no tags") skipAWSImp = flag.Bool("SkipAWSImp", false, "Whether to skip importing the AWS Go SDK aws package") // nosemgrep:ci.aws-in-var-name @@ -117,31 +112,26 @@ type TemplateBody struct { waitTagsPropagated string } -func newTemplateBody(version int, kvtValues bool) *TemplateBody { - switch version { - case sdkV2: - if kvtValues { - return &TemplateBody{ - getTag: "\n" + v2.GetTagBody, - header: v2.HeaderBody, - listTags: "\n" + v2.ListTagsBody, - serviceTagsMap: "\n" + v2.ServiceTagsValueMapBody, - serviceTagsSlice: "\n" + v2.ServiceTagsSliceBody, - updateTags: "\n" + v2.UpdateTagsBody, - waitTagsPropagated: "\n" + v2.WaitTagsPropagatedBody, - } - } +func newTemplateBody(kvtValues bool) *TemplateBody { + if kvtValues { return &TemplateBody{ getTag: "\n" + v2.GetTagBody, header: v2.HeaderBody, listTags: "\n" + v2.ListTagsBody, - serviceTagsMap: "\n" + v2.ServiceTagsMapBody, + serviceTagsMap: "\n" + v2.ServiceTagsValueMapBody, serviceTagsSlice: "\n" + v2.ServiceTagsSliceBody, updateTags: "\n" + v2.UpdateTagsBody, waitTagsPropagated: "\n" + v2.WaitTagsPropagatedBody, } - default: - return nil + } + return &TemplateBody{ + getTag: "\n" + v2.GetTagBody, + header: v2.HeaderBody, + listTags: "\n" + v2.ListTagsBody, + serviceTagsMap: "\n" + v2.ServiceTagsMapBody, + serviceTagsSlice: "\n" + v2.ServiceTagsSliceBody, + updateTags: "\n" + v2.UpdateTagsBody, + waitTagsPropagated: "\n" + v2.WaitTagsPropagatedBody, } } @@ -238,10 +228,6 @@ func main() { g := common.NewGenerator() - if *sdkVersion != sdkV2 { - g.Fatalf("AWS SDK Go Version %d not supported", *sdkVersion) - } - servicePackage := os.Getenv("GOPACKAGE") if *sdkServicePackage == "" { sdkServicePackage = &servicePackage @@ -264,8 +250,7 @@ func main() { createTagsFunc = "" } - clientTypeName := service.ClientTypeName(*sdkVersion) - clientType := fmt.Sprintf("*%s.%s", awsPkg, clientTypeName) + clientType := fmt.Sprintf("*%s.Client", awsPkg) tagPackage := awsPkg var cleanRetryErrorCodes []string @@ -359,7 +344,7 @@ func main() { IsDefaultUpdateTags: *updateTagsFunc == defaultUpdateTagsFunc, } - templateBody := newTemplateBody(*sdkVersion, *kvtValues) + templateBody := newTemplateBody(*kvtValues) d := g.NewGoFileDestination(filename) if *getTag || *listTags || *serviceTagsMap || *serviceTagsSlice || *updateTags { From 81594287d9a49a920aa10742f8b0c88e76e78819 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:34:01 -0400 Subject: [PATCH 04/24] 'internal/generate/tags/templates/v2' -> 'internal/generate/tags/templates'. --- internal/generate/tags/main.go | 30 +++++++++---------- .../tags/templates/{v2 => }/get_tag_body.gtpl | 0 .../tags/templates/{v2 => }/header_body.gtpl | 0 .../templates/{v2 => }/list_tags_body.gtpl | 0 .../{v2 => }/service_tags_map_body.gtpl | 0 .../{v2 => }/service_tags_slice_body.gtpl | 0 .../{v2 => }/service_tags_value_map_body.gtpl | 0 .../tags/templates/{v2/v2.go => templates.go} | 5 +--- .../templates/{v2 => }/update_tags_body.gtpl | 0 .../{v2 => }/wait_tags_propagated_body.gtpl | 0 10 files changed, 16 insertions(+), 19 deletions(-) rename internal/generate/tags/templates/{v2 => }/get_tag_body.gtpl (100%) rename internal/generate/tags/templates/{v2 => }/header_body.gtpl (100%) rename internal/generate/tags/templates/{v2 => }/list_tags_body.gtpl (100%) rename internal/generate/tags/templates/{v2 => }/service_tags_map_body.gtpl (100%) rename internal/generate/tags/templates/{v2 => }/service_tags_slice_body.gtpl (100%) rename internal/generate/tags/templates/{v2 => }/service_tags_value_map_body.gtpl (100%) rename internal/generate/tags/templates/{v2/v2.go => templates.go} (86%) rename internal/generate/tags/templates/{v2 => }/update_tags_body.gtpl (100%) rename internal/generate/tags/templates/{v2 => }/wait_tags_propagated_body.gtpl (100%) diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index 2fda6b0f9fa..6dd3da8cb6c 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -15,7 +15,7 @@ import ( "github.com/YakDriver/regexache" "github.com/hashicorp/terraform-provider-aws/internal/generate/common" - v2 "github.com/hashicorp/terraform-provider-aws/internal/generate/tags/templates/v2" + "github.com/hashicorp/terraform-provider-aws/internal/generate/tags/templates" "github.com/hashicorp/terraform-provider-aws/names/data" ) @@ -115,23 +115,23 @@ type TemplateBody struct { func newTemplateBody(kvtValues bool) *TemplateBody { if kvtValues { return &TemplateBody{ - getTag: "\n" + v2.GetTagBody, - header: v2.HeaderBody, - listTags: "\n" + v2.ListTagsBody, - serviceTagsMap: "\n" + v2.ServiceTagsValueMapBody, - serviceTagsSlice: "\n" + v2.ServiceTagsSliceBody, - updateTags: "\n" + v2.UpdateTagsBody, - waitTagsPropagated: "\n" + v2.WaitTagsPropagatedBody, + getTag: "\n" + templates.GetTagBody, + header: templates.HeaderBody, + listTags: "\n" + templates.ListTagsBody, + serviceTagsMap: "\n" + templates.ServiceTagsValueMapBody, + serviceTagsSlice: "\n" + templates.ServiceTagsSliceBody, + updateTags: "\n" + templates.UpdateTagsBody, + waitTagsPropagated: "\n" + templates.WaitTagsPropagatedBody, } } return &TemplateBody{ - getTag: "\n" + v2.GetTagBody, - header: v2.HeaderBody, - listTags: "\n" + v2.ListTagsBody, - serviceTagsMap: "\n" + v2.ServiceTagsMapBody, - serviceTagsSlice: "\n" + v2.ServiceTagsSliceBody, - updateTags: "\n" + v2.UpdateTagsBody, - waitTagsPropagated: "\n" + v2.WaitTagsPropagatedBody, + getTag: "\n" + templates.GetTagBody, + header: templates.HeaderBody, + listTags: "\n" + templates.ListTagsBody, + serviceTagsMap: "\n" + templates.ServiceTagsMapBody, + serviceTagsSlice: "\n" + templates.ServiceTagsSliceBody, + updateTags: "\n" + templates.UpdateTagsBody, + waitTagsPropagated: "\n" + templates.WaitTagsPropagatedBody, } } diff --git a/internal/generate/tags/templates/v2/get_tag_body.gtpl b/internal/generate/tags/templates/get_tag_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/get_tag_body.gtpl rename to internal/generate/tags/templates/get_tag_body.gtpl diff --git a/internal/generate/tags/templates/v2/header_body.gtpl b/internal/generate/tags/templates/header_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/header_body.gtpl rename to internal/generate/tags/templates/header_body.gtpl diff --git a/internal/generate/tags/templates/v2/list_tags_body.gtpl b/internal/generate/tags/templates/list_tags_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/list_tags_body.gtpl rename to internal/generate/tags/templates/list_tags_body.gtpl diff --git a/internal/generate/tags/templates/v2/service_tags_map_body.gtpl b/internal/generate/tags/templates/service_tags_map_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/service_tags_map_body.gtpl rename to internal/generate/tags/templates/service_tags_map_body.gtpl diff --git a/internal/generate/tags/templates/v2/service_tags_slice_body.gtpl b/internal/generate/tags/templates/service_tags_slice_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/service_tags_slice_body.gtpl rename to internal/generate/tags/templates/service_tags_slice_body.gtpl diff --git a/internal/generate/tags/templates/v2/service_tags_value_map_body.gtpl b/internal/generate/tags/templates/service_tags_value_map_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/service_tags_value_map_body.gtpl rename to internal/generate/tags/templates/service_tags_value_map_body.gtpl diff --git a/internal/generate/tags/templates/v2/v2.go b/internal/generate/tags/templates/templates.go similarity index 86% rename from internal/generate/tags/templates/v2/v2.go rename to internal/generate/tags/templates/templates.go index 0ea733e812d..a953a7d8e01 100644 --- a/internal/generate/tags/templates/v2/v2.go +++ b/internal/generate/tags/templates/templates.go @@ -1,15 +1,12 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package v2 +package templates import ( _ "embed" ) -// Package v2 contains the template bodies for tag methods -// using the AWS SDK Go V2. - //go:embed header_body.gtpl var HeaderBody string diff --git a/internal/generate/tags/templates/v2/update_tags_body.gtpl b/internal/generate/tags/templates/update_tags_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/update_tags_body.gtpl rename to internal/generate/tags/templates/update_tags_body.gtpl diff --git a/internal/generate/tags/templates/v2/wait_tags_propagated_body.gtpl b/internal/generate/tags/templates/wait_tags_propagated_body.gtpl similarity index 100% rename from internal/generate/tags/templates/v2/wait_tags_propagated_body.gtpl rename to internal/generate/tags/templates/wait_tags_propagated_body.gtpl From 586c8606a0d2822631a21c550e97d4c2379d6844 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:43:04 -0400 Subject: [PATCH 05/24] Remove unused '-SkipAWSImp' from tags generation callers. --- internal/service/macie2/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/macie2/generate.go b/internal/service/macie2/generate.go index 17f1f873bb9..614b2f2c349 100644 --- a/internal/service/macie2/generate.go +++ b/internal/service/macie2/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues=true -ServiceTagsMap -SkipAWSImp +//go:generate go run ../../generate/tags/main.go -KVTValues=true -ServiceTagsMap //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From 48acc7ff97e89a7519238c62f5537b1fe8966947 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:43:50 -0400 Subject: [PATCH 06/24] Remove unused '-SkipNamesImp' from tags generation callers. --- internal/service/transfer/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/transfer/generate.go b/internal/service/transfer/generate.go index 11156eed49e..2451b0c2294 100644 --- a/internal/service/transfer/generate.go +++ b/internal/service/transfer/generate.go @@ -3,7 +3,7 @@ //go:generate go run ../../generate/tagresource/main.go -UpdateTagsFunc=updateTagsNoIgnoreSystem //go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsInIDElem=Arn -ServiceTagsSlice -TagInIDElem=Arn -UpdateTags -//go:generate go run ../../generate/tags/main.go -TagInIDElem=Arn -UpdateTags -UpdateTagsFunc=updateTagsNoIgnoreSystem -UpdateTagsNoIgnoreSystem -SkipNamesImp -SkipTypesImp -- update_tags_no_system_ignore_gen.go +//go:generate go run ../../generate/tags/main.go -TagInIDElem=Arn -UpdateTags -UpdateTagsFunc=updateTagsNoIgnoreSystem -UpdateTagsNoIgnoreSystem -SkipTypesImp -- update_tags_no_system_ignore_gen.go //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From 265123fff186cf441edb634159160460b161046f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:45:12 -0400 Subject: [PATCH 07/24] Remove unused '-SkipAWSServiceImp' from tags generation callers. --- internal/service/cloudformation/generate.go | 2 +- internal/service/codebuild/generate.go | 2 +- internal/service/iam/generate.go | 2 +- internal/service/resourcegroupstaggingapi/generate.go | 2 +- internal/service/s3/generate.go | 2 +- internal/service/s3control/generate.go | 2 +- internal/service/serverlessrepo/generate.go | 2 +- internal/service/servicecatalog/generate.go | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/service/cloudformation/generate.go b/internal/service/cloudformation/generate.go index fd29d08145b..86b5e981d71 100644 --- a/internal/service/cloudformation/generate.go +++ b/internal/service/cloudformation/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -SkipAWSServiceImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/codebuild/generate.go b/internal/service/codebuild/generate.go index 79bd0e055e1..38b80319dc1 100644 --- a/internal/service/codebuild/generate.go +++ b/internal/service/codebuild/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -SkipAWSServiceImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/iam/generate.go b/internal/service/iam/generate.go index a54d9a7a7d2..15bda2593e0 100644 --- a/internal/service/iam/generate.go +++ b/internal/service/iam/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -Paginator=Marker -ListOps=ListGroupsForUser -//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -SkipAWSServiceImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/resourcegroupstaggingapi/generate.go b/internal/service/resourcegroupstaggingapi/generate.go index e0a1efc7c49..b306822d5bd 100644 --- a/internal/service/resourcegroupstaggingapi/generate.go +++ b/internal/service/resourcegroupstaggingapi/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -SkipAWSServiceImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/s3/generate.go b/internal/service/s3/generate.go index c6d52fdaa1f..b9e63a146ae 100644 --- a/internal/service/s3/generate.go +++ b/internal/service/s3/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -SkipAWSServiceImp -ServiceTagsSlice -TagsFunc=Tags -KeyValueTagsFunc=keyValueTags -GetTagsInFunc=getTagsIn -SetTagsOutFunc=setTagsOut +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -TagsFunc=Tags -KeyValueTagsFunc=keyValueTags -GetTagsInFunc=getTagsIn -SetTagsOutFunc=setTagsOut //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/s3control/generate.go b/internal/service/s3control/generate.go index 66e338fc406..718570a8776 100644 --- a/internal/service/s3control/generate.go +++ b/internal/service/s3control/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsSlice -TagResTypeElem=AccountId -UpdateTags -//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -TagsFunc=tagsS3 -KeyValueTagsFunc=keyValueTagsS3 -GetTagsInFunc=getTagsInS3 -SetTagsOutFunc=setTagsOutS3 -SkipAWSServiceImp -TagType=S3Tag -- tagss3_gen.go +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -TagsFunc=tagsS3 -KeyValueTagsFunc=keyValueTagsS3 -GetTagsInFunc=getTagsInS3 -SetTagsOutFunc=setTagsOutS3 -TagType=S3Tag -- tagss3_gen.go //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/serverlessrepo/generate.go b/internal/service/serverlessrepo/generate.go index d0c5c0b1f93..71aeaf48552 100644 --- a/internal/service/serverlessrepo/generate.go +++ b/internal/service/serverlessrepo/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -SkipAWSServiceImp -ServiceTagsSlice +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/servicecatalog/generate.go b/internal/service/servicecatalog/generate.go index f76fe5706a0..57574ebc5bc 100644 --- a/internal/service/servicecatalog/generate.go +++ b/internal/service/servicecatalog/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice -SkipAWSServiceImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsSlice //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From cf0841d4e6b958713c7d26f9b78bbb158fa36e9a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:46:03 -0400 Subject: [PATCH 08/24] Remove unused '-SkipTypesImp' from tags generation callers. --- internal/service/accessanalyzer/generate.go | 2 +- internal/service/amp/generate.go | 2 +- internal/service/amplify/generate.go | 2 +- internal/service/apigateway/generate.go | 2 +- internal/service/apigatewayv2/generate.go | 2 +- internal/service/appautoscaling/generate.go | 2 +- internal/service/appconfig/generate.go | 2 +- internal/service/appflow/generate.go | 2 +- internal/service/appintegrations/generate.go | 2 +- internal/service/appstream/generate.go | 2 +- internal/service/appsync/generate.go | 2 +- internal/service/auditmanager/generate.go | 2 +- internal/service/backup/generate.go | 2 +- internal/service/batch/generate.go | 2 +- internal/service/bedrockagent/generate.go | 2 +- internal/service/cleanrooms/generate.go | 2 +- internal/service/codecommit/generate.go | 2 +- internal/service/codeguruprofiler/generate.go | 2 +- internal/service/codegurureviewer/generate.go | 2 +- internal/service/codestarnotifications/generate.go | 2 +- internal/service/cognitoidentity/generate.go | 2 +- internal/service/cognitoidp/generate.go | 2 +- internal/service/connect/generate.go | 2 +- internal/service/controltower/generate.go | 2 +- internal/service/customerprofiles/generate.go | 2 +- internal/service/databrew/generate.go | 2 +- internal/service/dataexchange/generate.go | 2 +- internal/service/datazone/generate.go | 2 +- internal/service/detective/generate.go | 2 +- internal/service/dlm/generate.go | 2 +- internal/service/docdbelastic/generate.go | 2 +- internal/service/drs/generate.go | 2 +- internal/service/dynamodb/generate.go | 2 +- internal/service/eks/generate.go | 2 +- internal/service/emrcontainers/generate.go | 2 +- internal/service/emrserverless/generate.go | 2 +- internal/service/evidently/generate.go | 2 +- internal/service/finspace/generate.go | 2 +- internal/service/fis/generate.go | 2 +- internal/service/glacier/generate.go | 2 +- internal/service/glue/generate.go | 2 +- internal/service/grafana/generate.go | 2 +- internal/service/greengrass/generate.go | 2 +- internal/service/guardduty/generate.go | 2 +- internal/service/healthlake/generate.go | 2 +- internal/service/imagebuilder/generate.go | 2 +- internal/service/internetmonitor/generate.go | 2 +- internal/service/ivs/generate.go | 2 +- internal/service/ivschat/generate.go | 2 +- internal/service/kafka/generate.go | 2 +- internal/service/kafkaconnect/generate.go | 2 +- internal/service/kinesisvideo/generate.go | 2 +- internal/service/lambda/generate.go | 2 +- internal/service/lexv2models/generate.go | 2 +- internal/service/location/generate.go | 2 +- internal/service/logs/generate.go | 2 +- internal/service/lookoutmetrics/generate.go | 2 +- internal/service/m2/generate.go | 2 +- internal/service/mediaconnect/generate.go | 2 +- internal/service/mediaconvert/generate.go | 2 +- internal/service/medialive/generate.go | 2 +- internal/service/mediapackage/generate.go | 2 +- internal/service/mq/generate.go | 2 +- internal/service/mwaa/generate.go | 2 +- internal/service/networkmonitor/generate.go | 2 +- internal/service/oam/generate.go | 2 +- internal/service/opsworks/generate.go | 2 +- internal/service/outposts/generate.go | 2 +- internal/service/pipes/generate.go | 2 +- internal/service/qldb/generate.go | 2 +- internal/service/rekognition/generate.go | 2 +- internal/service/resiliencehub/generate.go | 2 +- internal/service/resourceexplorer2/generate.go | 2 +- internal/service/resourcegroups/generate.go | 2 +- internal/service/route53profiles/generate.go | 2 +- internal/service/route53recoveryreadiness/generate.go | 2 +- internal/service/rum/generate.go | 2 +- internal/service/schemas/generate.go | 2 +- internal/service/securityhub/generate.go | 2 +- internal/service/servicecatalogappregistry/generate.go | 2 +- internal/service/signer/generate.go | 2 +- internal/service/sqs/generate.go | 2 +- internal/service/ssmincidents/generate.go | 2 +- internal/service/synthetics/generate.go | 2 +- internal/service/timestreaminfluxdb/generate.go | 2 +- internal/service/transfer/generate.go | 2 +- internal/service/vpclattice/generate.go | 2 +- internal/service/wellarchitected/generate.go | 2 +- internal/service/worklink/generate.go | 2 +- 89 files changed, 89 insertions(+), 89 deletions(-) diff --git a/internal/service/accessanalyzer/generate.go b/internal/service/accessanalyzer/generate.go index 9ef1fa73de7..11af213fe46 100644 --- a/internal/service/accessanalyzer/generate.go +++ b/internal/service/accessanalyzer/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/amp/generate.go b/internal/service/amp/generate.go index efbbd6f0df9..6def0f6b3b7 100644 --- a/internal/service/amp/generate.go +++ b/internal/service/amp/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -TagInIDElem=ResourceArn -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -TagInIDElem=ResourceArn -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/amplify/generate.go b/internal/service/amplify/generate.go index 56f47327614..616b68502c0 100644 --- a/internal/service/amplify/generate.go +++ b/internal/service/amplify/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/apigateway/generate.go b/internal/service/apigateway/generate.go index b7442d8e83e..37e425bcca7 100644 --- a/internal/service/apigateway/generate.go +++ b/internal/service/apigateway/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=GetAuthorizers -Paginator=Position -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp -ListTags -ListTagsOp=GetTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -KVTValues -ListTags -ListTagsOp=GetTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/apigatewayv2/generate.go b/internal/service/apigatewayv2/generate.go index 8b056b6bf18..d7af2d6a763 100644 --- a/internal/service/apigatewayv2/generate.go +++ b/internal/service/apigatewayv2/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=GetApis,GetApiMappings,GetDomainNames,GetVpcLinks -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=GetTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=GetTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/appautoscaling/generate.go b/internal/service/appautoscaling/generate.go index 037b74322c5..72267e48e85 100644 --- a/internal/service/appautoscaling/generate.go +++ b/internal/service/appautoscaling/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceARN -ServiceTagsMap -TagInIDElem=ResourceARN -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceARN -ServiceTagsMap -TagInIDElem=ResourceARN -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/appconfig/generate.go b/internal/service/appconfig/generate.go index e5189cd6a5f..0d59cf381b2 100644 --- a/internal/service/appconfig/generate.go +++ b/internal/service/appconfig/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/appflow/generate.go b/internal/service/appflow/generate.go index 2935dba00bc..46a796330ca 100644 --- a/internal/service/appflow/generate.go +++ b/internal/service/appflow/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/appintegrations/generate.go b/internal/service/appintegrations/generate.go index 28bcd9bee3b..22de614fff4 100644 --- a/internal/service/appintegrations/generate.go +++ b/internal/service/appintegrations/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp -ListTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -KVTValues -ListTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/appstream/generate.go b/internal/service/appstream/generate.go index b9e63950907..6571b4aa269 100644 --- a/internal/service/appstream/generate.go +++ b/internal/service/appstream/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeDirectoryConfigs,DescribeFleets,DescribeImageBuilders,DescribeStacks,DescribeUsers,ListAssociatedStacks -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/appsync/generate.go b/internal/service/appsync/generate.go index 99d41370018..a7b20c7e40a 100644 --- a/internal/service/appsync/generate.go +++ b/internal/service/appsync/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=ListApiKeys,ListDomainNames,ListGraphqlApis -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/auditmanager/generate.go b/internal/service/auditmanager/generate.go index a963116d18c..11267e3daad 100644 --- a/internal/service/auditmanager/generate.go +++ b/internal/service/auditmanager/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/backup/generate.go b/internal/service/backup/generate.go index a72eb085c67..8210bc457b7 100644 --- a/internal/service/backup/generate.go +++ b/internal/service/backup/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsOp=ListTags -ServiceTagsMap -SkipTypesImp -UntagInTagsElem=TagKeyList -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsOp=ListTags -ServiceTagsMap -UntagInTagsElem=TagKeyList -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/batch/generate.go b/internal/service/batch/generate.go index dfd3ec43a3c..2a62e2c7115 100644 --- a/internal/service/batch/generate.go +++ b/internal/service/batch/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -KVTValues -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -KVTValues -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/bedrockagent/generate.go b/internal/service/bedrockagent/generate.go index 29c572db9f0..70a30299319 100644 --- a/internal/service/bedrockagent/generate.go +++ b/internal/service/bedrockagent/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags // ONLY generate directives and package declaration! Do not add anything else to this file. package bedrockagent diff --git a/internal/service/cleanrooms/generate.go b/internal/service/cleanrooms/generate.go index 79fc142bcf5..6bb00e7962a 100644 --- a/internal/service/cleanrooms/generate.go +++ b/internal/service/cleanrooms/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -TagTypeKeyElem=key -TagTypeValElem=value -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -TagTypeKeyElem=key -TagTypeValElem=value -KVTValues // ONLY generate directives and package declaration! Do not add anything else to this file. package cleanrooms diff --git a/internal/service/codecommit/generate.go b/internal/service/codecommit/generate.go index a5f0753f0a4..aafefc554b7 100644 --- a/internal/service/codecommit/generate.go +++ b/internal/service/codecommit/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/codeguruprofiler/generate.go b/internal/service/codeguruprofiler/generate.go index 6a233d6abc8..cea5de7e181 100644 --- a/internal/service/codeguruprofiler/generate.go +++ b/internal/service/codeguruprofiler/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ServiceTagsMap -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ServiceTagsMap -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/codegurureviewer/generate.go b/internal/service/codegurureviewer/generate.go index dbcac81aee2..dbfd137d473 100644 --- a/internal/service/codegurureviewer/generate.go +++ b/internal/service/codegurureviewer/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ServiceTagsMap -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ServiceTagsMap -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/codestarnotifications/generate.go b/internal/service/codestarnotifications/generate.go index 946bcac96b9..e00952d2a1d 100644 --- a/internal/service/codestarnotifications/generate.go +++ b/internal/service/codestarnotifications/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ListTags -ListTagsInIDElem=Arn -ServiceTagsMap -TagInIDElem=Arn -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsInIDElem=Arn -ServiceTagsMap -TagInIDElem=Arn -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/cognitoidentity/generate.go b/internal/service/cognitoidentity/generate.go index 494ee456627..92cdc659b07 100644 --- a/internal/service/cognitoidentity/generate.go +++ b/internal/service/cognitoidentity/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/cognitoidp/generate.go b/internal/service/cognitoidp/generate.go index 4a165b72766..0d3b6c2fd9d 100644 --- a/internal/service/cognitoidp/generate.go +++ b/internal/service/cognitoidp/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -EmptyMap -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -EmptyMap //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/connect/generate.go b/internal/service/connect/generate.go index 5ba6a1a946c..d299385e171 100644 --- a/internal/service/connect/generate.go +++ b/internal/service/connect/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/controltower/generate.go b/internal/service/controltower/generate.go index 8b813c09ab2..92ea225db4e 100644 --- a/internal/service/controltower/generate.go +++ b/internal/service/controltower/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags // ONLY generate directives and package declaration! Do not add anything else to this file. package controltower diff --git a/internal/service/customerprofiles/generate.go b/internal/service/customerprofiles/generate.go index e201e7abbc2..7f120529356 100644 --- a/internal/service/customerprofiles/generate.go +++ b/internal/service/customerprofiles/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags // ONLY generate directives and package declaration! Do not add anything else to this file. package customerprofiles diff --git a/internal/service/databrew/generate.go b/internal/service/databrew/generate.go index 2271d61c6d5..7164c809170 100644 --- a/internal/service/databrew/generate.go +++ b/internal/service/databrew/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/dataexchange/generate.go b/internal/service/dataexchange/generate.go index 1757e938071..9bb7578a9f5 100644 --- a/internal/service/dataexchange/generate.go +++ b/internal/service/dataexchange/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/datazone/generate.go b/internal/service/datazone/generate.go index 8a86a527a15..1a8efc009a6 100644 --- a/internal/service/datazone/generate.go +++ b/internal/service/datazone/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/detective/generate.go b/internal/service/detective/generate.go index 3ae4db3a38d..1aa9bd0c11d 100644 --- a/internal/service/detective/generate.go +++ b/internal/service/detective/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/dlm/generate.go b/internal/service/dlm/generate.go index fb4ac48eac2..51eae31c27c 100644 --- a/internal/service/dlm/generate.go +++ b/internal/service/dlm/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/docdbelastic/generate.go b/internal/service/docdbelastic/generate.go index f5edc2bbe6d..e38908b0f7f 100644 --- a/internal/service/docdbelastic/generate.go +++ b/internal/service/docdbelastic/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ListTags -ListTagsInIDElem=ResourceArn -ListTagsOutTagsElem=Tags -ServiceTagsMap -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsInIDElem=ResourceArn -ListTagsOutTagsElem=Tags -ServiceTagsMap -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/drs/generate.go b/internal/service/drs/generate.go index cab07e753e4..6b9708a8ad4 100644 --- a/internal/service/drs/generate.go +++ b/internal/service/drs/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -SkipTypesImp -KVTValues -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -CreateTags -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -KVTValues -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -CreateTags -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/dynamodb/generate.go b/internal/service/dynamodb/generate.go index b6da2b2219a..75273d26077 100644 --- a/internal/service/dynamodb/generate.go +++ b/internal/service/dynamodb/generate.go @@ -3,7 +3,7 @@ //go:generate go run ../../generate/tagresource/main.go -UpdateTagsFunc=updateTagsResource //go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsOp=ListTagsOfResource -ServiceTagsSlice -UpdateTags -Wait -WaitContinuousOccurence 2 -WaitMinTimeout 1s -WaitTimeout 2m -ParentNotFoundErrCode=ResourceNotFoundException -CreateTags -//go:generate go run ../../generate/tags/main.go -SkipTypesImp -UpdateTags -UpdateTagsFunc=updateTagsResource -Wait -WaitFunc=waitTagsPropagedForResource -WaitContinuousOccurence 2 -WaitMinTimeout 1s -WaitTimeout 2m -WaitFuncComparator=ContainsAll -- update_tags_for_resource_gen.go +//go:generate go run ../../generate/tags/main.go -UpdateTags -UpdateTagsFunc=updateTagsResource -Wait -WaitFunc=waitTagsPropagedForResource -WaitContinuousOccurence 2 -WaitMinTimeout 1s -WaitTimeout 2m -WaitFuncComparator=ContainsAll -- update_tags_for_resource_gen.go //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/listpages/main.go -ListOps=ListBackups -InputPaginator=ExclusiveStartBackupArn -OutputPaginator=LastEvaluatedBackupArn -- list_backups_pages_gen.go //go:generate go run ../../generate/tagstests/main.go diff --git a/internal/service/eks/generate.go b/internal/service/eks/generate.go index a649a67eae8..541cbf56238 100644 --- a/internal/service/eks/generate.go +++ b/internal/service/eks/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -KVTValues -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -KVTValues -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/emrcontainers/generate.go b/internal/service/emrcontainers/generate.go index d088da1ba83..0f62d3b114b 100644 --- a/internal/service/emrcontainers/generate.go +++ b/internal/service/emrcontainers/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/emrserverless/generate.go b/internal/service/emrserverless/generate.go index ef786af2fea..823c35a75f2 100644 --- a/internal/service/emrserverless/generate.go +++ b/internal/service/emrserverless/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/evidently/generate.go b/internal/service/evidently/generate.go index 6a24b4876e7..e43db9b92f0 100644 --- a/internal/service/evidently/generate.go +++ b/internal/service/evidently/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/finspace/generate.go b/internal/service/finspace/generate.go index 6761a483bbf..bcc2da69a48 100644 --- a/internal/service/finspace/generate.go +++ b/internal/service/finspace/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -CreateTags -UpdateTags -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -CreateTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/fis/generate.go b/internal/service/fis/generate.go index 7b1d2b05c92..c4142655fef 100644 --- a/internal/service/fis/generate.go +++ b/internal/service/fis/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/glacier/generate.go b/internal/service/glacier/generate.go index 63d9c9afec9..97e7b9561d5 100644 --- a/internal/service/glacier/generate.go +++ b/internal/service/glacier/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTagsForVault -ListTagsInIDElem=VaultName -ServiceTagsMap -KVTValues -TagOp=AddTagsToVault -TagInIDElem=VaultName -UntagOp=RemoveTagsFromVault -UpdateTags -CreateTags -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTagsForVault -ListTagsInIDElem=VaultName -ServiceTagsMap -KVTValues -TagOp=AddTagsToVault -TagInIDElem=VaultName -UntagOp=RemoveTagsFromVault -UpdateTags -CreateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/glue/generate.go b/internal/service/glue/generate.go index 4de82c59d5f..54bfad117c3 100644 --- a/internal/service/glue/generate.go +++ b/internal/service/glue/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsOp=GetTags -ServiceTagsMap -SkipTypesImp -TagInTagsElem=TagsToAdd -UntagInTagsElem=TagsToRemove -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsOp=GetTags -ServiceTagsMap -TagInTagsElem=TagsToAdd -UntagInTagsElem=TagsToRemove -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/grafana/generate.go b/internal/service/grafana/generate.go index 8247c0b64ef..bc4de33ee2e 100644 --- a/internal/service/grafana/generate.go +++ b/internal/service/grafana/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/greengrass/generate.go b/internal/service/greengrass/generate.go index 5d86f2b8c2a..3c5bb4ef763 100644 --- a/internal/service/greengrass/generate.go +++ b/internal/service/greengrass/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/guardduty/generate.go b/internal/service/guardduty/generate.go index c4dbd0a3db6..1af1692c5e8 100644 --- a/internal/service/guardduty/generate.go +++ b/internal/service/guardduty/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/healthlake/generate.go b/internal/service/healthlake/generate.go index 94d72f01b76..880ff4bcd07 100644 --- a/internal/service/healthlake/generate.go +++ b/internal/service/healthlake/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues=true -SkipTypesImp=false -TagInIDElem=ResourceARN -ListTagsInIDElem=ResourceARN -ListTags -ServiceTagsSlice -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues=true=false -TagInIDElem=ResourceARN -ListTagsInIDElem=ResourceARN -ListTags -ServiceTagsSlice -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/imagebuilder/generate.go b/internal/service/imagebuilder/generate.go index 27461940de7..3284c260b80 100644 --- a/internal/service/imagebuilder/generate.go +++ b/internal/service/imagebuilder/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -KVTValues -ServiceTagsMap -UpdateTags -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -KVTValues -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/internetmonitor/generate.go b/internal/service/internetmonitor/generate.go index c868fe16cf6..2f46025c970 100644 --- a/internal/service/internetmonitor/generate.go +++ b/internal/service/internetmonitor/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -KVTValues -TagInIDElem=ResourceArn -UpdateTags -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -KVTValues -TagInIDElem=ResourceArn -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/ivs/generate.go b/internal/service/ivs/generate.go index 426e563ec6e..af15398659c 100644 --- a/internal/service/ivs/generate.go +++ b/internal/service/ivs/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/ivschat/generate.go b/internal/service/ivschat/generate.go index 4585ce32871..0bcf935ada2 100644 --- a/internal/service/ivschat/generate.go +++ b/internal/service/ivschat/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/kafka/generate.go b/internal/service/kafka/generate.go index eedaef5324a..0d3f1d43ee1 100644 --- a/internal/service/kafka/generate.go +++ b/internal/service/kafka/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -ServiceTagsMap -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -ServiceTagsMap -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/kafkaconnect/generate.go b/internal/service/kafkaconnect/generate.go index 9a65ed35110..b542438ee5f 100644 --- a/internal/service/kafkaconnect/generate.go +++ b/internal/service/kafkaconnect/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -ListTags -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -ListTags -UpdateTags -KVTValues // ONLY generate directives and package declaration! Do not add anything else to this file. package kafkaconnect diff --git a/internal/service/kinesisvideo/generate.go b/internal/service/kinesisvideo/generate.go index c656dc305d0..6a0d52dfa3e 100644 --- a/internal/service/kinesisvideo/generate.go +++ b/internal/service/kinesisvideo/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsOp=ListTagsForStream -ListTagsInIDElem=StreamARN -ServiceTagsMap -SkipTypesImp -TagOp=TagStream -TagInIDElem=StreamARN -UntagOp=UntagStream -UntagInTagsElem=TagKeyList -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ListTagsOp=ListTagsForStream -ListTagsInIDElem=StreamARN -ServiceTagsMap -TagOp=TagStream -TagInIDElem=StreamARN -UntagOp=UntagStream -UntagInTagsElem=TagKeyList -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/lambda/generate.go b/internal/service/lambda/generate.go index 43f8fffda22..ac5d23a89d0 100644 --- a/internal/service/lambda/generate.go +++ b/internal/service/lambda/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -TagInIDElem=Resource -UpdateTags -ListTags -ListTagsInIDElem=Resource -ListTagsOp=ListTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -TagInIDElem=Resource -UpdateTags -ListTags -ListTagsInIDElem=Resource -ListTagsOp=ListTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/lexv2models/generate.go b/internal/service/lexv2models/generate.go index 22c1226ac63..0435558adee 100644 --- a/internal/service/lexv2models/generate.go +++ b/internal/service/lexv2models/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -TagInIDElem=ResourceARN -ListTagsInIDElem=ResourceARN -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -TagInIDElem=ResourceARN -ListTagsInIDElem=ResourceARN -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/location/generate.go b/internal/service/location/generate.go index f06e74e7b43..e53c30aaa4c 100644 --- a/internal/service/location/generate.go +++ b/internal/service/location/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -ListTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -ListTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/logs/generate.go b/internal/service/logs/generate.go index 54dfe45c4c1..e4084aad6d5 100644 --- a/internal/service/logs/generate.go +++ b/internal/service/logs/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -CreateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -CreateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/lookoutmetrics/generate.go b/internal/service/lookoutmetrics/generate.go index 39c6409b753..0402f2f2e72 100644 --- a/internal/service/lookoutmetrics/generate.go +++ b/internal/service/lookoutmetrics/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/m2/generate.go b/internal/service/m2/generate.go index 5898011c394..464291f8890 100644 --- a/internal/service/m2/generate.go +++ b/internal/service/m2/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file diff --git a/internal/service/mediaconnect/generate.go b/internal/service/mediaconnect/generate.go index 1398020d278..7696178287d 100644 --- a/internal/service/mediaconnect/generate.go +++ b/internal/service/mediaconnect/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/mediaconvert/generate.go b/internal/service/mediaconvert/generate.go index 685f9c9d4a0..5c0b19990c6 100644 --- a/internal/service/mediaconvert/generate.go +++ b/internal/service/mediaconvert/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=Arn -ListTagsOutTagsElem=ResourceTags.Tags -ServiceTagsMap -TagInIDElem=Arn -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=Arn -ListTagsOutTagsElem=ResourceTags.Tags -ServiceTagsMap -TagInIDElem=Arn -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/medialive/generate.go b/internal/service/medialive/generate.go index 06e5e2e9088..3ff6e664ffe 100644 --- a/internal/service/medialive/generate.go +++ b/internal/service/medialive/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues=true -SkipTypesImp=true -ListTags -ServiceTagsMap -TagOp=CreateTags -UntagOp=DeleteTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues=true=true -ListTags -ServiceTagsMap -TagOp=CreateTags -UntagOp=DeleteTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/mediapackage/generate.go b/internal/service/mediapackage/generate.go index 500816c3740..c43ad0438cc 100644 --- a/internal/service/mediapackage/generate.go +++ b/internal/service/mediapackage/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -SkipTypesImp=true -KVTValues -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go=true -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/mq/generate.go b/internal/service/mq/generate.go index 71351b6fdb3..ecb6597c328 100644 --- a/internal/service/mq/generate.go +++ b/internal/service/mq/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ServiceTagsMap -TagOp=CreateTags -UntagOp=DeleteTags -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ServiceTagsMap -TagOp=CreateTags -UntagOp=DeleteTags -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/mwaa/generate.go b/internal/service/mwaa/generate.go index ee8020761d5..038c158cdac 100644 --- a/internal/service/mwaa/generate.go +++ b/internal/service/mwaa/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -SkipTypesImp -KVTValues -ListTagsOp=ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTagsOp=ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/networkmonitor/generate.go b/internal/service/networkmonitor/generate.go index 896c7d48382..85bf6ad2758 100644 --- a/internal/service/networkmonitor/generate.go +++ b/internal/service/networkmonitor/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ServiceTagsMap -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ServiceTagsMap -ListTags -UpdateTags //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/oam/generate.go b/internal/service/oam/generate.go index 9a1df3b64e0..fda19e241d8 100644 --- a/internal/service/oam/generate.go +++ b/internal/service/oam/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues=true -SkipTypesImp=true -ListTags -ServiceTagsMap -TagOp=TagResource -UntagOp=UntagResource -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues=true=true -ListTags -ServiceTagsMap -TagOp=TagResource -UntagOp=UntagResource -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/opsworks/generate.go b/internal/service/opsworks/generate.go index 08569d8e190..507c03ec69d 100644 --- a/internal/service/opsworks/generate.go +++ b/internal/service/opsworks/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ServiceTagsMap -UpdateTags -CreateTags -SkipTypesImp -KVTValues +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ServiceTagsMap -UpdateTags -CreateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/outposts/generate.go b/internal/service/outposts/generate.go index 1bc980cf584..d6bbdb333e8 100644 --- a/internal/service/outposts/generate.go +++ b/internal/service/outposts/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/pipes/generate.go b/internal/service/pipes/generate.go index 513fb6f7262..3d0e78121b6 100644 --- a/internal/service/pipes/generate.go +++ b/internal/service/pipes/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -UpdateTags -ServiceTagsMap -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -UpdateTags -ServiceTagsMap -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/qldb/generate.go b/internal/service/qldb/generate.go index 711a6d3a249..16df87b665a 100644 --- a/internal/service/qldb/generate.go +++ b/internal/service/qldb/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/rekognition/generate.go b/internal/service/rekognition/generate.go index 098e28a2d0b..1615cbed3ce 100644 --- a/internal/service/rekognition/generate.go +++ b/internal/service/rekognition/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags // ONLY generate directives and package declaration! Do not add anything else to this file. package rekognition diff --git a/internal/service/resiliencehub/generate.go b/internal/service/resiliencehub/generate.go index 71027572c7b..a1f87363989 100644 --- a/internal/service/resiliencehub/generate.go +++ b/internal/service/resiliencehub/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -ListTagsInIDElem=ResourceArn -ListTagsOutTagsElem=Tags -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -ListTagsInIDElem=ResourceArn -ListTagsOutTagsElem=Tags -TagOp=TagResource -TagInIDElem=ResourceArn -UntagOp=UntagResource -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/resourceexplorer2/generate.go b/internal/service/resourceexplorer2/generate.go index 36e88177251..0ceca13b507 100644 --- a/internal/service/resourceexplorer2/generate.go +++ b/internal/service/resourceexplorer2/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -TagInIDElem=ResourceArn -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -UpdateTags -UntagInTagsElem=TagKeys -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -TagInIDElem=ResourceArn -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -UpdateTags -UntagInTagsElem=TagKeys -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/resourcegroups/generate.go b/internal/service/resourcegroups/generate.go index 773f9d6de9b..630c1c778f6 100644 --- a/internal/service/resourcegroups/generate.go +++ b/internal/service/resourcegroups/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=GetTags -ListTagsInIDElem=Arn -ServiceTagsMap -TagOp=Tag -TagInIDElem=Arn -UntagOp=Untag -UntagInTagsElem=Keys -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=GetTags -ListTagsInIDElem=Arn -ServiceTagsMap -TagOp=Tag -TagInIDElem=Arn -UntagOp=Untag -UntagInTagsElem=Keys -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/route53profiles/generate.go b/internal/service/route53profiles/generate.go index 0ca90ce6fd8..f3ad4608bce 100644 --- a/internal/service/route53profiles/generate.go +++ b/internal/service/route53profiles/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -KVTValues -UpdateTags -TagInIDElem=ResourceArn -ServiceTagsMap -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceArn -KVTValues -UpdateTags -TagInIDElem=ResourceArn -ServiceTagsMap //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/route53recoveryreadiness/generate.go b/internal/service/route53recoveryreadiness/generate.go index 943601d42ff..8628d762292 100644 --- a/internal/service/route53recoveryreadiness/generate.go +++ b/internal/service/route53recoveryreadiness/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTagsForResources -UpdateTags -CreateTags -ServiceTagsMap -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTagsForResources -UpdateTags -CreateTags -ServiceTagsMap -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/rum/generate.go b/internal/service/rum/generate.go index 740672b6ba9..da2e2285578 100644 --- a/internal/service/rum/generate.go +++ b/internal/service/rum/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues -ServiceTagsMap -SkipTypesImp -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/schemas/generate.go b/internal/service/schemas/generate.go index 9ee68f70bf0..12e910495a6 100644 --- a/internal/service/schemas/generate.go +++ b/internal/service/schemas/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/securityhub/generate.go b/internal/service/securityhub/generate.go index 2341c020cad..9dfc8e40d91 100644 --- a/internal/service/securityhub/generate.go +++ b/internal/service/securityhub/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues=true -SkipTypesImp=true +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues=true=true //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/servicecatalogappregistry/generate.go b/internal/service/servicecatalogappregistry/generate.go index 8d958208b74..76ced48a433 100644 --- a/internal/service/servicecatalogappregistry/generate.go +++ b/internal/service/servicecatalogappregistry/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/signer/generate.go b/internal/service/signer/generate.go index 9c5b80e2515..2c46d5a52d1 100644 --- a/internal/service/signer/generate.go +++ b/internal/service/signer/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -SkipTypesImp -KVTValues -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/sqs/generate.go b/internal/service/sqs/generate.go index 0b0bd7f55e7..0de929a5427 100644 --- a/internal/service/sqs/generate.go +++ b/internal/service/sqs/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -SkipTypesImp -ListTags -ListTagsOp=ListQueueTags -ListTagsInIDElem=QueueUrl -ServiceTagsMap -KVTValues -TagOp=TagQueue -TagInIDElem=QueueUrl -UntagOp=UntagQueue -UpdateTags -CreateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListQueueTags -ListTagsInIDElem=QueueUrl -ServiceTagsMap -KVTValues -TagOp=TagQueue -TagInIDElem=QueueUrl -UntagOp=UntagQueue -UpdateTags -CreateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/ssmincidents/generate.go b/internal/service/ssmincidents/generate.go index c3afb956fbe..7545df702f0 100644 --- a/internal/service/ssmincidents/generate.go +++ b/internal/service/ssmincidents/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -TagInIDElem=ResourceArn -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -TagInIDElem=ResourceArn -ListTags -ListTagsInIDElem=ResourceArn -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/synthetics/generate.go b/internal/service/synthetics/generate.go index db558362384..3e3012d0252 100644 --- a/internal/service/synthetics/generate.go +++ b/internal/service/synthetics/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/timestreaminfluxdb/generate.go b/internal/service/timestreaminfluxdb/generate.go index 3aa165d1069..4a9afcb9b75 100644 --- a/internal/service/timestreaminfluxdb/generate.go +++ b/internal/service/timestreaminfluxdb/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/servicepackage/main.go -//go:generate go run ../../generate/tags/main.go -KVTValues -SkipTypesImp -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/transfer/generate.go b/internal/service/transfer/generate.go index 2451b0c2294..f9b31221605 100644 --- a/internal/service/transfer/generate.go +++ b/internal/service/transfer/generate.go @@ -3,7 +3,7 @@ //go:generate go run ../../generate/tagresource/main.go -UpdateTagsFunc=updateTagsNoIgnoreSystem //go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsInIDElem=Arn -ServiceTagsSlice -TagInIDElem=Arn -UpdateTags -//go:generate go run ../../generate/tags/main.go -TagInIDElem=Arn -UpdateTags -UpdateTagsFunc=updateTagsNoIgnoreSystem -UpdateTagsNoIgnoreSystem -SkipTypesImp -- update_tags_no_system_ignore_gen.go +//go:generate go run ../../generate/tags/main.go -TagInIDElem=Arn -UpdateTags -UpdateTagsFunc=updateTagsNoIgnoreSystem -UpdateTagsNoIgnoreSystem -- update_tags_no_system_ignore_gen.go //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/vpclattice/generate.go b/internal/service/vpclattice/generate.go index ff4a34d972c..e80095fd3e7 100644 --- a/internal/service/vpclattice/generate.go +++ b/internal/service/vpclattice/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -SkipTypesImp -ListTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -KVTValues -ListTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/wellarchitected/generate.go b/internal/service/wellarchitected/generate.go index 237ee94ddbb..8debe88c92e 100644 --- a/internal/service/wellarchitected/generate.go +++ b/internal/service/wellarchitected/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=WorkloadArn -UpdateTags -TagInIDElem=WorkloadArn -ServiceTagsMap -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=WorkloadArn -UpdateTags -TagInIDElem=WorkloadArn -ServiceTagsMap -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/worklink/generate.go b/internal/service/worklink/generate.go index a7de5999101..b7039c6a114 100644 --- a/internal/service/worklink/generate.go +++ b/internal/service/worklink/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From 7062cec467ea949a1b6974cfeb8bdc0ee467c3c3 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 10:49:35 -0400 Subject: [PATCH 09/24] internal/generate/tags: Remove Go package inclusion logic. --- internal/generate/tags/main.go | 18 ----------- .../generate/tags/templates/header_body.gtpl | 30 ------------------- 2 files changed, 48 deletions(-) diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index 6dd3da8cb6c..e4ac220f17d 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -89,10 +89,6 @@ var ( sdkServicePackage = flag.String("AWSSDKServicePackage", "", "AWS Go SDK package to use. Defaults to the provider service package name.") kvtValues = flag.Bool("KVTValues", false, "Whether KVT string map is of string pointers") emptyMap = flag.Bool("EmptyMap", false, "Whether KVT string map should be empty for no tags") - skipAWSImp = flag.Bool("SkipAWSImp", false, "Whether to skip importing the AWS Go SDK aws package") // nosemgrep:ci.aws-in-var-name - skipNamesImp = flag.Bool("SkipNamesImp", false, "Whether to skip importing names") - skipServiceImp = flag.Bool("SkipAWSServiceImp", false, "Whether to skip importing the AWS service package") - skipTypesImp = flag.Bool("SkipTypesImp", false, "Whether to skip importing types") ) func usage() { @@ -270,20 +266,6 @@ func main() { ProviderNameUpper: providerNameUpper, ServicePackage: servicePackage, - ConnsPkg: (*listTags && *listTagsFunc == defaultListTagsFunc) || (*updateTags && *updateTagsFunc == defaultUpdateTagsFunc), - FmtPkg: *updateTags, - HelperSchemaPkg: awsPkg == "autoscaling", - InternalOptionPkg: (*listTags && *listTagsFunc == defaultListTagsFunc) || *serviceTagsMap || *serviceTagsSlice, - LoggingPkg: *updateTags, - NamesPkg: *updateTags && !*skipNamesImp, - SkipAWSImp: *skipAWSImp, - SkipServiceImp: *skipServiceImp, - SkipTypesImp: *skipTypesImp, - TfLogPkg: *updateTags, - TfResourcePkg: *getTag || *waitForPropagation || *retryTagsListTagsType != "", - TfSlicesPkg: *serviceTagsSlice && *tagTypeIDElem != "" && *tagTypeAddBoolElem != "", - TimePkg: *waitForPropagation || *retryTagsListTagsType != "", - CreateTagsFunc: createTagsFunc, EmptyMap: *emptyMap, GetTagFunc: *getTagFunc, diff --git a/internal/generate/tags/templates/header_body.gtpl b/internal/generate/tags/templates/header_body.gtpl index d71d6231e65..5b0770af4a2 100644 --- a/internal/generate/tags/templates/header_body.gtpl +++ b/internal/generate/tags/templates/header_body.gtpl @@ -3,51 +3,21 @@ package {{ .ServicePackage }} import ( "context" - {{- if .FmtPkg }} "fmt" - {{- end }} - {{- if .TimePkg }} "time" - {{- end }} - {{ if not .SkipAWSImp }} "github.com/aws/aws-sdk-go-v2/aws" - {{- end }} tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - {{- if .AWSService }} - {{- if not .SkipServiceImp }} "github.com/aws/aws-sdk-go-v2/service/{{ .AWSService }}" - {{- end }} - {{- if not .SkipTypesImp }} awstypes "github.com/aws/aws-sdk-go-v2/service/{{ .AWSService }}/types" - {{- end }} - {{- end }} - {{- if .HelperSchemaPkg }} "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - {{- end }} - {{- if .ParentNotFoundErrCode }} "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - {{- end }} - {{- if .TfLogPkg }} "github.com/hashicorp/terraform-plugin-log/tflog" - {{- end }} - {{- if .ConnsPkg }} "github.com/hashicorp/terraform-provider-aws/internal/conns" - {{- end }} - {{- if .LoggingPkg }} "github.com/hashicorp/terraform-provider-aws/internal/logging" - {{- end }} - {{- if .TfSlicesPkg }} tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" - {{- end }} - {{- if .TfResourcePkg }} "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - {{- end }} - {{- if .InternalOptionPkg }} "github.com/hashicorp/terraform-provider-aws/internal/types/option" - {{- end }} - {{- if .NamesPkg }} "github.com/hashicorp/terraform-provider-aws/names" - {{- end }} ) From 2fb328cd4b3f63bcc26eb6f53937de4ca8e0390b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 11:03:41 -0400 Subject: [PATCH 10/24] Fix typos. --- internal/service/healthlake/generate.go | 2 +- internal/service/medialive/generate.go | 2 +- internal/service/oam/generate.go | 2 +- internal/service/securityhub/generate.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/healthlake/generate.go b/internal/service/healthlake/generate.go index 880ff4bcd07..8805ca992ac 100644 --- a/internal/service/healthlake/generate.go +++ b/internal/service/healthlake/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues=true=false -TagInIDElem=ResourceARN -ListTagsInIDElem=ResourceARN -ListTags -ServiceTagsSlice -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues=true -TagInIDElem=ResourceARN -ListTagsInIDElem=ResourceARN -ListTags -ServiceTagsSlice -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/medialive/generate.go b/internal/service/medialive/generate.go index 3ff6e664ffe..dc7e9ed075b 100644 --- a/internal/service/medialive/generate.go +++ b/internal/service/medialive/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues=true=true -ListTags -ServiceTagsMap -TagOp=CreateTags -UntagOp=DeleteTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues=true -ListTags -ServiceTagsMap -TagOp=CreateTags -UntagOp=DeleteTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/oam/generate.go b/internal/service/oam/generate.go index fda19e241d8..582949bd54c 100644 --- a/internal/service/oam/generate.go +++ b/internal/service/oam/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -KVTValues=true=true -ListTags -ServiceTagsMap -TagOp=TagResource -UntagOp=UntagResource -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues=true -ListTags -ServiceTagsMap -TagOp=TagResource -UntagOp=UntagResource -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/securityhub/generate.go b/internal/service/securityhub/generate.go index 9dfc8e40d91..caf2cf0d79e 100644 --- a/internal/service/securityhub/generate.go +++ b/internal/service/securityhub/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues=true=true +//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags -KVTValues=true //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From 620b5ed2cde8ab6f157b2921d04a4a3f235d7891 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 11:11:33 -0400 Subject: [PATCH 11/24] internal/generate/tags: Start to update documentation. --- docs/resource-tagging.md | 10 - internal/generate/tags/README.md | 1 - internal/generate/tags/README_keyvaluetags.md | 34 --- internal/generate/tags/README_listtags.md | 106 --------- internal/generate/tags/README_servicetags.md | 123 ---------- internal/generate/tags/README_updatetags.md | 216 ------------------ 6 files changed, 490 deletions(-) delete mode 100644 internal/generate/tags/README_keyvaluetags.md delete mode 100644 internal/generate/tags/README_listtags.md delete mode 100644 internal/generate/tags/README_servicetags.md delete mode 100644 internal/generate/tags/README_updatetags.md diff --git a/docs/resource-tagging.md b/docs/resource-tagging.md index 2b2e3ef1d02..3bf249e6b7d 100644 --- a/docs/resource-tagging.md +++ b/docs/resource-tagging.md @@ -112,16 +112,6 @@ For more details on flags for generating tag updating functions, see the When creating a resource, some AWS APIs support passing tags in the Create call while others require setting the tags after the initial creation. If the API does not support tagging on creation, pass the `-CreateTags` flag to generate a `createTags` function that can be called from the resource Create handler function. -### Specifying the AWS SDK for Go version - -The majority of the Terraform AWS Provider is implemented using [version 2 of the AWS SDK for Go](https://github.com/aws/aws-sdk-go-v2). -Some services, however, are only present in [version 1 of the SDK](https://github.com/aws/aws-sdk-go). - -By default, the generated code uses the AWS SDK for Go v2. -To generate code using the AWS SDK for Go v1, pass the flag `-AwsSdkVersion=1`. - -For more information, see the [documentation on AWS SDK versions](./aws-go-sdk-versions.md). - ### Running Code generation Run the command `make gen` to run the code generators for the project. diff --git a/internal/generate/tags/README.md b/internal/generate/tags/README.md index e8c8e84093d..b771f23cf11 100644 --- a/internal/generate/tags/README.md +++ b/internal/generate/tags/README.md @@ -27,7 +27,6 @@ Some flags control generation a certain section of code, such as whether the gen | `ServiceTagsMap` | | Whether to generate map service tags (use this or `ServiceTagsSlice`, not both) | `-ServiceTagsMap` | | `ServiceTagsSlice` | | Whether to generate slice service tags (use this or `ServiceTagsMap`, not both) | `-ServiceTagsSlice` | | `UpdateTags` | | Whether to generate UpdateTags | `-UpdateTags` | -| `ContextOnly` | | Whether to generator only Context-aware functions | `-ContextOnly` | | `ListTagsInFiltIDName` | | List tags input filter identifier name | `-ListTagsInFiltIDName=resource-id` | | `ListTagsInIDElem` | `ResourceArn` | List tags input identifier element | `-ListTagsInIDElem=ResourceARN` | | `ListTagsInIDNeedSlice` | | Whether list tags input identifier needs a slice | `-ListTagsInIDNeedSlice=yes` | diff --git a/internal/generate/tags/README_keyvaluetags.md b/internal/generate/tags/README_keyvaluetags.md deleted file mode 100644 index d54d8cc18b9..00000000000 --- a/internal/generate/tags/README_keyvaluetags.md +++ /dev/null @@ -1,34 +0,0 @@ -# keyvaluetags - -The `keyvaluetags` package is designed to provide a consistent interface for handling AWS resource key-value tags. Many of the AWS Go SDK services, implement their own Go struct with `Key` and `Value` fields (e.g. `athena.Tag`) while others simply use a map (e.g. `map[string]string`). These inconsistent implementations and numerous Go types makes the process of correctly working with each of the services a tedius, previously copy-paste-modify process. - -This package instead implements a single `KeyValueTags` type, which covers all key-value handling logic such as merging tags and ignoring keys via functions on the single type. The underlying implementation is compatible with Go operations such as `len()`. - -Full documentation for this package can be found on [GoDoc](https://godoc.org/github.com/hashicorp/terraform-provider-aws/aws/internal/keyvaluetags). - -Many AWS Go SDK services that support tagging have their service-specific Go type conversion functions to and from `KeyValueTags` code generated. Converting from `KeyValueTags` to AWS Go SDK types is done via `{SERVICE}Tags()` functions on the type, while converting from AWS Go SDK types to the `KeyValueTags` type is done via `{SERVICE}KeyValueTags()` functions. For more information about this code generation, see the [`generators/servicetags` README](generators/servicetags/README.md). - -Some AWS Go SDK services that have common tag listing functionality (such as `ListTagsForResource` API call), also have auto-generated list functions. For more information about this code generation, see the [`generators/listtags` README](generators/listtags/README.md). - -Some AWS Go SDK services that have common tagging update functionality (such as `TagResource` and `UntagResource` API calls), also have auto-generated update functions. For more information about this code generation, see the [`generators/updatetags` README](generators/updatetags/README.md). - -Any tagging functions that cannot be generated should be hand implemented in a service-specific source file (e.g. `iam_tags.go`) and follow the format of similar generated code wherever possible. The first line of the source file should be `// +build !generate`. This prevents the file's inclusion during the code generation phase. - -## Code Structure - -```text -aws/internal/keyvaluetags -├── generators -│ ├── createtags (generates create_tags_gen.go) -│ ├── gettag (generates get_tag_gen.go) -│ ├── listtags (generates list_tags_gen.go) -│ ├── servicetags (generates service_tags_gen.go) -│ └── updatetags (generates update_tags_gen.go) -├── key_value_tags_test.go (unit tests for core logic) -├── key_value_tags.go (core logic) -├── list_tags_gen.go (generated AWS Go SDK service list tag functions) -├── service_generation_customizations.go (shared AWS Go SDK service customizations for generators) -├── service_tags_gen.go (generated AWS Go SDK service conversion functions) -├── update_tags_gen.go (generated AWS Go SDK service tagging update functions) -└── _tags.go (any service-specific functions that cannot be generated) -``` diff --git a/internal/generate/tags/README_listtags.md b/internal/generate/tags/README_listtags.md deleted file mode 100644 index 81ea0ecc6cb..00000000000 --- a/internal/generate/tags/README_listtags.md +++ /dev/null @@ -1,106 +0,0 @@ -# listtags - -This package contains a code generator to consistently handle the various AWS Go SDK service implementations for listing resource tags. Not all AWS Go SDK services that support tagging are generated in this manner. - -To run this code generator, execute `go generate ./...` from the root of the repository. The general workflow for the generator is: - -- Generate Go file contents via template from local variables and functions -- Go format file contents -- Write file contents to `list_tags_gen.go` file - -## Example Output - -```go -// AmplifyListTags lists amplify service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func AmplifyListTags(conn *amplify.Amplify, identifier string) (KeyValueTags, error) { - input := &lify.ListTagsForResourceInput{ - ResourceArn: aws.String(identifier), - } - - output, err := conn.ListTagsForResource(input) - - if err != nil { - return New(nil), err - } - - return AmplifyKeyValueTags(output.Tags), nil -} -``` - -## Implementing a New Generated Service - -### Requirements - -Before a new service can be added to the generator, the new service must: - -- Have the `KeyValueTags` conversion functions implemented for the AWS Go SDK service type/map. See also the [`servicetags` generator README](../servicetags/README.md). -- Implement a function for listing resource tags (e.g. `ListTagsforResource`) -- Have the service included in `aws/internal/keyvaluetags/service_generation_customizations.go`, if not present the following compilation error will be seen: - -```text -2019/09/03 09:22:21 error executing template: template: listtags:19:41: executing "listtags" at : error calling ClientType: unrecognized ServiceClientType: acmpca -``` - -Once the service has met all the requirements, in `main.go`: - -- Add import for new service, e.g. `"github.com/aws/aws-sdk-go/service/athena"` -- Add service name to `serviceNames`, e.g. `athena` -- Run `go generate ./...` (or `make gen`) from the root of the repository to regenerate the code -- Run `go test ./...` (or `make test`) from the root of the repository to ensure the generated code compiles -- (Optional) Customize the service generation, if necessary (see below) - -### Customizations - -By default, the generator creates a `{SERVICE}ListTags()` function with the following structs and function calls: - -- `{SERVICE}.ListTagsForResourceInput` struct with `ResourceArn` field for calling `ListTagsForResource()` API call - -If these do not match the actual AWS Go SDK service implementation, the generated code will compile with errors. See the sections below for certain errors and how to handle them. - -#### ServiceListTagsFunction - -Given the following compilation error: - -```text -./list_tags_gen.go:183:12: undefined: backup.ListTagsForResourceInput -./list_tags_gen.go:187:21: conn.ListTagsForResource undefined (type *backup.Backup has no field or method ListTagsForResource) -``` - -The function for listing resource tags must be updated. Add an entry within the `ServiceListTagsFunction()` function of the generator to customize the naming of the `ListTagsForResource()` function and matching `ListTagsForResourceInput` struct. In the above case: - -```go -case "backup": - return "ListTags" -``` - -#### ServiceListTagsInputIdentifierField - -Given the following compilation error: - -```text -./list_tags_gen.go:1118:3: unknown field 'ResourceArn' in struct literal of type transfer.ListTagsForResourceInput -``` - -The field name to identify the resource for tag listing must be updated. Add an entry within the `ServiceListTagsInputIdentifierField()` function of the generator to customize the naming of the `ResourceArn` field for the list tags input struct. In the above case: - -```go -case "transfer": - return "Arn" -``` - -#### ServiceListTagsOutputTagsField - -Given the following compilation error: - -```text -./list_tags_gen.go:206:38: output.Tags undefined (type *cloudhsmv2.ListTagsOutput has no field or method Tags) -``` - -The field name of the tags from the tag listing must be updated. Add an entry within the `ServiceListTagsOutputTagsField()` function of the generator to customize the naming of the `Tags` field for the list tags output struct. In the above case: - -```go -case "cloudhsmv2": - return "TagList" -``` diff --git a/internal/generate/tags/README_servicetags.md b/internal/generate/tags/README_servicetags.md deleted file mode 100644 index 58c43d49e81..00000000000 --- a/internal/generate/tags/README_servicetags.md +++ /dev/null @@ -1,123 +0,0 @@ -# servicetags - -This package contains a code generator to consistently handle the various AWS Go SDK service implementations for converting service tag/map types to/from `KeyValueTags`. Not all AWS Go SDK services that support tagging are generated in this manner. - -To run this code generator, execute `go generate ./...` from the root of the repository. The general workflow for the generator is: - -- Generate Go file contents via template from local variables and functions -- Go format file contents -- Write file contents to `service_tags_gen.go` file - -## Example Output - -For services with a specific Go type: - -```go -// AthenaTags returns athena service tags. -func (tags KeyValueTags) AthenaTags() []*athena.Tag { - result := make([]*athena.Tag, 0, len(tags)) - - for k, v := range tags.Map() { - tag := &athena.Tag{ - Key: aws.String(k), - Value: aws.String(v), - } - - result = append(result, tag) - } - - return result -} - -// AthenaKeyValueTags creates KeyValueTags from athena service tags. -func AthenaKeyValueTags(tags []*athena.Tag) KeyValueTags { - m := make(map[string]*string, len(tags)) - - for _, tag := range tags { - m[aws.StringValue(tag.Key)] = tag.Value - } - - return New(m) -} -``` - -For services that implement a map instead: - -```go -// AmplifyTags returns amplify service tags. -func (tags KeyValueTags) AmplifyTags() map[string]*string { - return aws.StringMap(tags.Map()) -} - -// AmplifyKeyValueTags creates KeyValueTags from amplify service tags. -func AmplifyKeyValueTags(tags map[string]*string) KeyValueTags { - return New(tags) -} -``` - -## Implementing a New Generated Service - -- In `main.go`: Add service name, e.g. `athena`, to one of the implementation handlers - - Use `sliceServiceNames` if the AWS Go SDK service implements a specific Go type such as `Tag` - - Use `mapServiceNames` if the AWS Go SDK service implements `map[string]*string` -- Run `go generate ./...` (or `make gen`) from the root of the repository to regenerate the code -- Run `go test ./...` (or `make test`) from the root of the repository to ensure the generated code compiles -- (Optional, only for services with a specific Go type such as `Tag`) Customize the service generation, if necessary (see below) - -### Customizations - -By default, the generator creates `KeyValueTags.{SERVICE}Tags()` and `{SERVICE}KeyValueTags()` functions with the following expectations: - -- `Tag` struct with `Key` field and `Value` field - -If these do not match the actual AWS Go SDK service implementation, the generated code will compile with errors. See the sections below for certain errors and how to handle them. - -#### ServiceTagType - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/service_tags_gen.go:397:43: undefined: appmesh.Tag -aws/internal/keyvaluetags/service_tags_gen.go:398:20: undefined: appmesh.Tag -aws/internal/keyvaluetags/service_tags_gen.go:401:11: undefined: appmesh.Tag -aws/internal/keyvaluetags/service_tags_gen.go:413:34: undefined: appmesh.Tag -``` - -The Go type that represents a tag must be updated. Add an entry within the `ServiceTagType()` function of the generator to customize the naming of the Go type. In the above case: - -```go -case "appmesh": - return "TagRef" -``` - -#### ServiceTagTypeKeyField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/service_tags_gen.go:1563:4: unknown field 'Key' in struct literal of type kms.Tag -aws/internal/keyvaluetags/service_tags_gen.go:1578:24: tag.Key undefined (type *kms.Tag has no field or method Key) -``` - -The field name to identify the tag key within the Go type for tagging must be updated. Add an entry within the `ServiceTagTypeKeyField` function of the generator to customize the naming of the `Key` field for the tagging Go type. In the above case: - -```go -case "kms": - return "TagKey" -``` - -#### ServiceTagTypeValueField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/service_tags_gen.go:1564:4: unknown field 'Value' in struct literal of type kms.Tag -aws/internal/keyvaluetags/service_tags_gen.go:1578:39: tag.Value undefined (type *kms.Tag has no field or method Value) -``` - -The field name to identify the tag value within the Go type for tagging must be updated. Add an entry within the `ServiceTagTypeValueField` function of the generator to customize the naming of the `Value` field for the tagging Go type. In the above case: - -```go -case "kms": - return "TagValue" -``` diff --git a/internal/generate/tags/README_updatetags.md b/internal/generate/tags/README_updatetags.md deleted file mode 100644 index b33dec3e40d..00000000000 --- a/internal/generate/tags/README_updatetags.md +++ /dev/null @@ -1,216 +0,0 @@ -# updatetags - -This package contains a code generator to consistently handle the various AWS Go SDK service implementations for updating resource tags. Not all AWS Go SDK services that support tagging are generated in this manner. - -To run this code generator, execute `go generate ./...` from the root of the repository. The general workflow for the generator is: - -- Generate Go file contents via template from local variables and functions -- Go format file contents -- Write file contents to `update_tags_gen.go` file - -## Example Output - -```go -// AthenaUpdateTags updates athena service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func AthenaUpdateTags(conn *athena.Athena, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { - oldTags := New(oldTagsMap) - newTags := New(newTagsMap) - - if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { - input := &athena.UntagResourceInput{ - ResourceARN: aws.String(identifier), - TagKeys: aws.StringSlice(removedTags.Keys()), - } - - _, err := conn.UntagResource(input) - - if err != nil { - return fmt.Errorf("untagging resource (%s): %s", identifier, err) - } - } - - if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { - input := &athena.TagResourceInput{ - ResourceARN: aws.String(identifier), - Tags: updatedTags.IgnoreAws().AthenaTags(), - } - - _, err := conn.TagResource(input) - - if err != nil { - return fmt.Errorf("tagging resource (%s): %s", identifier, err) - } - } - - return nil -} -``` - -## Implementing a New Generated Service - -### Requirements - -Before a new service can be added to the generator, the new service must: - -- Have the `KeyValueTags` conversion functions implemented for the AWS Go SDK service type/map. See also the [`servicetags` generator README](../servicetags/README.md). -- Implement a function for tagging (e.g. `TagResource`) and a function for untagging via keys (e.g. `UntagResource`) -- Have the service included in `aws/internal/keyvaluetags/service_generation_customizations.go`, if not present the following compilation error will be seen: - -```text -2019/09/03 09:22:21 error executing template: template: listtags:19:41: executing "updatetags" at : error calling ClientType: unrecognized ServiceClientType: acmpca -``` - -Once the service has met all the requirements, in `main.go`: - -- Add import for new service, e.g. `"github.com/aws/aws-sdk-go/service/athena"` -- Add service name to `serviceNames`, e.g. `athena` -- Add reflection handling to `ServiceClientType()` function, e.g. - -```go -case "athena": - funcType = reflect.TypeOf(athena.New) -``` - -- Run `go generate ./...` (or `make gen`) from the root of the repository to regenerate the code -- Run `go test ./...` (or `make test`) from the root of the repository to ensure the generated code compiles -- (Optional) Customize the service generation, if necessary (see below) - -### Customizations - -By default, the generator creates a `{SERVICE}UpdateTags()` function with the following structs and function calls: - -- `{SERVICE}.TagResourceInput` struct with `ResourceArn` field and `Tags` field for calling `TagResource()` API call -- `{SERVICE}.UntagResourceInput` struct with `ResourceArn` field and `TagKeys` field for calling `UntagResource()` API call - -If these do not match the actual AWS Go SDK service implementation, the generated code will compile with errors. See the sections below for certain errors and how to handle them. - -#### ServiceTagFunction - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:704:13: undefined: datapipeline.TagResourceInput -aws/internal/keyvaluetags/update_tags_gen.go:709:17: conn.TagResource undefined (type *datapipeline.DataPipeline has no field or method TagResource) -``` - -The function for resource tagging must be updated. Add an entry within the `ServiceTagFunction()` function of the generator to customize the naming of the `TagResource()` function and matching `TagResourceInput` struct. In the above case: - -```go -case "datapipeline": - return "AddTags" -``` - -#### ServiceTagInputCustomValue - -Given the following compilation errors: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:1994:4: cannot use updatedTags.IgnoreAws().KinesisTags() (type []*kinesis.Tag) as type map[string]*string in field value -``` - -or - -```text -aws/internal/keyvaluetags/update_tags_gen.go:2534:4: cannot use updatedTags.IgnoreAws().PinpointTags() (type map[string]*string) as type *pinpoint.TagsModel in field value -``` - -The value of the tags for tagging must be transformed. Add an entry within the `ServiceTagInputCustomValue()` function of the generator to return the custom value. In the above case: - -```go -case "kinesis": - return "aws.StringMap(chunk.IgnoreAws().Map())" -``` - -#### ServiceTagInputIdentifierField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:296:4: unknown field 'ResourceArn' in struct literal of type athena.UntagResourceInput (but does have ResourceARN) -aws/internal/keyvaluetags/update_tags_gen.go:309:4: unknown field 'ResourceArn' in struct literal of type athena.TagResourceInput (but does have ResourceARN) -``` - -The field name to identify the resource for tagging must be updated. Add an entry within the `ServiceTagInputIdentifierField()` function of the generator to customize the naming of the `ResourceArn` field for the tagging and untagging input structs. In the above case: - -```go -case "athena": - return "ResourceARN" -``` - -#### ServiceTagInputIdentifierRequiresSlice - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:1296:4: cannot use aws.String(identifier) (type *string) as type []*string in field value -``` - -The value to identify the resource for tagging must be passed in a string slice. Add an entry within the `ServiceTagInputIdentifierRequiresSlice()` function of the generator to ensure that the value is passed as expected. In the above case - -```go -case "ec2": - return "yes" -``` - -#### ServiceTagInputTagsField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:382:4: unknown field 'Tags' in struct literal of type cloudhsmv2.TagResourceInput -``` - -The field name with the tags for tagging must be updated. Add an entry within the `ServiceTagInputTagsField()` function of the generator to customize the naming of the `Tags` field for the tagging input struct. In the above case: - -```go -case "cloudhsmv2": - return "TagList" -``` - -#### ServiceUntagFunction - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:691:13: undefined: datapipeline.UntagResourceInput -aws/internal/keyvaluetags/update_tags_gen.go:696:17: conn.UntagResource undefined (type *datapipeline.DataPipeline has no field or method UntagResource) -``` - -The function for resource untagging must be updated. Add an entry within the `ServiceUntagFunction()` function of the generator to customize the naming of the `UntagResource()` function and matching `UntagResourceInput` struct. In the above case: - -```go -case "datapipeline": - return "RemoveTags" -``` - -#### ServiceUntagInputTagsField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:369:4: unknown field 'TagKeys' in struct literal of type cloudhsmv2.UntagResourceInput -``` - -The field name with the tag keys for untagging must be updated. Add an entry within the `ServiceUntagInputTagsField()` function of the generator to customize the naming of the `TagKeys` field for the untagging input struct. In the above case: - -```go -case "cloudhsmv2": - return "TagKeyList" -``` - -#### ServiceUntagInputCustomValue - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:523:4: cannot use updatedTags.IgnoreAws().CloudfrontTags() (type []*cloudfront.Tag) as type *cloudfront.Tags in field value -``` - -The value of the tags for untagging must be transformed. Add an entry within the `ServiceUntagInputCustomValue()` function of the generator to return the custom value. In the above case: - -```go -case "cloudfront": - return "&cloudfront.TagKeys{Items: aws.StringSlice(removedTags.IgnoreAws().Keys())}" -``` From 7f646bdbcdfc22f7c07088a1e3d1d797dd4dd754 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 11:13:03 -0400 Subject: [PATCH 12/24] Fix typo. --- internal/service/mediapackage/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/mediapackage/generate.go b/internal/service/mediapackage/generate.go index c43ad0438cc..8e47d91f5b1 100644 --- a/internal/service/mediapackage/generate.go +++ b/internal/service/mediapackage/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go=true -KVTValues -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -KVTValues -ListTags -ServiceTagsMap -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From e26094e2d153ca12ebe71ec3f3ed7a775c23677e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 14:31:35 -0400 Subject: [PATCH 13/24] internal/generate/tags: 'ListTagsInIDNeedValueSlice' -> bool. --- internal/generate/tags/main.go | 62 ++++++++++--------- .../tags/templates/list_tags_body.gtpl | 4 +- internal/service/cloudtrail/generate.go | 2 +- internal/service/directconnect/generate.go | 2 +- internal/service/elb/generate.go | 2 +- internal/service/elbv2/generate.go | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index e4ac220f17d..e4d236780c5 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -26,25 +26,42 @@ const ( ) var ( - createTags = flag.Bool("CreateTags", false, "whether to generate CreateTags") - getTag = flag.Bool("GetTag", false, "whether to generate GetTag") - listTags = flag.Bool("ListTags", false, "whether to generate ListTags") - serviceTagsMap = flag.Bool("ServiceTagsMap", false, "whether to generate service tags for map") - serviceTagsSlice = flag.Bool("ServiceTagsSlice", false, "whether to generate service tags for slice") + sdkServicePackage = flag.String("AWSSDKServicePackage", "", "AWS Go SDK package to use. Defaults to the provider service package name.") + + createTags = flag.Bool("CreateTags", false, "whether to generate CreateTags") + createTagsFunc = flag.String("CreateTagsFunc", "createTags", "createTagsFunc") + getTag = flag.Bool("GetTag", false, "whether to generate GetTag") + getTagFunc = flag.String("GetTagFunc", "findTag", "getTagFunc") + listTags = flag.Bool("ListTags", false, "whether to generate ListTags") + listTagsFunc = flag.String("ListTagsFunc", defaultListTagsFunc, "listTagsFunc") + updateTags = flag.Bool("UpdateTags", false, "whether to generate UpdateTags") + updateTagsFunc = flag.String("UpdateTagsFunc", defaultUpdateTagsFunc, "updateTagsFunc") + + serviceTagsMap = flag.Bool("ServiceTagsMap", false, "whether to generate service tags for map") + kvtValues = flag.Bool("KVTValues", false, "Whether KVT string map is of string pointers") + emptyMap = flag.Bool("EmptyMap", false, "Whether KVT string map should be empty for no tags") + serviceTagsSlice = flag.Bool("ServiceTagsSlice", false, "whether to generate service tags for slice") + + keyValueTagsFunc = flag.String("KeyValueTagsFunc", "KeyValueTags", "keyValueTagsFunc") + tagsFunc = flag.String("TagsFunc", "Tags", "tagsFunc") + getTagsInFunc = flag.String("GetTagsInFunc", "getTagsIn", "getTagsInFunc") + setTagsOutFunc = flag.String("SetTagsOutFunc", "setTagsOut", "setTagsOutFunc") + + waitForPropagation = flag.Bool("Wait", false, "whether to generate WaitTagsPropagated") + waitTagsPropagatedFunc = flag.String("WaitFunc", defaultWaitTagsPropagatedFunc, "waitFunc") + waitContinuousOccurence = flag.Int("WaitContinuousOccurence", 0, "ContinuousTargetOccurence for Wait function") + waitFuncComparator = flag.String("WaitFuncComparator", "Equal", "waitFuncComparator") + waitDelay = flag.Duration("WaitDelay", 0, "Delay for Wait function") + waitMinTimeout = flag.Duration("WaitMinTimeout", 0, `"MinTimeout" (minimum poll interval) for Wait function`) + waitPollInterval = flag.Duration("WaitPollInterval", 0, "PollInterval for Wait function") + waitTimeout = flag.Duration("WaitTimeout", 0, "Timeout for Wait function") + untagInNeedTagType = flag.Bool("UntagInNeedTagType", false, "whether Untag input needs tag type") - updateTags = flag.Bool("UpdateTags", false, "whether to generate UpdateTags") updateTagsNoIgnoreSystem = flag.Bool("UpdateTagsNoIgnoreSystem", false, "whether to not ignore system tags in UpdateTags") - waitForPropagation = flag.Bool("Wait", false, "whether to generate WaitTagsPropagated") - createTagsFunc = flag.String("CreateTagsFunc", "createTags", "createTagsFunc") - getTagFunc = flag.String("GetTagFunc", "findTag", "getTagFunc") - getTagsInFunc = flag.String("GetTagsInFunc", "getTagsIn", "getTagsInFunc") - keyValueTagsFunc = flag.String("KeyValueTagsFunc", "KeyValueTags", "keyValueTagsFunc") - listTagsFunc = flag.String("ListTagsFunc", defaultListTagsFunc, "listTagsFunc") listTagsInFiltIDName = flag.String("ListTagsInFiltIDName", "", "listTagsInFiltIDName") listTagsInIDElem = flag.String("ListTagsInIDElem", "ResourceArn", "listTagsInIDElem") - listTagsInIDNeedSlice = flag.String("ListTagsInIDNeedSlice", "", "listTagsInIDNeedSlice") - listTagsInIDNeedValueSlice = flag.String("ListTagsInIDNeedValueSlice", "", "listTagsInIDNeedSlice") + listTagsInIDNeedValueSlice = flag.Bool("ListTagsInIDNeedValueSlice", false, "listTagsInIDNeedSlice") listTagsOp = flag.String("ListTagsOp", "ListTagsForResource", "listTagsOp") listTagsOpPaginated = flag.Bool("ListTagsOpPaginated", false, "whether ListTagsOp is paginated") listTagsOutTagsElem = flag.String("ListTagsOutTagsElem", "Tags", "listTagsOutTagsElem") @@ -52,7 +69,6 @@ var ( retryTagsErrorCodes = flag.String("RetryTagsErrorCodes", "", "comma-separated list of error codes to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorMessages") retryTagsErrorMessages = flag.String("RetryTagsErrorMessages", "", "comma-separated list of error messages to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorCodes") retryTagsTimeout = flag.Duration("RetryTagsTimeout", 1*time.Minute, "Timeout for retrying tag operations") - setTagsOutFunc = flag.String("SetTagsOutFunc", "setTagsOut", "setTagsOutFunc") tagInCustomVal = flag.String("TagInCustomVal", "", "tagInCustomVal") tagInIDElem = flag.String("TagInIDElem", "ResourceArn", "tagInIDElem") tagInIDNeedSlice = flag.String("TagInIDNeedSlice", "", "tagInIDNeedSlice") @@ -69,26 +85,13 @@ var ( tagTypeIDElem = flag.String("TagTypeIDElem", "", "tagTypeIDElem") tagTypeKeyElem = flag.String("TagTypeKeyElem", "Key", "tagTypeKeyElem") tagTypeValElem = flag.String("TagTypeValElem", "Value", "tagTypeValElem") - tagsFunc = flag.String("TagsFunc", "Tags", "tagsFunc") untagInCustomVal = flag.String("UntagInCustomVal", "", "untagInCustomVal") untagInNeedTagKeyType = flag.String("UntagInNeedTagKeyType", "", "untagInNeedTagKeyType") untagInTagsElem = flag.String("UntagInTagsElem", "TagKeys", "untagInTagsElem") untagOp = flag.String("UntagOp", "UntagResource", "untagOp") - updateTagsFunc = flag.String("UpdateTagsFunc", defaultUpdateTagsFunc, "updateTagsFunc") - waitTagsPropagatedFunc = flag.String("WaitFunc", defaultWaitTagsPropagatedFunc, "waitFunc") - waitContinuousOccurence = flag.Int("WaitContinuousOccurence", 0, "ContinuousTargetOccurence for Wait function") - waitFuncComparator = flag.String("WaitFuncComparator", "Equal", "waitFuncComparator") - waitDelay = flag.Duration("WaitDelay", 0, "Delay for Wait function") - waitMinTimeout = flag.Duration("WaitMinTimeout", 0, `"MinTimeout" (minimum poll interval) for Wait function`) - waitPollInterval = flag.Duration("WaitPollInterval", 0, "PollInterval for Wait function") - waitTimeout = flag.Duration("WaitTimeout", 0, "Timeout for Wait function") parentNotFoundErrCode = flag.String("ParentNotFoundErrCode", "", "Parent 'NotFound' Error Code") parentNotFoundErrMsg = flag.String("ParentNotFoundErrMsg", "", "Parent 'NotFound' Error Message") - - sdkServicePackage = flag.String("AWSSDKServicePackage", "", "AWS Go SDK package to use. Defaults to the provider service package name.") - kvtValues = flag.Bool("KVTValues", false, "Whether KVT string map is of string pointers") - emptyMap = flag.Bool("EmptyMap", false, "Whether KVT string map should be empty for no tags") ) func usage() { @@ -146,7 +149,7 @@ type TemplateData struct { ListTagsInFiltIDName string ListTagsInIDElem string ListTagsInIDNeedSlice string - ListTagsInIDNeedValueSlice string + ListTagsInIDNeedValueSlice bool ListTagsOp string ListTagsOpPaginated bool ListTagsOutTagsElem string @@ -274,7 +277,6 @@ func main() { ListTagsFunc: *listTagsFunc, ListTagsInFiltIDName: *listTagsInFiltIDName, ListTagsInIDElem: *listTagsInIDElem, - ListTagsInIDNeedSlice: *listTagsInIDNeedSlice, ListTagsInIDNeedValueSlice: *listTagsInIDNeedValueSlice, ListTagsOp: *listTagsOp, ListTagsOpPaginated: *listTagsOpPaginated, diff --git a/internal/generate/tags/templates/list_tags_body.gtpl b/internal/generate/tags/templates/list_tags_body.gtpl index 907bfdf8ba8..75e99d79da4 100644 --- a/internal/generate/tags/templates/list_tags_body.gtpl +++ b/internal/generate/tags/templates/list_tags_body.gtpl @@ -11,9 +11,7 @@ func {{ .ListTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier }, }, {{- else }} - {{- if .ListTagsInIDNeedSlice }} - {{ .ListTagsInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else if .ListTagsInIDNeedValueSlice }} + {{- if .ListTagsInIDNeedValueSlice }} {{ .ListTagsInIDElem }}: []string{identifier}, {{- else }} {{ .ListTagsInIDElem }}: aws.String(identifier), diff --git a/internal/service/cloudtrail/generate.go b/internal/service/cloudtrail/generate.go index 0d6f769fac0..bcd45e270b2 100644 --- a/internal/service/cloudtrail/generate.go +++ b/internal/service/cloudtrail/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsOpPaginated -ListTagsInIDElem=ResourceIdList --ListTagsInIDNeedValueSlice=yes -ListTagsOutTagsElem=ResourceTagList[0].TagsList -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceId -TagInTagsElem=TagsList -UntagOp=RemoveTags -UntagInNeedTagType -UntagInTagsElem=TagsList -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsOpPaginated -ListTagsInIDElem=ResourceIdList -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=ResourceTagList[0].TagsList -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceId -TagInTagsElem=TagsList -UntagOp=RemoveTags -UntagInNeedTagType -UntagInTagsElem=TagsList -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/directconnect/generate.go b/internal/service/directconnect/generate.go index 6b5cff2c680..2590033a426 100644 --- a/internal/service/directconnect/generate.go +++ b/internal/service/directconnect/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeDirectConnectGateways,DescribeDirectConnectGatewayAssociations,DescribeDirectConnectGatewayAssociationProposals -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=ResourceArns -ListTagsInIDNeedValueSlice=yes -ListTagsOutTagsElem=ResourceTags[0].Tags -ServiceTagsSlice -UpdateTags -CreateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=ResourceArns -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=ResourceTags[0].Tags -ServiceTagsSlice -UpdateTags -CreateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/elb/generate.go b/internal/service/elb/generate.go index a42381c56c9..3df7be693e1 100644 --- a/internal/service/elb/generate.go +++ b/internal/service/elb/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=LoadBalancerNames -ListTagsInIDNeedValueSlice=yes -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=LoadBalancerNames -TagInIDNeedValueSlice=yes -TagKeyType=TagKeyOnly -UntagOp=RemoveTags -UntagInNeedTagKeyType=yes -UntagInTagsElem=Tags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=LoadBalancerNames -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=LoadBalancerNames -TagInIDNeedValueSlice=yes -TagKeyType=TagKeyOnly -UntagOp=RemoveTags -UntagInNeedTagKeyType=yes -UntagInTagsElem=Tags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/elbv2/generate.go b/internal/service/elbv2/generate.go index 97064d40d49..f2dda72b3dc 100644 --- a/internal/service/elbv2/generate.go +++ b/internal/service/elbv2/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeListenerCertificates -InputPaginator=Marker -OutputPaginator=NextMarker -- list_listener_certificates_pages_gen.go -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=ResourceArns -ListTagsInIDNeedValueSlice=yes -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceArns -TagInIDNeedValueSlice=yes -UntagOp=RemoveTags -UpdateTags -CreateTags -KVTValues +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=ResourceArns -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceArns -TagInIDNeedValueSlice=yes -UntagOp=RemoveTags -UpdateTags -CreateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From b208997cd7507d884f5adf4a923bf2399cca9e60 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 14:38:21 -0400 Subject: [PATCH 14/24] internal/generate/tags: 'TagInIDNeedValueSlice' -> bool. --- internal/generate/tags/main.go | 62 +++++++++---------- .../tags/templates/update_tags_body.gtpl | 12 +--- internal/service/ec2/generate.go | 2 +- internal/service/elb/generate.go | 2 +- internal/service/elbv2/generate.go | 2 +- 5 files changed, 37 insertions(+), 43 deletions(-) diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index e4d236780c5..9243694475c 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -56,39 +56,41 @@ var ( waitPollInterval = flag.Duration("WaitPollInterval", 0, "PollInterval for Wait function") waitTimeout = flag.Duration("WaitTimeout", 0, "Timeout for Wait function") - untagInNeedTagType = flag.Bool("UntagInNeedTagType", false, "whether Untag input needs tag type") - updateTagsNoIgnoreSystem = flag.Bool("UpdateTagsNoIgnoreSystem", false, "whether to not ignore system tags in UpdateTags") - listTagsInFiltIDName = flag.String("ListTagsInFiltIDName", "", "listTagsInFiltIDName") listTagsInIDElem = flag.String("ListTagsInIDElem", "ResourceArn", "listTagsInIDElem") listTagsInIDNeedValueSlice = flag.Bool("ListTagsInIDNeedValueSlice", false, "listTagsInIDNeedSlice") listTagsOp = flag.String("ListTagsOp", "ListTagsForResource", "listTagsOp") listTagsOpPaginated = flag.Bool("ListTagsOpPaginated", false, "whether ListTagsOp is paginated") listTagsOutTagsElem = flag.String("ListTagsOutTagsElem", "Tags", "listTagsOutTagsElem") - retryTagsListTagsType = flag.String("RetryTagsListTagsType", "", "type of the first ListTagsOp return value such as TagListMessage") - retryTagsErrorCodes = flag.String("RetryTagsErrorCodes", "", "comma-separated list of error codes to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorMessages") - retryTagsErrorMessages = flag.String("RetryTagsErrorMessages", "", "comma-separated list of error messages to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorCodes") - retryTagsTimeout = flag.Duration("RetryTagsTimeout", 1*time.Minute, "Timeout for retrying tag operations") - tagInCustomVal = flag.String("TagInCustomVal", "", "tagInCustomVal") - tagInIDElem = flag.String("TagInIDElem", "ResourceArn", "tagInIDElem") - tagInIDNeedSlice = flag.String("TagInIDNeedSlice", "", "tagInIDNeedSlice") - tagInIDNeedValueSlice = flag.String("TagInIDNeedValueSlice", "", "tagInIDNeedValueSlice") - tagInTagsElem = flag.String("TagInTagsElem", "Tags", "tagInTagsElem") - tagKeyType = flag.String("TagKeyType", "", "tagKeyType") - tagOp = flag.String("TagOp", "TagResource", "tagOp") - tagOpBatchSize = flag.String("TagOpBatchSize", "", "tagOpBatchSize") - tagResTypeElem = flag.String("TagResTypeElem", "", "tagResTypeElem") - tagResTypeElemType = flag.String("TagResTypeElemType", "", "tagResTypeElemType") - tagType = flag.String("TagType", "Tag", "tagType") - tagType2 = flag.String("TagType2", "", "tagType") - tagTypeAddBoolElem = flag.String("TagTypeAddBoolElem", "", "TagTypeAddBoolElem") - tagTypeIDElem = flag.String("TagTypeIDElem", "", "tagTypeIDElem") - tagTypeKeyElem = flag.String("TagTypeKeyElem", "Key", "tagTypeKeyElem") - tagTypeValElem = flag.String("TagTypeValElem", "Value", "tagTypeValElem") - untagInCustomVal = flag.String("UntagInCustomVal", "", "untagInCustomVal") - untagInNeedTagKeyType = flag.String("UntagInNeedTagKeyType", "", "untagInNeedTagKeyType") - untagInTagsElem = flag.String("UntagInTagsElem", "TagKeys", "untagInTagsElem") - untagOp = flag.String("UntagOp", "UntagResource", "untagOp") + + tagInCustomVal = flag.String("TagInCustomVal", "", "tagInCustomVal") + tagInIDElem = flag.String("TagInIDElem", "ResourceArn", "tagInIDElem") + tagInIDNeedValueSlice = flag.Bool("TagInIDNeedValueSlice", false, "tagInIDNeedValueSlice") + tagInTagsElem = flag.String("TagInTagsElem", "Tags", "tagInTagsElem") + tagKeyType = flag.String("TagKeyType", "", "tagKeyType") + tagOp = flag.String("TagOp", "TagResource", "tagOp") + tagOpBatchSize = flag.Int("TagOpBatchSize", 0, "tagOpBatchSize") + tagResTypeElem = flag.String("TagResTypeElem", "", "tagResTypeElem") + tagResTypeElemType = flag.String("TagResTypeElemType", "", "tagResTypeElemType") + tagType = flag.String("TagType", "Tag", "tagType") + tagType2 = flag.String("TagType2", "", "tagType") + tagTypeAddBoolElem = flag.String("TagTypeAddBoolElem", "", "TagTypeAddBoolElem") + tagTypeIDElem = flag.String("TagTypeIDElem", "", "tagTypeIDElem") + tagTypeKeyElem = flag.String("TagTypeKeyElem", "Key", "tagTypeKeyElem") + tagTypeValElem = flag.String("TagTypeValElem", "Value", "tagTypeValElem") + + untagInNeedTagType = flag.Bool("UntagInNeedTagType", false, "whether Untag input needs tag type") + updateTagsNoIgnoreSystem = flag.Bool("UpdateTagsNoIgnoreSystem", false, "whether to not ignore system tags in UpdateTags") + + retryTagsListTagsType = flag.String("RetryTagsListTagsType", "", "type of the first ListTagsOp return value such as TagListMessage") + retryTagsErrorCodes = flag.String("RetryTagsErrorCodes", "", "comma-separated list of error codes to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorMessages") + retryTagsErrorMessages = flag.String("RetryTagsErrorMessages", "", "comma-separated list of error messages to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorCodes") + retryTagsTimeout = flag.Duration("RetryTagsTimeout", 1*time.Minute, "Timeout for retrying tag operations") + + untagInCustomVal = flag.String("UntagInCustomVal", "", "untagInCustomVal") + untagInNeedTagKeyType = flag.String("UntagInNeedTagKeyType", "", "untagInNeedTagKeyType") + untagInTagsElem = flag.String("UntagInTagsElem", "TagKeys", "untagInTagsElem") + untagOp = flag.String("UntagOp", "UntagResource", "untagOp") parentNotFoundErrCode = flag.String("ParentNotFoundErrCode", "", "Parent 'NotFound' Error Code") parentNotFoundErrMsg = flag.String("ParentNotFoundErrMsg", "", "Parent 'NotFound' Error Message") @@ -163,12 +165,11 @@ type TemplateData struct { SetTagsOutFunc string TagInCustomVal string TagInIDElem string - TagInIDNeedSlice string - TagInIDNeedValueSlice string + TagInIDNeedValueSlice bool TagInTagsElem string TagKeyType string TagOp string - TagOpBatchSize string + TagOpBatchSize int TagPackage string TagResTypeElem string TagResTypeElemType string @@ -291,7 +292,6 @@ func main() { SetTagsOutFunc: *setTagsOutFunc, TagInCustomVal: *tagInCustomVal, TagInIDElem: *tagInIDElem, - TagInIDNeedSlice: *tagInIDNeedSlice, TagInIDNeedValueSlice: *tagInIDNeedValueSlice, TagInTagsElem: *tagInTagsElem, TagKeyType: *tagKeyType, diff --git a/internal/generate/tags/templates/update_tags_body.gtpl b/internal/generate/tags/templates/update_tags_body.gtpl index 3ed05b03df7..bb712647b5e 100644 --- a/internal/generate/tags/templates/update_tags_body.gtpl +++ b/internal/generate/tags/templates/update_tags_body.gtpl @@ -31,9 +31,7 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi input := &{{ .AWSService }}.{{ .TagOp }}Input{ {{- if not ( .TagTypeIDElem ) }} - {{- if .TagInIDNeedSlice }} - {{ .TagInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else if .TagInIDNeedValueSlice }} + {{- if .TagInIDNeedValueSlice }} {{ .TagInIDElem }}: []string{identifier}, {{- else }} {{ .TagInIDElem }}: aws.String(identifier), @@ -82,9 +80,7 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi {{- end }} input := &{{ .TagPackage }}.{{ .UntagOp }}Input{ {{- if not ( .TagTypeIDElem ) }} - {{- if .TagInIDNeedSlice }} - {{ .TagInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else if .TagInIDNeedValueSlice }} + {{- if .TagInIDNeedValueSlice }} {{ .TagInIDElem }}: []string{identifier}, {{- else }} {{ .TagInIDElem }}: aws.String(identifier), @@ -128,9 +124,7 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi {{- end }} input := &{{ .TagPackage }}.{{ .TagOp }}Input{ {{- if not ( .TagTypeIDElem ) }} - {{- if .TagInIDNeedSlice }} - {{ .TagInIDElem }}: aws.StringSlice([]string{identifier}), - {{- else if .TagInIDNeedValueSlice }} + {{- if .TagInIDNeedValueSlice }} {{ .TagInIDElem }}: []string{identifier}, {{- else }} {{ .TagInIDElem }}: aws.String(identifier), diff --git a/internal/service/ec2/generate.go b/internal/service/ec2/generate.go index 889279d16ea..f051ea12c7e 100644 --- a/internal/service/ec2/generate.go +++ b/internal/service/ec2/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/tagresource/main.go -IDAttribName=resource_id -//go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsOp=DescribeTags -ListTagsOpPaginated -ListTagsInFiltIDName=resource-id -ServiceTagsSlice -KeyValueTagsFunc=keyValueTags -TagOp=CreateTags -TagInIDElem=Resources -TagInIDNeedValueSlice=yes -TagType2=TagDescription -UntagOp=DeleteTags -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags +//go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsOp=DescribeTags -ListTagsOpPaginated -ListTagsInFiltIDName=resource-id -ServiceTagsSlice -KeyValueTagsFunc=keyValueTags -TagOp=CreateTags -TagInIDElem=Resources -TagInIDNeedValueSlice -TagType2=TagDescription -UntagOp=DeleteTags -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeSpotFleetInstances,DescribeSpotFleetRequestHistory,DescribeVpcEndpointServices //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go diff --git a/internal/service/elb/generate.go b/internal/service/elb/generate.go index 3df7be693e1..cfe17d7f687 100644 --- a/internal/service/elb/generate.go +++ b/internal/service/elb/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=LoadBalancerNames -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=LoadBalancerNames -TagInIDNeedValueSlice=yes -TagKeyType=TagKeyOnly -UntagOp=RemoveTags -UntagInNeedTagKeyType=yes -UntagInTagsElem=Tags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=LoadBalancerNames -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=LoadBalancerNames -TagInIDNeedValueSlice -TagKeyType=TagKeyOnly -UntagOp=RemoveTags -UntagInNeedTagKeyType=yes -UntagInTagsElem=Tags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/elbv2/generate.go b/internal/service/elbv2/generate.go index f2dda72b3dc..00592f39381 100644 --- a/internal/service/elbv2/generate.go +++ b/internal/service/elbv2/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeListenerCertificates -InputPaginator=Marker -OutputPaginator=NextMarker -- list_listener_certificates_pages_gen.go -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=ResourceArns -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceArns -TagInIDNeedValueSlice=yes -UntagOp=RemoveTags -UpdateTags -CreateTags -KVTValues +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=ResourceArns -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceArns -TagInIDNeedValueSlice -UntagOp=RemoveTags -UpdateTags -CreateTags -KVTValues //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. From edcc22c104bb57706afe2d0e70b4ac0a7b90a077 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 15:18:10 -0400 Subject: [PATCH 15/24] Add 'names.ToSnakeCase'. --- names/snake.go | 71 +++++++++++++++++++++++++++++++++++++++++++++ names/snake_test.go | 59 +++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 names/snake.go create mode 100644 names/snake_test.go diff --git a/names/snake.go b/names/snake.go new file mode 100644 index 00000000000..d44a5e90283 --- /dev/null +++ b/names/snake.go @@ -0,0 +1,71 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package names + +import ( + "strings" +) + +// ToSnakeCase converts a string to snake_case. +func ToSnakeCase(in string) string { + out := strings.Builder{} + + for i, ch := range []byte(in) { + isCap := isCapitalLetter(ch) + isLow := isLowercaseLetter(ch) + isDig := isNumeric(ch) + + if isCap { + ch = toLowercaseLetter(ch) + } + + if i < len(in)-1 { + nextCh := in[i+1] + nextIsCap := isCapitalLetter(nextCh) + nextIsLow := isLowercaseLetter(nextCh) + nextIsDig := isNumeric(nextCh) + + // Append underscore if case changes. + if (isCap && nextIsLow) || (isLow && (nextIsCap || nextIsDig) || (isDig && (nextIsCap || nextIsLow))) { + if isCap && nextIsLow { + if prevIsCap := i > 0 && isCapitalLetter(in[i-1]); prevIsCap { + out.WriteByte('_') + } + } + out.WriteByte(ch) + if isLow || isDig { + out.WriteByte('_') + } + + continue + } + } + + if isCap || isLow || isDig { + out.WriteByte(ch) + } else { + out.WriteByte('_') + } + } + + return out.String() +} + +func isCapitalLetter(ch byte) bool { + return ch >= 'A' && ch <= 'Z' +} + +func isLowercaseLetter(ch byte) bool { + return ch >= 'a' && ch <= 'z' +} + +func isNumeric(ch byte) bool { + return ch >= '0' && ch <= '9' +} + +func toLowercaseLetter(ch byte) byte { + ch += 'a' + ch -= 'A' + return ch +} diff --git a/names/snake_test.go b/names/snake_test.go new file mode 100644 index 00000000000..b888bdc27cf --- /dev/null +++ b/names/snake_test.go @@ -0,0 +1,59 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package names + +import ( + "testing" +) + +func TestToSnakeCase(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + input string + expected string + }{ + { + name: "empty", + input: "", + expected: "", + }, + { + name: "All lower", + input: "lower", + expected: "lower", + }, + { + name: "Initial upper", + input: "Lower", + expected: "lower", + }, + { + name: "Two words", + input: "TwoWords", + expected: "two_words", + }, + { + name: "A long one", + input: "GlobalReplicationGroupDescription", + expected: "global_replication_group_description", + }, + { + name: "Including a digit", + input: "S3Bucket", + expected: "s3_bucket", + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + t.Parallel() + + if got, want := ToSnakeCase(testCase.input), testCase.expected; got != want { + t.Errorf("got: %s, expected: %s", got, want) + } + }) + } +} From 154239a1e455b553483dabadbacfd05c19f4a079 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 15:50:44 -0400 Subject: [PATCH 16/24] internal/generate/tags: 'UntagInNeedTagKeyType' -> bool. --- internal/generate/tags/README.md | 531 ++---------------- internal/generate/tags/main.go | 93 +-- .../templates/service_tags_slice_body.gtpl | 4 +- internal/service/elb/generate.go | 2 +- internal/tags/key_value_tags.go | 11 - internal/tags/key_value_tags_test.go | 42 -- names/snake_test.go | 15 + 7 files changed, 76 insertions(+), 622 deletions(-) diff --git a/internal/generate/tags/README.md b/internal/generate/tags/README.md index b771f23cf11..0a775d5e86e 100644 --- a/internal/generate/tags/README.md +++ b/internal/generate/tags/README.md @@ -22,25 +22,46 @@ Some flags control generation a certain section of code, such as whether the gen | Flag | Default | Description | Example Use | | --- | --- | --- | --- | -| `GetTag` | | Whether to generate GetTag | `-GetTag` | -| `ListTags` | | Whether to generate ListTags | `-ListTags` | -| `ServiceTagsMap` | | Whether to generate map service tags (use this or `ServiceTagsSlice`, not both) | `-ServiceTagsMap` | -| `ServiceTagsSlice` | | Whether to generate slice service tags (use this or `ServiceTagsMap`, not both) | `-ServiceTagsSlice` | -| `UpdateTags` | | Whether to generate UpdateTags | `-UpdateTags` | +| `CreateTags` | `false` | Whether to generate `CreateTags` | `-CreateTags` | +| `CreateTagsFunc` | `createTags` | Name of the generated `CreateTags` function | `-CreateTagsFunc=createTags2` | +| `GetTag` | `false` | Whether to generate `GetTag` | `-GetTag` | +| `GetTagFunc` | `findTag` | Name of the generated `GetTag` function | `-GetTagFunc=findTag2` | +| `ListTags` | `false` | Whether to generate `ListTags` | `-ListTags` | +| `ListTagsFunc` | `listTags` | Name of the generated `ListTags` function | `-ListTagsFunc=listTags2` | +| `UpdateTags` | `false` | Whether to generate `UpdateTags` | `-UpdateTags` | +| `UpdateTagsFunc` | `updateTags` | Name of the generated `UpdateTags` function | `-UpdateTagsFunc=updateTags2` | +| `UpdateTagsNoIgnoreSystem` | `false` | Whether to ignore system tags in `UpdateTags` | `-UpdateTagsNoIgnoreSystem` | +| `ServiceTagsMap` | `false` | Whether to generate map service tags (use this or `ServiceTagsSlice`, not both) | `-ServiceTagsMap` | +| `KVTValues` | `false` | Whether map service tags have string pointer values | `-KVTValues` | +| `EmptyMap` | `false` | Whether map service tags should be empty for no tags | `-EmptyMap` | +| `ServiceTagsSlice` | `false` | Whether to generate slice service tags (use this or `ServiceTagsMap`, not both) | `-ServiceTagsSlice` | +| `KeyValueTagsFunc` | `KeyValueTags` | Name of the generated `KeyValueTags` function | `-KeyValueTagsFunc=keyValueTags2` | +| `TagsFunc` | `Tags` | Name of the generated `Tags` function | `-TagsFunc=tags2` | +| `GetTagsInFunc` | `getTagsIn` | Name of the generated `getTagsIn` function | `-GetTagsInFunc=getTagsIn2` | +| `SetTagsOutFunc` | `setTagsOut` | Name of the generated `setTagsOut` function | `-SetTagsOutFunc=setTagsOut2` | +| `Wait` | `false` | Whether to generate `waitTagsPropagated` | `-Wait` | +| `WaitFunc` | `waitTagsPropagated` | Name of the generated `waitTagsPropagated` function | `-WaitFunc=waitTagsPropagated2` | +| `WaitContinuousOccurence` | `0` | `ContinuousTargetOccurence` for `waitTagsPropagated` function | `-WaitContinuousOccurence=2` | +| `WaitFuncComparator` | `Equal` | Name of the function used for tags comparison during wait | `-WaitFuncComparator=ContainsAll` | +| `WaitDelay` | `0` | "Delay" for `waitTagsPropagated` function | `-WaitDelay=10s` | +| `WaitMinTimeout` | `0` | "MinTimeout" (minimum poll interval) for `waitTagsPropagated` function | `-WaitMinTimeout=1s` | +| `WaitPollInterval` | `0` | "PollInterval" for `waitTagsPropagated` function | `-WaitPollInterval=5s` | +| `WaitTimeout` | `0` | "Timeout" for `waitTagsPropagated` function | `-WaitTimeout=2m` | | `ListTagsInFiltIDName` | | List tags input filter identifier name | `-ListTagsInFiltIDName=resource-id` | | `ListTagsInIDElem` | `ResourceArn` | List tags input identifier element | `-ListTagsInIDElem=ResourceARN` | -| `ListTagsInIDNeedSlice` | | Whether list tags input identifier needs a slice | `-ListTagsInIDNeedSlice=yes` | +| `ListTagsInIDNeedValueSlice` | `false` | Whether list tags input identifier needs a slice | `-ListTagsInIDNeedSlice` | | `ListTagsOp` | `ListTagsForResource` | List tags operation | `-ListTagsOp=ListTags` | +| `ListTagsOpPaginated` | `false` | Whether `ListTagsOp` is paginated | `-ListTagsOpPaginated` | | `ListTagsOutTagsElem` | `Tags` | List tags output tags element | `-ListTagsOutTagsElem=TagList` | | `TagInCustomVal` | | Tag input custom value | `-TagInCustomVal=aws.StringMap(updatedTags.IgnoreAWS().Map())` | | `TagInIDElem` | `ResourceArn` | Tag input identifier element | `-TagInIDElem=ResourceARN` | -| `TagInIDNeedSlice` | | Tag input identifier needs a slice | `-TagInIDNeedSlice=yes` | -| `TagInIDNeedValueSlice` | | Tag input identifier needs a slice of values, rather than a slice of pointers | `-TagInIDNeedValueSlice=yes` | +| `TagInIDNeedValueSlice` | `false` | Tag input identifier needs a slice of values | `-TagInIDNeedValueSlice` | | `TagInTagsElem` | Tags | Tag input tags element | `-TagInTagsElem=TagsList` | | `TagKeyType` | | Tag key type | `-TagKeyType=TagKeyOnly` | | `TagOp` | `TagResource` | Tag operation | `-TagOp=AddTags` | -| `TagOpBatchSize` | | Tag operation batch size | `-TagOpBatchSize=10` | +| `TagOpBatchSize` | `0` | Tag operation batch size | `-TagOpBatchSize=10` | | `TagResTypeElem` | | Tag resource type field | `-TagResTypeElem=ResourceType` | +| `TagResTypeElemType` | | Tag resource type field type | `-TagResTypeElem=ResourceTypeForTagging` | | `TagType` | `Tag` | Tag type | `-TagType=TagRef` | | `TagType2` | | Second tag type | `-TagType2=TagDescription` | | `TagTypeAddBoolElem` | | Tag type additional boolean element | `-TagTypeAddBoolElem=PropagateAtLaunch` | @@ -48,493 +69,9 @@ Some flags control generation a certain section of code, such as whether the gen | `TagTypeKeyElem` | `Key` | Tag type key element | `-TagTypeKeyElem=TagKey` | | `TagTypeValElem` | `Value` | Tag type value element | `-TagTypeValElem=TagValue` | | `UntagInCustomVal` | | Untag input custom value | `-UntagInCustomVal="&cloudfront.TagKeys{Items: aws.StringSlice(removedTags.IgnoreAWS().Keys())}"` | -| `UntagInNeedTagKeyType` | | Untag input needs tag key type | `-UntagInNeedTagKeyType=yes` | -| `UntagInNeedTagType` | | Untag input needs tag type | `-UntagInNeedTagType` | +| `UntagInNeedTagKeyType` | `false` | Untag input needs tag key type | `-UntagInNeedTagKeyType` | +| `UntagInNeedTagType` | `false` | Untag input needs tag type | `-UntagInNeedTagType` | | `UntagInTagsElem` | `TagKeys` | Untag input tags element | `-UntagInTagsElem=Tags` | | `UntagOp` | `UntagResource` | Untag operation | `-UntagOp=DeleteTags` | - -## Legacy Documentation - -(TODO: This needs to be updated...) - -The `keyvaluetags` package is designed to provide a consistent interface for handling AWS resource key-value tags. Many of the AWS Go SDK services, implement their own Go struct with `Key` and `Value` fields (e.g. `athena.Tag`) while others simply use a map (e.g. `map[string]string`). These inconsistent implementations and numerous Go types makes the process of correctly working with each of the services a tedius, previously copy-paste-modify process. - -This package instead implements a single `KeyValueTags` type, which covers all key-value handling logic such as merging tags and ignoring keys via functions on the single type. The underlying implementation is compatible with Go operations such as `len()`. - -Full documentation for this package can be found on [GoDoc](https://godoc.org/github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags). - -Many AWS Go SDK services that support tagging have their service-specific Go type conversion functions to and from `KeyValueTags` code generated. Converting from `KeyValueTags` to AWS Go SDK types is done via `{SERVICE}Tags()` functions on the type, while converting from AWS Go SDK types to the `KeyValueTags` type is done via `{SERVICE}KeyValueTags()` functions. For more information about this code generation, see the [`servicetags` README](README_servicetags.md). - -Some AWS Go SDK services that have common tag listing functionality (such as `ListTagsForResource` API call), also have auto-generated list functions. For more information about this code generation, see the [`listtags` README](README_listtags.md). - -Some AWS Go SDK services that have common tagging update functionality (such as `TagResource` and `UntagResource` API calls), also have auto-generated update functions. For more information about this code generation, see the [`updatetags` README](README_updatetags.md). - -Any tagging functions that cannot be generated should be hand implemented in a service-specific source file (e.g. `iam_tags.go`) and follow the format of similar generated code wherever possible. The first line of the source file should be `// +build !generate`. This prevents the file's inclusion during the code generation phase. - -## Code Structure - -```text -aws/internal/keyvaluetags -├── generators -│ ├── createtags (generates create_tags_gen.go) -│ ├── gettag (generates get_tag_gen.go) -│ ├── listtags (generates list_tags_gen.go) -│ ├── servicetags (generates service_tags_gen.go) -│ └── updatetags (generates update_tags_gen.go) -├── key_value_tags_test.go (unit tests for core logic) -├── key_value_tags.go (core logic) -├── list_tags_gen.go (generated AWS Go SDK service list tag functions) -├── service_generation_customizations.go (shared AWS Go SDK service customizations for generators) -├── service_tags_gen.go (generated AWS Go SDK service conversion functions) -├── update_tags_gen.go (generated AWS Go SDK service tagging update functions) -└── _tags.go (any service-specific functions that cannot be generated) -``` - - -# listtags - -This package contains a code generator to consistently handle the various AWS Go SDK service implementations for listing resource tags. Not all AWS Go SDK services that support tagging are generated in this manner. - -To run this code generator, execute `go generate ./...` from the root of the repository. The general workflow for the generator is: - -- Generate Go file contents via template from local variables and functions -- Go format file contents -- Write file contents to `list_tags_gen.go` file - -## Example Output - -```go -// AmplifyListTags lists amplify service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func AmplifyListTags(conn *amplify.Amplify, identifier string) (KeyValueTags, error) { - input := &lify.ListTagsForResourceInput{ - ResourceArn: aws.String(identifier), - } - - output, err := conn.ListTagsForResource(input) - - if err != nil { - return New(nil), err - } - - return AmplifyKeyValueTags(output.Tags), nil -} -``` - -## Implementing a New Generated Service - -### Requirements - -Before a new service can be added to the generator, the new service must: - -- Have the `KeyValueTags` conversion functions implemented for the AWS Go SDK service type/map. See also the [`servicetags` README](README_servicetags.md). -- Implement a function for listing resource tags (e.g. `ListTagsforResource`) -- Have the service included in `aws/internal/keyvaluetags/service_generation_customizations.go`, if not present the following compilation error will be seen: - -```text -2019/09/03 09:22:21 error executing template: template: listtags:19:41: executing "listtags" at : error calling ClientType: unrecognized ServiceClientType: acmpca -``` - -Once the service has met all the requirements, in `main.go`: - -- Add import for new service, e.g. `"github.com/aws/aws-sdk-go/service/athena"` -- Add service name to `serviceNames`, e.g. `athena` -- Run `go generate ./...` (or `make gen`) from the root of the repository to regenerate the code -- Run `go test ./...` (or `make test`) from the root of the repository to ensure the generated code compiles -- (Optional) Customize the service generation, if necessary (see below) - -### Customizations - -By default, the generator creates a `{SERVICE}ListTags()` function with the following structs and function calls: - -- `{SERVICE}.ListTagsForResourceInput` struct with `ResourceArn` field for calling `ListTagsForResource()` API call - -If these do not match the actual AWS Go SDK service implementation, the generated code will compile with errors. See the sections below for certain errors and how to handle them. - -#### ServiceListTagsFunction - -Given the following compilation error: - -```text -./list_tags_gen.go:183:12: undefined: backup.ListTagsForResourceInput -./list_tags_gen.go:187:21: conn.ListTagsForResource undefined (type *backup.Backup has no field or method ListTagsForResource) -``` - -The function for listing resource tags must be updated. Add an entry within the `ServiceListTagsFunction()` function of the generator to customize the naming of the `ListTagsForResource()` function and matching `ListTagsForResourceInput` struct. In the above case: - -```go -case "backup": - return "ListTags" -``` - -#### ServiceListTagsInputIdentifierField - -Given the following compilation error: - -```text -./list_tags_gen.go:1118:3: unknown field 'ResourceArn' in struct literal of type transfer.ListTagsForResourceInput -``` - -The field name to identify the resource for tag listing must be updated. Add an entry within the `ServiceListTagsInputIdentifierField()` function of the generator to customize the naming of the `ResourceArn` field for the list tags input struct. In the above case: - -```go -case "transfer": - return "Arn" -``` - -#### ServiceListTagsOutputTagsField - -Given the following compilation error: - -```text -./list_tags_gen.go:206:38: output.Tags undefined (type *cloudhsmv2.ListTagsOutput has no field or method Tags) -``` - -The field name of the tags from the tag listing must be updated. Add an entry within the `ServiceListTagsOutputTagsField()` function of the generator to customize the naming of the `Tags` field for the list tags output struct. In the above case: - -```go -case "cloudhsmv2": - return "TagList" -``` - -# servicetags - -This package contains a code generator to consistently handle the various AWS Go SDK service implementations for converting service tag/map types to/from `KeyValueTags`. Not all AWS Go SDK services that support tagging are generated in this manner. - -To run this code generator, execute `go generate ./...` from the root of the repository. The general workflow for the generator is: - -- Generate Go file contents via template from local variables and functions -- Go format file contents -- Write file contents to `service_tags_gen.go` file - -## Example Output - -For services with a specific Go type: - -```go -// AthenaTags returns athena service tags. -func (tags KeyValueTags) AthenaTags() []*athena.Tag { - result := make([]*athena.Tag, 0, len(tags)) - - for k, v := range tags.Map() { - tag := &athena.Tag{ - Key: aws.String(k), - Value: aws.String(v), - } - - result = append(result, tag) - } - - return result -} - -// AthenaKeyValueTags creates KeyValueTags from athena service tags. -func AthenaKeyValueTags(tags []*athena.Tag) KeyValueTags { - m := make(map[string]*string, len(tags)) - - for _, tag := range tags { - m[aws.StringValue(tag.Key)] = tag.Value - } - - return New(m) -} -``` - -For services that implement a map instead: - -```go -// AmplifyTags returns amplify service tags. -func (tags KeyValueTags) AmplifyTags() map[string]*string { - return aws.StringMap(tags.Map()) -} - -// AmplifyKeyValueTags creates KeyValueTags from amplify service tags. -func AmplifyKeyValueTags(tags map[string]*string) KeyValueTags { - return New(tags) -} -``` - -## Implementing a New Generated Service - -- In `main.go`: Add service name, e.g. `athena`, to one of the implementation handlers - - Use `sliceServiceNames` if the AWS Go SDK service implements a specific Go type such as `Tag` - - Use `mapServiceNames` if the AWS Go SDK service implements `map[string]*string` -- Run `go generate ./...` (or `make gen`) from the root of the repository to regenerate the code -- Run `go test ./...` (or `make test`) from the root of the repository to ensure the generated code compiles -- (Optional, only for services with a specific Go type such as `Tag`) Customize the service generation, if necessary (see below) - -### Customizations - -By default, the generator creates `KeyValueTags.{SERVICE}Tags()` and `{SERVICE}KeyValueTags()` functions with the following expectations: - -- `Tag` struct with `Key` field and `Value` field - -If these do not match the actual AWS Go SDK service implementation, the generated code will compile with errors. See the sections below for certain errors and how to handle them. - -#### ServiceTagType - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/service_tags_gen.go:397:43: undefined: appmesh.Tag -aws/internal/keyvaluetags/service_tags_gen.go:398:20: undefined: appmesh.Tag -aws/internal/keyvaluetags/service_tags_gen.go:401:11: undefined: appmesh.Tag -aws/internal/keyvaluetags/service_tags_gen.go:413:34: undefined: appmesh.Tag -``` - -The Go type that represents a tag must be updated. Add an entry within the `ServiceTagType()` function of the generator to customize the naming of the Go type. In the above case: - -```go -case "appmesh": - return "TagRef" -``` - -#### ServiceTagTypeKeyField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/service_tags_gen.go:1563:4: unknown field 'Key' in struct literal of type kms.Tag -aws/internal/keyvaluetags/service_tags_gen.go:1578:24: tag.Key undefined (type *kms.Tag has no field or method Key) -``` - -The field name to identify the tag key within the Go type for tagging must be updated. Add an entry within the `ServiceTagTypeKeyField` function of the generator to customize the naming of the `Key` field for the tagging Go type. In the above case: - -```go -case "kms": - return "TagKey" -``` - -#### ServiceTagTypeValueField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/service_tags_gen.go:1564:4: unknown field 'Value' in struct literal of type kms.Tag -aws/internal/keyvaluetags/service_tags_gen.go:1578:39: tag.Value undefined (type *kms.Tag has no field or method Value) -``` - -The field name to identify the tag value within the Go type for tagging must be updated. Add an entry within the `ServiceTagTypeValueField` function of the generator to customize the naming of the `Value` field for the tagging Go type. In the above case: - -```go -case "kms": - return "TagValue" -``` - -# updatetags - -This package contains a code generator to consistently handle the various AWS Go SDK service implementations for updating resource tags. Not all AWS Go SDK services that support tagging are generated in this manner. - -To run this code generator, execute `go generate ./...` from the root of the repository. The general workflow for the generator is: - -- Generate Go file contents via template from local variables and functions -- Go format file contents -- Write file contents to `update_tags_gen.go` file - -## Example Output - -```go -// AthenaUpdateTags updates athena service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func AthenaUpdateTags(conn *athena.Athena, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { - oldTags := New(oldTagsMap) - newTags := New(newTagsMap) - - if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { - input := &athena.UntagResourceInput{ - ResourceARN: aws.String(identifier), - TagKeys: aws.StringSlice(removedTags.Keys()), - } - - _, err := conn.UntagResource(input) - - if err != nil { - return fmt.Errorf("untagging resource (%s): %s", identifier, err) - } - } - - if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { - input := &athena.TagResourceInput{ - ResourceARN: aws.String(identifier), - Tags: updatedTags.IgnoreAws().AthenaTags(), - } - - _, err := conn.TagResource(input) - - if err != nil { - return fmt.Errorf("tagging resource (%s): %s", identifier, err) - } - } - - return nil -} -``` - -## Implementing a New Generated Service - -### Requirements - -Before a new service can be added to the generator, the new service must: - -- Have the `KeyValueTags` conversion functions implemented for the AWS Go SDK service type/map. See also the [`servicetags` README](README_servicetags.md). -- Implement a function for tagging (e.g. `TagResource`) and a function for untagging via keys (e.g. `UntagResource`) -- Have the service included in `aws/internal/keyvaluetags/service_generation_customizations.go`, if not present the following compilation error will be seen: - -```text -2019/09/03 09:22:21 error executing template: template: listtags:19:41: executing "updatetags" at : error calling ClientType: unrecognized ServiceClientType: acmpca -``` - -Once the service has met all the requirements, in `main.go`: - -- Add import for new service, e.g. `"github.com/aws/aws-sdk-go/service/athena"` -- Add service name to `serviceNames`, e.g. `athena` -- Add reflection handling to `ServiceClientType()` function, e.g. - -```go -case "athena": - funcType = reflect.TypeOf(athena.New) -``` - -- Run `go generate ./...` (or `make gen`) from the root of the repository to regenerate the code -- Run `go test ./...` (or `make test`) from the root of the repository to ensure the generated code compiles -- (Optional) Customize the service generation, if necessary (see below) - -### Customizations - -By default, the generator creates a `{SERVICE}UpdateTags()` function with the following structs and function calls: - -- `{SERVICE}.TagResourceInput` struct with `ResourceArn` field and `Tags` field for calling `TagResource()` API call -- `{SERVICE}.UntagResourceInput` struct with `ResourceArn` field and `TagKeys` field for calling `UntagResource()` API call - -If these do not match the actual AWS Go SDK service implementation, the generated code will compile with errors. See the sections below for certain errors and how to handle them. - -#### ServiceTagFunction - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:704:13: undefined: datapipeline.TagResourceInput -aws/internal/keyvaluetags/update_tags_gen.go:709:17: conn.TagResource undefined (type *datapipeline.DataPipeline has no field or method TagResource) -``` - -The function for resource tagging must be updated. Add an entry within the `ServiceTagFunction()` function of the generator to customize the naming of the `TagResource()` function and matching `TagResourceInput` struct. In the above case: - -```go -case "datapipeline": - return "AddTags" -``` - -#### ServiceTagInputCustomValue - -Given the following compilation errors: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:1994:4: cannot use updatedTags.IgnoreAws().KinesisTags() (type []*kinesis.Tag) as type map[string]*string in field value -``` - -or - -```text -aws/internal/keyvaluetags/update_tags_gen.go:2534:4: cannot use updatedTags.IgnoreAws().PinpointTags() (type map[string]*string) as type *pinpoint.TagsModel in field value -``` - -The value of the tags for tagging must be transformed. Add an entry within the `ServiceTagInputCustomValue()` function of the generator to return the custom value. In the above case: - -```go -case "kinesis": - return "aws.StringMap(chunk.IgnoreAws().Map())" -``` - -#### ServiceTagInputIdentifierField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:296:4: unknown field 'ResourceArn' in struct literal of type athena.UntagResourceInput (but does have ResourceARN) -aws/internal/keyvaluetags/update_tags_gen.go:309:4: unknown field 'ResourceArn' in struct literal of type athena.TagResourceInput (but does have ResourceARN) -``` - -The field name to identify the resource for tagging must be updated. Add an entry within the `ServiceTagInputIdentifierField()` function of the generator to customize the naming of the `ResourceArn` field for the tagging and untagging input structs. In the above case: - -```go -case "athena": - return "ResourceARN" -``` - -#### ServiceTagInputIdentifierRequiresSlice - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:1296:4: cannot use aws.String(identifier) (type *string) as type []*string in field value -``` - -The value to identify the resource for tagging must be passed in a string slice. Add an entry within the `ServiceTagInputIdentifierRequiresSlice()` function of the generator to ensure that the value is passed as expected. In the above case - -```go -case "ec2": - return "yes" -``` - -#### ServiceTagInputTagsField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:382:4: unknown field 'Tags' in struct literal of type cloudhsmv2.TagResourceInput -``` - -The field name with the tags for tagging must be updated. Add an entry within the `ServiceTagInputTagsField()` function of the generator to customize the naming of the `Tags` field for the tagging input struct. In the above case: - -```go -case "cloudhsmv2": - return "TagList" -``` - -#### ServiceUntagFunction - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:691:13: undefined: datapipeline.UntagResourceInput -aws/internal/keyvaluetags/update_tags_gen.go:696:17: conn.UntagResource undefined (type *datapipeline.DataPipeline has no field or method UntagResource) -``` - -The function for resource untagging must be updated. Add an entry within the `ServiceUntagFunction()` function of the generator to customize the naming of the `UntagResource()` function and matching `UntagResourceInput` struct. In the above case: - -```go -case "datapipeline": - return "RemoveTags" -``` - -#### ServiceUntagInputTagsField - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:369:4: unknown field 'TagKeys' in struct literal of type cloudhsmv2.UntagResourceInput -``` - -The field name with the tag keys for untagging must be updated. Add an entry within the `ServiceUntagInputTagsField()` function of the generator to customize the naming of the `TagKeys` field for the untagging input struct. In the above case: - -```go -case "cloudhsmv2": - return "TagKeyList" -``` - -#### ServiceUntagInputCustomValue - -Given the following compilation error: - -```text -aws/internal/keyvaluetags/update_tags_gen.go:523:4: cannot use updatedTags.IgnoreAws().CloudfrontTags() (type []*cloudfront.Tag) as type *cloudfront.Tags in field value -``` - -The value of the tags for untagging must be transformed. Add an entry within the `ServiceUntagInputCustomValue()` function of the generator to return the custom value. In the above case: - -```go -case "cloudfront": - return "&cloudfront.TagKeys{Items: aws.StringSlice(removedTags.IgnoreAws().Keys())}" -``` +| `ParentNotFoundErrCode` | | Parent _NotFound_ error code | `-ParentNotFoundErrCode=InvalidParameterException` | +| `ParentNotFoundErrMsg` | | Parent _NotFound_ error Message | `"-ParentNotFoundErrMsg=The specified cluster is inactive. Specify an active cluster and try again."` | diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index 9243694475c..cd2b5121767 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -11,11 +11,12 @@ import ( "fmt" "os" "strings" + "text/template" "time" - "github.com/YakDriver/regexache" "github.com/hashicorp/terraform-provider-aws/internal/generate/common" "github.com/hashicorp/terraform-provider-aws/internal/generate/tags/templates" + "github.com/hashicorp/terraform-provider-aws/names" "github.com/hashicorp/terraform-provider-aws/names/data" ) @@ -28,14 +29,15 @@ const ( var ( sdkServicePackage = flag.String("AWSSDKServicePackage", "", "AWS Go SDK package to use. Defaults to the provider service package name.") - createTags = flag.Bool("CreateTags", false, "whether to generate CreateTags") - createTagsFunc = flag.String("CreateTagsFunc", "createTags", "createTagsFunc") - getTag = flag.Bool("GetTag", false, "whether to generate GetTag") - getTagFunc = flag.String("GetTagFunc", "findTag", "getTagFunc") - listTags = flag.Bool("ListTags", false, "whether to generate ListTags") - listTagsFunc = flag.String("ListTagsFunc", defaultListTagsFunc, "listTagsFunc") - updateTags = flag.Bool("UpdateTags", false, "whether to generate UpdateTags") - updateTagsFunc = flag.String("UpdateTagsFunc", defaultUpdateTagsFunc, "updateTagsFunc") + createTags = flag.Bool("CreateTags", false, "whether to generate CreateTags") + createTagsFunc = flag.String("CreateTagsFunc", "createTags", "createTagsFunc") + getTag = flag.Bool("GetTag", false, "whether to generate GetTag") + getTagFunc = flag.String("GetTagFunc", "findTag", "getTagFunc") + listTags = flag.Bool("ListTags", false, "whether to generate ListTags") + listTagsFunc = flag.String("ListTagsFunc", defaultListTagsFunc, "listTagsFunc") + updateTags = flag.Bool("UpdateTags", false, "whether to generate UpdateTags") + updateTagsFunc = flag.String("UpdateTagsFunc", defaultUpdateTagsFunc, "updateTagsFunc") + updateTagsNoIgnoreSystem = flag.Bool("UpdateTagsNoIgnoreSystem", false, "whether to not ignore system tags in UpdateTags") serviceTagsMap = flag.Bool("ServiceTagsMap", false, "whether to generate service tags for map") kvtValues = flag.Bool("KVTValues", false, "Whether KVT string map is of string pointers") @@ -79,16 +81,9 @@ var ( tagTypeKeyElem = flag.String("TagTypeKeyElem", "Key", "tagTypeKeyElem") tagTypeValElem = flag.String("TagTypeValElem", "Value", "tagTypeValElem") - untagInNeedTagType = flag.Bool("UntagInNeedTagType", false, "whether Untag input needs tag type") - updateTagsNoIgnoreSystem = flag.Bool("UpdateTagsNoIgnoreSystem", false, "whether to not ignore system tags in UpdateTags") - - retryTagsListTagsType = flag.String("RetryTagsListTagsType", "", "type of the first ListTagsOp return value such as TagListMessage") - retryTagsErrorCodes = flag.String("RetryTagsErrorCodes", "", "comma-separated list of error codes to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorMessages") - retryTagsErrorMessages = flag.String("RetryTagsErrorMessages", "", "comma-separated list of error messages to retry, must be used with RetryTagsListTagsType and same length as RetryTagsErrorCodes") - retryTagsTimeout = flag.Duration("RetryTagsTimeout", 1*time.Minute, "Timeout for retrying tag operations") - untagInCustomVal = flag.String("UntagInCustomVal", "", "untagInCustomVal") - untagInNeedTagKeyType = flag.String("UntagInNeedTagKeyType", "", "untagInNeedTagKeyType") + untagInNeedTagKeyType = flag.Bool("UntagInNeedTagKeyType", false, "untagInNeedTagKeyType") + untagInNeedTagType = flag.Bool("UntagInNeedTagType", false, "whether Untag input needs tag type") untagInTagsElem = flag.String("UntagInTagsElem", "TagKeys", "untagInTagsElem") untagOp = flag.String("UntagOp", "UntagResource", "untagOp") @@ -157,10 +152,6 @@ type TemplateData struct { ListTagsOutTagsElem string ParentNotFoundErrCode string ParentNotFoundErrMsg string - RetryTagsListTagsType string - RetryTagsErrorCodes []string - RetryTagsErrorMessages []string - RetryTagsTimeout string ServiceTagsMap bool SetTagsOutFunc string TagInCustomVal string @@ -176,13 +167,12 @@ type TemplateData struct { TagType string TagType2 string TagTypeAddBoolElem string - TagTypeAddBoolElemSnake string TagTypeIDElem string TagTypeKeyElem string TagTypeValElem string TagsFunc string UntagInCustomVal string - UntagInNeedTagKeyType string + UntagInNeedTagKeyType bool UntagInNeedTagType bool UntagInTagsElem string UntagOp string @@ -197,22 +187,6 @@ type TemplateData struct { WaitPollInterval string WaitTimeout string - // The following are specific to writing import paths in the `headerBody`; - // to include the package, set the corresponding field's value to true - ConnsPkg bool - FmtPkg bool - HelperSchemaPkg bool - InternalOptionPkg bool - LoggingPkg bool - NamesPkg bool - SkipAWSImp bool - SkipServiceImp bool - SkipTypesImp bool - TfLogPkg bool - TfResourcePkg bool - TfSlicesPkg bool - TimePkg bool - IsDefaultListTags bool IsDefaultUpdateTags bool } @@ -252,18 +226,7 @@ func main() { clientType := fmt.Sprintf("*%s.Client", awsPkg) tagPackage := awsPkg - - var cleanRetryErrorCodes []string - for _, c := range strings.Split(*retryTagsErrorCodes, ",") { - if strings.HasPrefix(c, fmt.Sprintf("%s.", servicePackage)) || strings.HasPrefix(c, "types.") { - cleanRetryErrorCodes = append(cleanRetryErrorCodes, c) - } else { - cleanRetryErrorCodes = append(cleanRetryErrorCodes, fmt.Sprintf(`"%s"`, c)) - } - } - providerNameUpper := service.ProviderNameUpper() - templateData := TemplateData{ AWSService: awsPkg, ClientType: clientType, @@ -284,10 +247,6 @@ func main() { ListTagsOutTagsElem: *listTagsOutTagsElem, ParentNotFoundErrCode: *parentNotFoundErrCode, ParentNotFoundErrMsg: *parentNotFoundErrMsg, - RetryTagsListTagsType: *retryTagsListTagsType, - RetryTagsErrorCodes: cleanRetryErrorCodes, - RetryTagsErrorMessages: strings.Split(*retryTagsErrorMessages, ","), - RetryTagsTimeout: formatDuration(*retryTagsTimeout), ServiceTagsMap: *serviceTagsMap, SetTagsOutFunc: *setTagsOutFunc, TagInCustomVal: *tagInCustomVal, @@ -303,7 +262,6 @@ func main() { TagType: *tagType, TagType2: *tagType2, TagTypeAddBoolElem: *tagTypeAddBoolElem, - TagTypeAddBoolElemSnake: toSnakeCase(*tagTypeAddBoolElem), TagTypeIDElem: *tagTypeIDElem, TagTypeKeyElem: *tagTypeKeyElem, TagTypeValElem: *tagTypeValElem, @@ -329,6 +287,9 @@ func main() { } templateBody := newTemplateBody(*kvtValues) + templateFuncMap := template.FuncMap{ + "Snake": names.ToSnakeCase, + } d := g.NewGoFileDestination(filename) if *getTag || *listTags || *serviceTagsMap || *serviceTagsSlice || *updateTags { @@ -339,43 +300,43 @@ func main() { templateData.TagPackage = "" } - if err := d.BufferTemplate("header", templateBody.header, templateData); err != nil { + if err := d.BufferTemplate("header", templateBody.header, templateData, templateFuncMap); err != nil { g.Fatalf("generating file (%s): %s", filename, err) } } if *getTag { - if err := d.BufferTemplate("gettag", templateBody.getTag, templateData); err != nil { + if err := d.BufferTemplate("gettag", templateBody.getTag, templateData, templateFuncMap); err != nil { g.Fatalf("generating file (%s): %s", filename, err) } } if *listTags { - if err := d.BufferTemplate("listtags", templateBody.listTags, templateData); err != nil { + if err := d.BufferTemplate("listtags", templateBody.listTags, templateData, templateFuncMap); err != nil { g.Fatalf("generating file (%s): %s", filename, err) } } if *serviceTagsMap { - if err := d.BufferTemplate("servicetagsmap", templateBody.serviceTagsMap, templateData); err != nil { + if err := d.BufferTemplate("servicetagsmap", templateBody.serviceTagsMap, templateData, templateFuncMap); err != nil { g.Fatalf("generating file (%s): %s", filename, err) } } if *serviceTagsSlice { - if err := d.BufferTemplate("servicetagsslice", templateBody.serviceTagsSlice, templateData); err != nil { + if err := d.BufferTemplate("servicetagsslice", templateBody.serviceTagsSlice, templateData, templateFuncMap); err != nil { g.Fatalf("generating file (%s): %s", filename, err) } } if *updateTags { - if err := d.BufferTemplate("updatetags", templateBody.updateTags, templateData); err != nil { + if err := d.BufferTemplate("updatetags", templateBody.updateTags, templateData, templateFuncMap); err != nil { g.Fatalf("generating file (%s): %s", filename, err) } } if *waitForPropagation { - if err := d.BufferTemplate("waittagspropagated", templateBody.waitTagsPropagated, templateData); err != nil { + if err := d.BufferTemplate("waittagspropagated", templateBody.waitTagsPropagated, templateData, templateFuncMap); err != nil { g.Fatalf("generating file (%s): %s", filename, err) } } @@ -385,12 +346,6 @@ func main() { } } -func toSnakeCase(str string) string { - result := regexache.MustCompile("(.)([A-Z][a-z]+)").ReplaceAllString(str, "${1}_${2}") - result = regexache.MustCompile("([0-9a-z])([A-Z])").ReplaceAllString(result, "${1}_${2}") - return strings.ToLower(result) -} - func formatDuration(d time.Duration) string { if d == 0 { return "" diff --git a/internal/generate/tags/templates/service_tags_slice_body.gtpl b/internal/generate/tags/templates/service_tags_slice_body.gtpl index 08de40230c5..4151d19b6c2 100644 --- a/internal/generate/tags/templates/service_tags_slice_body.gtpl +++ b/internal/generate/tags/templates/service_tags_slice_body.gtpl @@ -13,7 +13,7 @@ func listOfMap(tags tftags.KeyValueTags) []any { names.AttrKey: key, names.AttrValue: aws.ToString(tags.KeyValue(key)), {{- if .TagTypeAddBoolElem }} - "{{ .TagTypeAddBoolElemSnake }}": aws.ToBool(tags.KeyAdditionalBoolValue(key, "{{ .TagTypeAddBoolElem }}")), + "{{ .TagTypeAddBoolElem | Snake }}": aws.ToBool(tags.KeyAdditionalBoolValue(key, "{{ .TagTypeAddBoolElem }}")), {{ end }} } }) @@ -183,7 +183,7 @@ func {{ .KeyValueTagsFunc }}(ctx context.Context, tags any{{ if .TagTypeIDElem } {{ if .TagTypeAddBoolElem }} tagData.AdditionalBoolFields = make(map[string]*bool) {{- if .TagTypeAddBoolElem }} - if v, ok := tfMap["{{ .TagTypeAddBoolElemSnake }}"].(bool); ok { + if v, ok := tfMap["{{ .TagTypeAddBoolElem | Snake }}"].(bool); ok { tagData.AdditionalBoolFields["{{ .TagTypeAddBoolElem }}"] = &v } {{- end }} diff --git a/internal/service/elb/generate.go b/internal/service/elb/generate.go index cfe17d7f687..4945e49cf98 100644 --- a/internal/service/elb/generate.go +++ b/internal/service/elb/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=LoadBalancerNames -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=LoadBalancerNames -TagInIDNeedValueSlice -TagKeyType=TagKeyOnly -UntagOp=RemoveTags -UntagInNeedTagKeyType=yes -UntagInTagsElem=Tags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=LoadBalancerNames -ListTagsInIDNeedValueSlice -ListTagsOutTagsElem=TagDescriptions[0].Tags -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=LoadBalancerNames -TagInIDNeedValueSlice -TagKeyType=TagKeyOnly -UntagOp=RemoveTags -UntagInNeedTagKeyType -UntagInTagsElem=Tags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/tags/key_value_tags.go b/internal/tags/key_value_tags.go index c763561a286..638cb58aaa8 100644 --- a/internal/tags/key_value_tags.go +++ b/internal/tags/key_value_tags.go @@ -12,7 +12,6 @@ import ( "strconv" "strings" - "github.com/YakDriver/regexache" "github.com/hashicorp/go-cty/cty" fwdiag "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -929,16 +928,6 @@ func (tags KeyValueTags) ResolveDuplicatesFramework(ctx context.Context, default return New(ctx, result).IgnoreConfig(ignoreConfig) } -// ToSnakeCase converts a string to snake case. -// -// For example, AWS Go SDK field names are in PascalCase, -// while Terraform schema attribute names are in snake_case. -func ToSnakeCase(str string) string { - result := regexache.MustCompile("(.)([A-Z][a-z]+)").ReplaceAllString(str, "${1}_${2}") - result = regexache.MustCompile("([0-9a-z])([A-Z])").ReplaceAllString(result, "${1}_${2}") - return strings.ToLower(result) -} - func normalizeTagsFromRaw(m map[string]cty.Value, incoming map[string]configTag, source tagSource) { for k, v := range m { if !v.IsNull() { diff --git a/internal/tags/key_value_tags_test.go b/internal/tags/key_value_tags_test.go index d664b299792..a57d9e0f894 100644 --- a/internal/tags/key_value_tags_test.go +++ b/internal/tags/key_value_tags_test.go @@ -2748,48 +2748,6 @@ func TestTagDataString(t *testing.T) { } } -func TestToSnakeCase(t *testing.T) { - t.Parallel() - - testCases := []struct { - Input string - Expected string - }{ - { - Input: "ARN", - Expected: "arn", - }, - { - Input: "PropagateAtLaunch", - Expected: "propagate_at_launch", - }, - { - Input: "ResourceId", - Expected: "resource_id", - }, - { - Input: "ResourceArn", - Expected: "resource_arn", - }, - { - Input: "ResourceARN", - Expected: "resource_arn", - }, - } - - for _, testCase := range testCases { - t.Run(testCase.Input, func(t *testing.T) { - t.Parallel() - - got := ToSnakeCase(testCase.Input) - - if got != testCase.Expected { - t.Errorf("got %s, expected %s", got, testCase.Expected) - } - }) - } -} - func TestKeyValueTagsString(t *testing.T) { t.Parallel() diff --git a/names/snake_test.go b/names/snake_test.go index b888bdc27cf..b621e1ca079 100644 --- a/names/snake_test.go +++ b/names/snake_test.go @@ -45,6 +45,21 @@ func TestToSnakeCase(t *testing.T) { input: "S3Bucket", expected: "s3_bucket", }, + { + name: "ARN", + input: "ARN", + expected: "arn", + }, + { + name: "ResourceArn", + input: "ResourceArn", + expected: "resource_arn", + }, + { + name: "ResourceARN", + input: "ResourceARN", + expected: "resource_arn", + }, } for _, testCase := range testCases { From 39ba4e915ff5ba51e79adf597f1ddfab9f273e08 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 15:57:22 -0400 Subject: [PATCH 17/24] 'internal/generate/namevaluesfilters/v2' -> 'internal/generate/namevaluesfilters'. --- internal/generate/namevaluesfilters/{v2 => }/file.tmpl | 0 internal/generate/namevaluesfilters/{v2 => }/main.go | 0 internal/namevaluesfilters/v2/generate.go | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename internal/generate/namevaluesfilters/{v2 => }/file.tmpl (100%) rename internal/generate/namevaluesfilters/{v2 => }/main.go (100%) diff --git a/internal/generate/namevaluesfilters/v2/file.tmpl b/internal/generate/namevaluesfilters/file.tmpl similarity index 100% rename from internal/generate/namevaluesfilters/v2/file.tmpl rename to internal/generate/namevaluesfilters/file.tmpl diff --git a/internal/generate/namevaluesfilters/v2/main.go b/internal/generate/namevaluesfilters/main.go similarity index 100% rename from internal/generate/namevaluesfilters/v2/main.go rename to internal/generate/namevaluesfilters/main.go diff --git a/internal/namevaluesfilters/v2/generate.go b/internal/namevaluesfilters/v2/generate.go index b990aefdc7f..b27a5fb706d 100644 --- a/internal/namevaluesfilters/v2/generate.go +++ b/internal/namevaluesfilters/v2/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/namevaluesfilters/v2/main.go +//go:generate go run ../../generate/namevaluesfilters/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. package v2 From d1d4437dcba9c19ff42a541dd7d432fd17dcba5f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 15:59:40 -0400 Subject: [PATCH 18/24] Some 'internal/namevaluesfilters/v2' -> 'internal/namevaluesfilters'. --- internal/generate/namevaluesfilters/file.tmpl | 2 +- internal/namevaluesfilters/{v2 => }/generate.go | 4 ++-- internal/namevaluesfilters/{v2 => }/service_filters_gen.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename internal/namevaluesfilters/{v2 => }/generate.go (65%) rename internal/namevaluesfilters/{v2 => }/service_filters_gen.go (99%) diff --git a/internal/generate/namevaluesfilters/file.tmpl b/internal/generate/namevaluesfilters/file.tmpl index 8b0dad97143..5fc91d2c3c2 100644 --- a/internal/generate/namevaluesfilters/file.tmpl +++ b/internal/generate/namevaluesfilters/file.tmpl @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 // Code generated by internal/generate/namevaluesfilters/v2/main.go; DO NOT EDIT. -package v2 +package namevaluesfilters import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports "github.com/aws/aws-sdk-go-v2/aws" diff --git a/internal/namevaluesfilters/v2/generate.go b/internal/namevaluesfilters/generate.go similarity index 65% rename from internal/namevaluesfilters/v2/generate.go rename to internal/namevaluesfilters/generate.go index b27a5fb706d..24ca10ad6ec 100644 --- a/internal/namevaluesfilters/v2/generate.go +++ b/internal/namevaluesfilters/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/namevaluesfilters/main.go +//go:generate go run ../generate/namevaluesfilters/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. -package v2 +package namevaluesfilters diff --git a/internal/namevaluesfilters/v2/service_filters_gen.go b/internal/namevaluesfilters/service_filters_gen.go similarity index 99% rename from internal/namevaluesfilters/v2/service_filters_gen.go rename to internal/namevaluesfilters/service_filters_gen.go index 111d36e2e7b..6eb2491dc6d 100644 --- a/internal/namevaluesfilters/v2/service_filters_gen.go +++ b/internal/namevaluesfilters/service_filters_gen.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 // Code generated by internal/generate/namevaluesfilters/v2/main.go; DO NOT EDIT. -package v2 +package namevaluesfilters import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports "github.com/aws/aws-sdk-go-v2/aws" From 6239e1776714c4f20015757e1861fdd4095d2d0e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 16:39:43 -0400 Subject: [PATCH 19/24] Complete 'internal/namevaluesfilters/v2' -> 'internal/namevaluesfilters'. --- internal/generate/namevaluesfilters/main.go | 14 +++++++------- internal/namevaluesfilters/{v2 => }/README.md | 4 ++-- .../service_generation_customizations.go | 2 +- .../namevaluesfilters/v2/name_values_filters.go | 16 ---------------- 4 files changed, 10 insertions(+), 26 deletions(-) rename internal/namevaluesfilters/{v2 => }/README.md (59%) rename internal/namevaluesfilters/{v2 => }/service_generation_customizations.go (98%) delete mode 100644 internal/namevaluesfilters/v2/name_values_filters.go diff --git a/internal/generate/namevaluesfilters/main.go b/internal/generate/namevaluesfilters/main.go index cad00cc100f..679438f7e54 100644 --- a/internal/generate/namevaluesfilters/main.go +++ b/internal/generate/namevaluesfilters/main.go @@ -12,7 +12,7 @@ import ( "text/template" "github.com/hashicorp/terraform-provider-aws/internal/generate/common" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" + namevaluesfilters "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -43,12 +43,12 @@ func main() { SliceServiceNames: sliceServiceNames, } templateFuncMap := template.FuncMap{ - "FilterPackage": namevaluesfiltersv2.ServiceFilterPackage, - "FilterPackagePrefix": namevaluesfiltersv2.ServiceFilterPackagePrefix, - "FilterType": namevaluesfiltersv2.ServiceFilterType, - "FilterTypeNameField": namevaluesfiltersv2.ServiceFilterTypeNameField, - "FilterTypeNameFunc": namevaluesfiltersv2.ServiceFilterTypeNameFunc, - "FilterTypeValuesField": namevaluesfiltersv2.ServiceFilterTypeValuesField, + "FilterPackage": namevaluesfilters.ServiceFilterPackage, + "FilterPackagePrefix": namevaluesfilters.ServiceFilterPackagePrefix, + "FilterType": namevaluesfilters.ServiceFilterType, + "FilterTypeNameField": namevaluesfilters.ServiceFilterTypeNameField, + "FilterTypeNameFunc": namevaluesfilters.ServiceFilterTypeNameFunc, + "FilterTypeValuesField": namevaluesfilters.ServiceFilterTypeValuesField, "ProviderNameUpper": names.ProviderNameUpper, } diff --git a/internal/namevaluesfilters/v2/README.md b/internal/namevaluesfilters/README.md similarity index 59% rename from internal/namevaluesfilters/v2/README.md rename to internal/namevaluesfilters/README.md index cf3527987a2..a98e0687a6e 100644 --- a/internal/namevaluesfilters/v2/README.md +++ b/internal/namevaluesfilters/README.md @@ -1,5 +1,5 @@ -# namevaluesfiltersv2 +# namevaluesfilters -The `namevaluesfilters/v2` package is designed to provide a consistent interface for handling AWS resource filtering with AWS SDK for Go v2. +The `namevaluesfilters` package is designed to provide a consistent interface for handling AWS resource filtering with AWS SDK for Go v2. This package implements a single `NameValuesFilters` type, which covers all filter handling logic, such as merging filters, via functions on the single type. The underlying implementation is compatible with Go operations such as `len()`. diff --git a/internal/namevaluesfilters/v2/service_generation_customizations.go b/internal/namevaluesfilters/service_generation_customizations.go similarity index 98% rename from internal/namevaluesfilters/v2/service_generation_customizations.go rename to internal/namevaluesfilters/service_generation_customizations.go index 9e140fb6fe2..8edcbabdb84 100644 --- a/internal/namevaluesfilters/v2/service_generation_customizations.go +++ b/internal/namevaluesfilters/service_generation_customizations.go @@ -3,7 +3,7 @@ // This file contains code generation customizations for each AWS Go SDK service. -package v2 +package namevaluesfilters import "fmt" diff --git a/internal/namevaluesfilters/v2/name_values_filters.go b/internal/namevaluesfilters/v2/name_values_filters.go deleted file mode 100644 index 18d0279d8b3..00000000000 --- a/internal/namevaluesfilters/v2/name_values_filters.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package v2 - -import ( - "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" -) - -type NameValuesFilters struct { - namevaluesfilters.NameValuesFilters -} - -func New(i interface{}) NameValuesFilters { - return NameValuesFilters{NameValuesFilters: namevaluesfilters.New(i)} -} From 819b22630824174d49ad519f9acac41da546ff19 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 16:40:44 -0400 Subject: [PATCH 20/24] 'internal/namevaluesfilters/v2' -> 'internal/namevaluesfilters' - imagebuilder. --- internal/service/imagebuilder/components_data_source.go | 3 +-- internal/service/imagebuilder/container_recipes_data_source.go | 3 +-- .../imagebuilder/distribution_configurations_data_source.go | 3 +-- internal/service/imagebuilder/image_pipelines_data_source.go | 3 +-- internal/service/imagebuilder/image_recipes_data_source.go | 3 +-- .../imagebuilder/infrastructure_configurations_data_source.go | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/internal/service/imagebuilder/components_data_source.go b/internal/service/imagebuilder/components_data_source.go index 2b073d63de6..8febf29b95e 100644 --- a/internal/service/imagebuilder/components_data_source.go +++ b/internal/service/imagebuilder/components_data_source.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -53,7 +52,7 @@ func dataSourceComponentsRead(ctx context.Context, d *schema.ResourceData, meta input := &imagebuilder.ListComponentsInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).ImageBuilderFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).ImageBuilderFilters() } if v, ok := d.GetOk(names.AttrOwner); ok { diff --git a/internal/service/imagebuilder/container_recipes_data_source.go b/internal/service/imagebuilder/container_recipes_data_source.go index 222958e55c7..d4c73deba61 100644 --- a/internal/service/imagebuilder/container_recipes_data_source.go +++ b/internal/service/imagebuilder/container_recipes_data_source.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -53,7 +52,7 @@ func dataSourceContainerRecipesRead(ctx context.Context, d *schema.ResourceData, input := &imagebuilder.ListContainerRecipesInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).ImageBuilderFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).ImageBuilderFilters() } if v, ok := d.GetOk(names.AttrOwner); ok { diff --git a/internal/service/imagebuilder/distribution_configurations_data_source.go b/internal/service/imagebuilder/distribution_configurations_data_source.go index 5eb8ef15a4f..fee149ac428 100644 --- a/internal/service/imagebuilder/distribution_configurations_data_source.go +++ b/internal/service/imagebuilder/distribution_configurations_data_source.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -47,7 +46,7 @@ func dataSourceDistributionConfigurationsRead(ctx context.Context, d *schema.Res input := &imagebuilder.ListDistributionConfigurationsInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).ImageBuilderFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).ImageBuilderFilters() } distributionConfigurations, err := findDistributionConfigurations(ctx, conn, input) diff --git a/internal/service/imagebuilder/image_pipelines_data_source.go b/internal/service/imagebuilder/image_pipelines_data_source.go index 2df87c2c836..bdc5a263104 100644 --- a/internal/service/imagebuilder/image_pipelines_data_source.go +++ b/internal/service/imagebuilder/image_pipelines_data_source.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -47,7 +46,7 @@ func dataSourceImagePipelinesRead(ctx context.Context, d *schema.ResourceData, m input := &imagebuilder.ListImagePipelinesInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).ImageBuilderFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).ImageBuilderFilters() } imagePipelines, err := findImagePipelines(ctx, conn, input) diff --git a/internal/service/imagebuilder/image_recipes_data_source.go b/internal/service/imagebuilder/image_recipes_data_source.go index a4342b16a8b..7e12d6fa4d5 100644 --- a/internal/service/imagebuilder/image_recipes_data_source.go +++ b/internal/service/imagebuilder/image_recipes_data_source.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -53,7 +52,7 @@ func dataSourceImageRecipesRead(ctx context.Context, d *schema.ResourceData, met input := &imagebuilder.ListImageRecipesInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).ImageBuilderFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).ImageBuilderFilters() } if v, ok := d.GetOk(names.AttrOwner); ok { diff --git a/internal/service/imagebuilder/infrastructure_configurations_data_source.go b/internal/service/imagebuilder/infrastructure_configurations_data_source.go index e009c2a4576..fdccc6f6ff4 100644 --- a/internal/service/imagebuilder/infrastructure_configurations_data_source.go +++ b/internal/service/imagebuilder/infrastructure_configurations_data_source.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -47,7 +46,7 @@ func dataSourceInfrastructureConfigurationsRead(ctx context.Context, d *schema.R input := &imagebuilder.ListInfrastructureConfigurationsInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).ImageBuilderFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).ImageBuilderFilters() } infrastructureConfigurations, err := findInfrastructureConfigurations(ctx, conn, input) From 1303152a41d20e90ee0a1725311541ad55771e5b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 16:40:46 -0400 Subject: [PATCH 21/24] 'internal/namevaluesfilters/v2' -> 'internal/namevaluesfilters' - licensemanager. --- internal/service/licensemanager/grants_data_source.go | 3 +-- .../service/licensemanager/received_licenses_data_source.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/service/licensemanager/grants_data_source.go b/internal/service/licensemanager/grants_data_source.go index e5b0d87c1b7..a11d5f2441e 100644 --- a/internal/service/licensemanager/grants_data_source.go +++ b/internal/service/licensemanager/grants_data_source.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -44,7 +43,7 @@ func dataSourceDistributedGrantsRead(ctx context.Context, d *schema.ResourceData input := &licensemanager.ListDistributedGrantsInput{} if v, ok := d.GetOk(names.AttrFilter); ok && v.(*schema.Set).Len() > 0 { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).LicenseManagerFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).LicenseManagerFilters() } grants, err := findDistributedGrants(ctx, conn, input) diff --git a/internal/service/licensemanager/received_licenses_data_source.go b/internal/service/licensemanager/received_licenses_data_source.go index a7553c0da90..5f55aa6abf9 100644 --- a/internal/service/licensemanager/received_licenses_data_source.go +++ b/internal/service/licensemanager/received_licenses_data_source.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -44,7 +43,7 @@ func dataSourceReceivedLicensesRead(ctx context.Context, d *schema.ResourceData, input := &licensemanager.ListReceivedLicensesInput{} if v, ok := d.GetOk(names.AttrFilter); ok && v.(*schema.Set).Len() > 0 { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).LicenseManagerFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).LicenseManagerFilters() } licenses, err := findReceivedLicenses(ctx, conn, input) From 6464a6df139cf32087b49ea74e440f479ea2bb11 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 16:40:51 -0400 Subject: [PATCH 22/24] 'internal/namevaluesfilters/v2' -> 'internal/namevaluesfilters' - rds. --- internal/service/rds/clusters_data_source.go | 3 +-- internal/service/rds/engine_version_data_source.go | 3 +-- internal/service/rds/instances_data_source.go | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/service/rds/clusters_data_source.go b/internal/service/rds/clusters_data_source.go index f7fc4f92ade..72ba778b7bb 100644 --- a/internal/service/rds/clusters_data_source.go +++ b/internal/service/rds/clusters_data_source.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -47,7 +46,7 @@ func dataSourceClustersRead(ctx context.Context, d *schema.ResourceData, meta in input := &rds.DescribeDBClustersInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).RDSFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).RDSFilters() } clusters, err := findDBClusters(ctx, conn, input, tfslices.PredicateTrue[*types.DBCluster]()) diff --git a/internal/service/rds/engine_version_data_source.go b/internal/service/rds/engine_version_data_source.go index 0d697e2d909..fe48eba3b35 100644 --- a/internal/service/rds/engine_version_data_source.go +++ b/internal/service/rds/engine_version_data_source.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -176,7 +175,7 @@ func dataSourceEngineVersionRead(ctx context.Context, d *schema.ResourceData, me } if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).RDSFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).RDSFilters() } if v, ok := d.GetOk("parameter_group_family"); ok { diff --git a/internal/service/rds/instances_data_source.go b/internal/service/rds/instances_data_source.go index b45e1b53555..119eb0684bb 100644 --- a/internal/service/rds/instances_data_source.go +++ b/internal/service/rds/instances_data_source.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/names" @@ -49,7 +48,7 @@ func dataSourceInstancesRead(ctx context.Context, d *schema.ResourceData, meta i input := &rds.DescribeDBInstancesInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).RDSFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).RDSFilters() } filter := tfslices.PredicateTrue[*types.DBInstance]() From 9605ee25595c3cd19b23b5093c183e4b31cbe1cc Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 16:40:52 -0400 Subject: [PATCH 23/24] 'internal/namevaluesfilters/v2' -> 'internal/namevaluesfilters' - route53resolver. --- .../service/route53resolver/query_log_config_data_source.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/service/route53resolver/query_log_config_data_source.go b/internal/service/route53resolver/query_log_config_data_source.go index 84f637c4778..96eb9206dfc 100644 --- a/internal/service/route53resolver/query_log_config_data_source.go +++ b/internal/service/route53resolver/query_log_config_data_source.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/create" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -71,7 +70,7 @@ func dataSourceQueryLogConfigRead(ctx context.Context, d *schema.ResourceData, m input := &route53resolver.ListResolverQueryLogConfigsInput{} if v, ok := d.GetOk(names.AttrFilter); ok && v.(*schema.Set).Len() > 0 { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).Route53ResolverFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).Route53ResolverFilters() } var configs []awstypes.ResolverQueryLogConfig From cdba5de00521dd7fe07de8fdf3cc5313eb491fd0 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 28 Oct 2024 16:40:53 -0400 Subject: [PATCH 24/24] 'internal/namevaluesfilters/v2' -> 'internal/namevaluesfilters' - secretsmanager. --- internal/service/secretsmanager/secrets_data_source.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/service/secretsmanager/secrets_data_source.go b/internal/service/secretsmanager/secrets_data_source.go index 164800db8a7..3a9102c56b4 100644 --- a/internal/service/secretsmanager/secrets_data_source.go +++ b/internal/service/secretsmanager/secrets_data_source.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -46,7 +45,7 @@ func dataSourceSecretsRead(ctx context.Context, d *schema.ResourceData, meta int input := &secretsmanager.ListSecretsInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).SecretsManagerFilters() + input.Filters = namevaluesfilters.New(v.(*schema.Set)).SecretsManagerFilters() } var results []types.SecretListEntry