Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

generate/tags: Replace IgnoreAWS() with IgnoreSystem(<service name>) #30643

Merged
merged 4 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/generate/tags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var (

sdkVersion = flag.Int("AWSSDKVersion", sdkV1, "Version of the AWS SDK Go to use i.e. 1 or 2")
kvtValues = flag.Bool("KVTValues", false, "Whether KVT string map is of string pointers")
skipNamesImp = flag.Bool("SkipNamesImp", false, "Whether to skip importing names")
skipTypesImp = flag.Bool("SkipTypesImp", false, "Whether to skip importing types")
)

Expand Down Expand Up @@ -161,6 +162,7 @@ type TemplateData struct {
FmtPkg bool
HelperSchemaPkg bool
InternalTypesPkg bool
NamesPkg bool
SkipTypesImp bool
StrConvPkg bool
TfResourcePkg bool
Expand Down Expand Up @@ -232,6 +234,7 @@ func main() {
FmtPkg: *updateTags,
HelperSchemaPkg: awsPkg == "autoscaling",
InternalTypesPkg: *listTags || *serviceTagsMap || *serviceTagsSlice,
NamesPkg: *updateTags && !*skipNamesImp,
SkipTypesImp: *skipTypesImp,
StrConvPkg: awsPkg == "autoscaling",
TfResourcePkg: *getTag,
Expand Down
3 changes: 3 additions & 0 deletions internal/generate/tags/templates/v1/header_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ import (
{{- if .InternalTypesPkg }}
"github.com/hashicorp/terraform-provider-aws/internal/types"
{{- end }}
{{- if .NamesPkg }}
"github.com/hashicorp/terraform-provider-aws/names"
{{- end }}
)
14 changes: 7 additions & 7 deletions internal/generate/tags/templates/v1/update_tags_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
}

if len(updatedTags) > 0 {
input.{{ .TagInTagsElem }} = Tags(updatedTags.IgnoreAWS())
input.{{ .TagInTagsElem }} = Tags(updatedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}))
}

if len(removedTags) > 0 {
{{- if .UntagInNeedTagType }}
input.{{ .UntagInTagsElem }} = Tags(removedTags.IgnoreAWS())
input.{{ .UntagInTagsElem }} = Tags(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}))
{{- else if .UntagInNeedTagKeyType }}
input.{{ .UntagInTagsElem }} = TagKeys(removedTags.IgnoreAWS())
input.{{ .UntagInTagsElem }} = TagKeys(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}))
{{- else if .UntagInCustomVal }}
input.{{ .UntagInTagsElem }} = {{ .UntagInCustomVal }}
{{- else }}
Expand Down Expand Up @@ -72,13 +72,13 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
{{- end }}
{{- end }}
{{- if .UntagInNeedTagType }}
{{ .UntagInTagsElem }}: Tags(removedTags.IgnoreAWS()),
{{ .UntagInTagsElem }}: Tags(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})),
{{- else if .UntagInNeedTagKeyType }}
{{ .UntagInTagsElem }}: TagKeys(removedTags.IgnoreAWS()),
{{ .UntagInTagsElem }}: TagKeys(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})),
{{- else if .UntagInCustomVal }}
{{ .UntagInTagsElem }}: {{ .UntagInCustomVal }},
{{- else }}
{{ .UntagInTagsElem }}: aws.StringSlice(removedTags.IgnoreAWS().Keys()),
{{ .UntagInTagsElem }}: aws.StringSlice(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}).Keys()),
{{- end }}
}

Expand Down Expand Up @@ -110,7 +110,7 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
{{- if .TagInCustomVal }}
{{ .TagInTagsElem }}: {{ .TagInCustomVal }},
{{- else }}
{{ .TagInTagsElem }}: Tags(updatedTags.IgnoreAWS()),
{{ .TagInTagsElem }}: Tags(updatedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})),
{{- end }}
}

Expand Down
3 changes: 3 additions & 0 deletions internal/generate/tags/templates/v2/header_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ import (
{{- if .InternalTypesPkg }}
"github.com/hashicorp/terraform-provider-aws/internal/types"
{{- end }}
{{- if .NamesPkg }}
"github.com/hashicorp/terraform-provider-aws/names"
{{- end }}
)
14 changes: 7 additions & 7 deletions internal/generate/tags/templates/v2/update_tags_body.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
}

if len(updatedTags) > 0 {
input.{{ .TagInTagsElem }} = Tags(updatedTags.IgnoreAWS())
input.{{ .TagInTagsElem }} = Tags(updatedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}))
}

if len(removedTags) > 0 {
{{- if .UntagInNeedTagType }}
input.{{ .UntagInTagsElem }} = Tags(removedTags.IgnoreAWS())
input.{{ .UntagInTagsElem }} = Tags(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}))
{{- else if .UntagInNeedTagKeyType }}
input.{{ .UntagInTagsElem }} = TagKeys(removedTags.IgnoreAWS())
input.{{ .UntagInTagsElem }} = TagKeys(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}))
{{- else if .UntagInCustomVal }}
input.{{ .UntagInTagsElem }} = {{ .UntagInCustomVal }}
{{- else }}
Expand Down Expand Up @@ -72,13 +72,13 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
{{- end }}
{{- end }}
{{- if .UntagInNeedTagType }}
{{ .UntagInTagsElem }}: Tags(removedTags.IgnoreAWS()),
{{ .UntagInTagsElem }}: Tags(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})),
{{- else if .UntagInNeedTagKeyType }}
{{ .UntagInTagsElem }}: TagKeys(removedTags.IgnoreAWS()),
{{ .UntagInTagsElem }}: TagKeys(removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})),
{{- else if .UntagInCustomVal }}
{{ .UntagInTagsElem }}: {{ .UntagInCustomVal }},
{{- else }}
{{ .UntagInTagsElem }}: removedTags.IgnoreAWS().Keys(),
{{ .UntagInTagsElem }}: removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }}).Keys(),
{{- end }}
}

Expand Down Expand Up @@ -110,7 +110,7 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
{{- if .TagInCustomVal }}
{{ .TagInTagsElem }}: {{ .TagInCustomVal }},
{{- else }}
{{ .TagInTagsElem }}: Tags(updatedTags.IgnoreAWS()),
{{ .TagInTagsElem }}: Tags(updatedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})),
{{- end }}
}

Expand Down
5 changes: 3 additions & 2 deletions internal/service/accessanalyzer/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/acm/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/acmpca/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/amp/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/amplify/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/apigateway/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/apigatewayv2/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/appconfig/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/appflow/tags_gen.go

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

5 changes: 3 additions & 2 deletions internal/service/appintegrations/tags_gen.go

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

Loading