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

PoC: Super simple Plugin Framework data source self-registration #26101

Merged
merged 41 commits into from
Sep 9, 2022

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Aug 2, 2022

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

Relates #26027.
Relates #25715.
Relates #25606.

Introduces a naive self-registration mechanism for data sources implemented using Terraform Plugin Framework.
The ideas can be extended to resources implemented using Terraform Plugin Framework and resources and data sources implemented using Terraform Plugin SDK v2.

  • In internal/intf (package name up for discussion), two interfaces ServiceData and ProviderData are defined (type names up for discussion). ProviderData is the interface implemented by the (primary) provider's Meta value (currently conns.AWSClient). ServiceData is implemented by a structure defined in each service package.
  • In the internal/service/meta package a structure implementing intf.ServiceData is defined. It implements a very simple registry that can be added to in init methods. In future this can be generated for each service package.
  • The conns.AWSClient structure is modified to implement intf.ProviderData, including returning a map of intf.ServiceDatas.
  • The (primary) Terraform Plugin SDK v2 provider's initialization and configuration have been rejigged slightly so that an initialized, but unconfigured until ConfigureContextFunc is called, conns.AWSClient is available (via the intf.ProviderData) for the Terraform Plugin Framework provider to use.
  • The Terraform Plugin Framework provider uses the intf.ProviderData passed during initialization to build the data source (and in future resource) maps returned to Terraform core.

@github-actions github-actions bot added client-connections Pertains to the AWS Client and service connections. generators Relates to code generators. provider Pertains to the provider itself, rather than any interaction with AWS. service/meta tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. and removed tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. provider Pertains to the provider itself, rather than any interaction with AWS. client-connections Pertains to the AWS Client and service connections. generators Relates to code generators. service/meta labels Aug 2, 2022
@ewbankkit ewbankkit added provider Pertains to the provider itself, rather than any interaction with AWS. service/meta labels Aug 2, 2022
@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. and removed documentation Introduces or discusses updates to documentation. labels Sep 2, 2022
@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label Sep 2, 2022
@ewbankkit ewbankkit changed the title [WIP] Super simple Plugin Framework data source self-registration PoC: Super simple Plugin Framework data source self-registration Sep 9, 2022
@ewbankkit
Copy link
Contributor Author

% make testacc TESTARGS='-run=TestAccMetaARNDataSource_' PKG=meta ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/meta/... -v -count 1 -parallel 2  -run=TestAccMetaARNDataSource_ -timeout 180m
=== RUN   TestAccMetaARNDataSource_basic
=== PAUSE TestAccMetaARNDataSource_basic
=== RUN   TestAccMetaARNDataSource_s3Bucket
=== PAUSE TestAccMetaARNDataSource_s3Bucket
=== CONT  TestAccMetaARNDataSource_basic
=== CONT  TestAccMetaARNDataSource_s3Bucket
--- PASS: TestAccMetaARNDataSource_basic (13.63s)
--- PASS: TestAccMetaARNDataSource_s3Bucket (13.84s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/meta	18.027s
% make testacc TESTARGS='-run=TestAccMediaLive_serial/MultiplexProgram' PKG=medialive
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/medialive/... -v -count 1 -parallel 20  -run=TestAccMediaLive_serial/MultiplexProgram -timeout 180m
=== RUN   TestAccMediaLive_serial
=== RUN   TestAccMediaLive_serial/MultiplexProgram
=== RUN   TestAccMediaLive_serial/MultiplexProgram/basic
=== RUN   TestAccMediaLive_serial/MultiplexProgram/disappears
--- PASS: TestAccMediaLive_serial (119.57s)
    --- PASS: TestAccMediaLive_serial/MultiplexProgram (119.57s)
        --- PASS: TestAccMediaLive_serial/MultiplexProgram/basic (62.74s)
        --- PASS: TestAccMediaLive_serial/MultiplexProgram/disappears (56.83s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/medialive	123.758s
% make testacc TESTARGS='-run=TestAccVPC_basic' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccVPC_basic -timeout 180m
=== RUN   TestAccVPC_basic
=== PAUSE TestAccVPC_basic
=== CONT  TestAccVPC_basic
--- PASS: TestAccVPC_basic (21.14s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	25.347s

@ewbankkit ewbankkit merged commit 4bdb205 into main Sep 9, 2022
@ewbankkit ewbankkit deleted the f-simple-service-self-registration branch September 9, 2022 21:23
@github-actions github-actions bot added this to the v4.31.0 milestone Sep 9, 2022
@github-actions
Copy link

This functionality has been released in v4.31.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. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
client-connections Pertains to the AWS Client and service connections. documentation Introduces or discusses updates to documentation. generators Relates to code generators. provider Pertains to the provider itself, rather than any interaction with AWS. service/codepipeline Issues and PRs that pertain to the codepipeline service. size/XL Managed by automation to categorize the size of a PR. sweeper Pertains to changes to or issues with the sweeper. 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.

2 participants