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

Move custom service-specific tagging functions to own namespace #11638

Merged
merged 7 commits into from
Feb 5, 2020

Conversation

ewbankkit
Copy link
Contributor

This ensures that make gen succeeds.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #11637.

Release note for CHANGELOG:

NONE

Output from acceptance testing:

$ make gen
rm -f aws/internal/keyvaluetags/*_gen.go
go generate ./...
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSIAMRole_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSIAMRole_ -timeout 120m
=== RUN   TestAccAWSIAMRole_basic
=== PAUSE TestAccAWSIAMRole_basic
=== RUN   TestAccAWSIAMRole_basicWithDescription
=== PAUSE TestAccAWSIAMRole_basicWithDescription
=== RUN   TestAccAWSIAMRole_namePrefix
=== PAUSE TestAccAWSIAMRole_namePrefix
=== RUN   TestAccAWSIAMRole_testNameChange
=== PAUSE TestAccAWSIAMRole_testNameChange
=== RUN   TestAccAWSIAMRole_badJSON
=== PAUSE TestAccAWSIAMRole_badJSON
=== RUN   TestAccAWSIAMRole_disappears
=== PAUSE TestAccAWSIAMRole_disappears
=== RUN   TestAccAWSIAMRole_force_detach_policies
=== PAUSE TestAccAWSIAMRole_force_detach_policies
=== RUN   TestAccAWSIAMRole_MaxSessionDuration
=== PAUSE TestAccAWSIAMRole_MaxSessionDuration
=== RUN   TestAccAWSIAMRole_PermissionsBoundary
=== PAUSE TestAccAWSIAMRole_PermissionsBoundary
=== RUN   TestAccAWSIAMRole_tags
=== PAUSE TestAccAWSIAMRole_tags
=== CONT  TestAccAWSIAMRole_basic
=== CONT  TestAccAWSIAMRole_force_detach_policies
=== CONT  TestAccAWSIAMRole_tags
=== CONT  TestAccAWSIAMRole_PermissionsBoundary
=== CONT  TestAccAWSIAMRole_MaxSessionDuration
=== CONT  TestAccAWSIAMRole_testNameChange
=== CONT  TestAccAWSIAMRole_disappears
=== CONT  TestAccAWSIAMRole_namePrefix
=== CONT  TestAccAWSIAMRole_badJSON
=== CONT  TestAccAWSIAMRole_basicWithDescription
--- PASS: TestAccAWSIAMRole_badJSON (3.49s)
--- PASS: TestAccAWSIAMRole_disappears (17.58s)
--- PASS: TestAccAWSIAMRole_basic (22.59s)
--- PASS: TestAccAWSIAMRole_namePrefix (23.02s)
--- PASS: TestAccAWSIAMRole_force_detach_policies (23.27s)
--- PASS: TestAccAWSIAMRole_tags (36.03s)
--- PASS: TestAccAWSIAMRole_MaxSessionDuration (38.98s)
--- PASS: TestAccAWSIAMRole_testNameChange (41.11s)
--- PASS: TestAccAWSIAMRole_basicWithDescription (49.36s)
--- PASS: TestAccAWSIAMRole_PermissionsBoundary (76.93s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	76.988s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSUser_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSUser_ -timeout 120m
=== RUN   TestAccAWSUser_basic
=== PAUSE TestAccAWSUser_basic
=== RUN   TestAccAWSUser_disappears
=== PAUSE TestAccAWSUser_disappears
=== RUN   TestAccAWSUser_ForceDestroy_AccessKey
=== PAUSE TestAccAWSUser_ForceDestroy_AccessKey
=== RUN   TestAccAWSUser_ForceDestroy_LoginProfile
=== PAUSE TestAccAWSUser_ForceDestroy_LoginProfile
=== RUN   TestAccAWSUser_ForceDestroy_MFADevice
=== PAUSE TestAccAWSUser_ForceDestroy_MFADevice
=== RUN   TestAccAWSUser_ForceDestroy_SSHKey
=== PAUSE TestAccAWSUser_ForceDestroy_SSHKey
=== RUN   TestAccAWSUser_nameChange
=== PAUSE TestAccAWSUser_nameChange
=== RUN   TestAccAWSUser_pathChange
=== PAUSE TestAccAWSUser_pathChange
=== RUN   TestAccAWSUser_permissionsBoundary
=== PAUSE TestAccAWSUser_permissionsBoundary
=== RUN   TestAccAWSUser_tags
=== PAUSE TestAccAWSUser_tags
=== CONT  TestAccAWSUser_basic
=== CONT  TestAccAWSUser_nameChange
=== CONT  TestAccAWSUser_tags
=== CONT  TestAccAWSUser_permissionsBoundary
=== CONT  TestAccAWSUser_pathChange
=== CONT  TestAccAWSUser_ForceDestroy_LoginProfile
=== CONT  TestAccAWSUser_ForceDestroy_SSHKey
=== CONT  TestAccAWSUser_ForceDestroy_MFADevice
=== CONT  TestAccAWSUser_ForceDestroy_AccessKey
=== CONT  TestAccAWSUser_disappears
--- PASS: TestAccAWSUser_disappears (18.19s)
--- PASS: TestAccAWSUser_ForceDestroy_LoginProfile (23.50s)
--- PASS: TestAccAWSUser_ForceDestroy_SSHKey (24.28s)
--- PASS: TestAccAWSUser_ForceDestroy_AccessKey (24.31s)
--- PASS: TestAccAWSUser_ForceDestroy_MFADevice (24.48s)
--- PASS: TestAccAWSUser_basic (35.55s)
--- PASS: TestAccAWSUser_pathChange (36.48s)
--- PASS: TestAccAWSUser_tags (36.58s)
--- PASS: TestAccAWSUser_nameChange (37.06s)
--- PASS: TestAccAWSUser_permissionsBoundary (78.47s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	78.536s

@ewbankkit ewbankkit requested a review from a team January 17, 2020 16:48
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. service/iam Issues and PRs that pertain to the iam service. labels Jan 17, 2020
@ewbankkit ewbankkit changed the title Move custom service-specific functions to own namespace Move custom service-specific tagging functions to own namespace Jan 17, 2020
@bflad bflad self-assigned this Feb 5, 2020
Copy link
Contributor

@bflad bflad left a 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 bflad added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Feb 5, 2020
@ewbankkit
Copy link
Contributor Author

@bflad Makes sense; I'll make changes today.
Thanks.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 5, 2020
ewbankkit and others added 6 commits February 5, 2020 10:51
This ensures that `make gen` succeeds.
This reverts commit 2e6008bbe4c1e33ad6ed4dc08019e207cd29939e.
This reverts commit 2d050db0cf29919336f9b1b1898856601763403b.
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 ./...
@ghost ghost added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Feb 5, 2020
@bflad bflad added this to the v2.48.0 milestone Feb 5, 2020
Copy link
Contributor

@bflad bflad left a 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 🚀

@bflad bflad merged commit 4681395 into hashicorp:master Feb 5, 2020
@ewbankkit ewbankkit deleted the issue-11637 branch February 5, 2020 16:46
@ghost
Copy link

ghost commented Feb 7, 2020

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!

@ghost
Copy link

ghost commented Mar 27, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/iam Issues and PRs that pertain to the iam service. size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'make gen' fails
2 participants