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

fallback to hashicorp namespace if none is passed in go provider generation #728

Open
ansgarm opened this issue May 26, 2021 · 2 comments
Open
Labels
core-parity Better experience in Terraform Core than CDKTF enhancement New feature or request language/golang priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. providers

Comments

@ansgarm
Copy link
Member

ansgarm commented May 26, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue 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 issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Imports for generated providers in Go are currently nested according to their namespace.
So, for example:

"cdk.tf/go/stack/generated/hashicorp/random"

However, this only happens if the namespace is explicitly passed in cdktf.json:

"terraformProviders": ["hashicorp/random@~> 3.1.0"],

As the shorthand without the prefix hashicorp/ is also allowed for official providers, this:

"terraformProviders": ["random@~> 3.1.0"],

should also result in the same import to work.

But, as the implementation currently does not fall back to hashicorp for an empty namespace, it results in generated code that needs to be imported from another directory:

"cdk.tf/go/stack/generated/random"

It should always have the same import name.

References

@danieldreier
Copy link
Contributor

This is a good pragmatic approach, but we should also print a warning or informational message when we do this. There is a long-term effort across Core and the registry to move away from implicit hashicorp namespacing, so we should help nudge people in the right direction if they omit the hashicorp namespace.

@danieldreier danieldreier added priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. core-parity Better experience in Terraform Core than CDKTF labels Jul 2, 2021
@mutahhir
Copy link
Member

mutahhir commented Oct 5, 2022

After #2146 hashicorp will be cdktf now, but Daniel's point stands regarding informational message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-parity Better experience in Terraform Core than CDKTF enhancement New feature or request language/golang priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. providers
Projects
None yet
Development

No branches or pull requests

3 participants