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

Fix URLs generated for non-Hashicorp providers #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

b-rad36
Copy link

@b-rad36 b-rad36 commented Dec 21, 2021

Previous fix (0.7.2) for Resource/Data Doc URLs didn't work for non-Hashicorp providers. Hashicorp providers, like AWS, Azure, Kubernetes are now working but the non-Hashicorp URLs generated from tfschema resource/data provider <name> are going to a 404 page.

Example:

tfschema resource browse okta_group

Creates the link: https://registry.terraform.io/providers/hashicorp/okta/latest/docs/resources/group
The correct link: https://registry.terraform.io/providers/okta/okta/latest/docs/resources/group

Note that the URL should be using /providers/okta/okta/ and not /providers/hashicorp/okta/.

This PR reverts the docBaseURL constant and buildXDocURL functions to their previous format but with the .html suffix removed for Data and Resource URLs.

Verify that the following are working:

tfschema resource browse okta_group
tfschema data browse okta_group

tfschema resource browse aws_security_group
tfschema data browse aws_security_group

@minamijoyo
Copy link
Owner

@b-rad36 Thank you for the patch. I also forgot to consider unofficial community providers.

I guess redirecting legacy URLs work only for backward compatibility before the registry exists and it doesn't work newly added community providers because there is no way to know their namespace. That is to say, depending on legacy URLs is not only fragile, but also never be comprehensive solution.

I think a simple solution is adding a new flag such as -source=okta/okta, which accepts a provider source syntax in Terraform v0.13+. This looks a bit redundant for browse command, but would be comprehensive solution.

An alternative is peeking into a lock file a.k.a .terraform.lock.hcl in Terraform v0.14+. Actually show and list commands have already peek into the lock file to find provider binary. It would work for most of case except for a case found duplicated entries using provider alias with a forked provider. A notable requirement using the lock file is that we need to run browse command in an initialized root module directory. It's not required for official providers, so peeking into the lock file should be optional and just ignore if not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants