-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Move custom service-specific tagging functions to own namespace #11638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ewbankkit 👋 Thanks for taking a look at this.
We can simplify this (without requiring an extra Go package) by using build constraints, which will keep the "user interface" the same between custom and non-custom implementations (minus the function names).
Without any of these changes:
$ make gen
rm -f aws/internal/keyvaluetags/*_gen.go
go generate ./...
# github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags
./iam_tags.go:34:37: updatedTags.IgnoreAws().IamTags undefined (type KeyValueTags has no field or method IamTags)
./iam_tags.go:69:37: updatedTags.IgnoreAws().IamTags undefined (type KeyValueTags has no field or method IamTags)
aws/internal/keyvaluetags/key_value_tags.go:1: running "go": exit status 2
make: *** [gen] Error 1
Adjusting the top of aws/internal/keyvaluetags/iam_tags.go
to not build with the generate
build tag:
// +build !generate
package keyvaluetags
Adjusting the top of aws/internal/keyvaluetags/key_value_tags.go
to add the generate
build tag when running:
//go:generate go run -tags generate generators/servicetags/main.go
//go:generate go run -tags generate generators/listtags/main.go
//go:generate go run -tags generate generators/updatetags/main.go
Trying again:
$ make gen
rm -f aws/internal/keyvaluetags/*_gen.go
go generate ./...
$
To ensure generation via make gen
works as expected going forward, we should probably not add it to the test
or testacc
Makefile targets since it is time intensive, but instead implement a separate gencheck
target, similar to depscheck
, potentially something like:
gencheck:
@echo "==> Checking generated source code..."
@$(MAKE) gen
@git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'make gen' command and commit."; exit 1)
Then separately include that in CI, e.g. in the TravisCI unit testing matrix seems fine:
- go: "1.13.x"
name: "Code UnitTest"
script:
- make test
- make gencheck
Please reach out with any questions. 👍
@bflad Makes sense; I'll make changes today. |
This ensures that `make gen` succeeds.
This reverts commit 2e6008bbe4c1e33ad6ed4dc08019e207cd29939e.
This reverts commit 2d050db0cf29919336f9b1b1898856601763403b.
…valuetags implementations.
If there are differences we get an error like: % make gencheck ==> Checking generated source code... rm -f aws/internal/keyvaluetags/*_gen.go go generate ./... GNUmakefile | 6 ++++++ 1 file changed, 6 insertions(+) Unexpected difference in directories after code generation. Run 'make gen' command and commit. make: *** [gencheck] Error 1 If there are no differences: % make gencheck ==> Checking generated source code... rm -f aws/internal/keyvaluetags/*_gen.go go generate ./...
2e6008b
to
eebc630
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for those updates, @ewbankkit, looks good 🚀
This has been released in version 2.48.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
This ensures that
make gen
succeeds.Community Note
Closes #11637.
Release note for CHANGELOG:
Output from acceptance testing: