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

Include base URL for docs links in machine-readable output #34660

Open
radeksimko opened this issue Feb 12, 2024 · 1 comment
Open

Include base URL for docs links in machine-readable output #34660

radeksimko opened this issue Feb 12, 2024 · 1 comment

Comments

@radeksimko
Copy link
Member

Context

There is a number of commands which produce machine-readable output, which is consumed by other projects, e.g. CDKTF or Terraform LS.

On occasion, this output may contain relative links and it may not be always clear to the consumer what to do with those relative links, i.e. how to convert them into absolute ones.

Additionally, the documentation has moved to different hostnames or paths in the past (from terraform.io to developer.hashicorp.com/terraform) and the machine-readable output should be able to reflect that somehow.

This has surfaced recently in #34510

Proposal

  • Either replace all relative links with absolute, i.e. include the whole base URL beginning with https://developer.hashicorp.com, or
  • produce an additional field in all these commands, such as "baseUri": "https://developer.hashicorp.com/terraform"

Considerations

It is possible that these same commands may at some point end up as the source of truth for generated docs and it is likely that we want to retain the ability to produce relative links there.

@apparentlymart
Copy link
Contributor

I find it kinda unfortunate that these URLs have ended up hard-coded in this way at all, but I don't really have a better idea for how to deal with it, so agree that we should accept that they are there and make them useful.

I don't really see much point in making the caller of these commands do relative URL resolution themselves, since either way both the base URL and the relative URL will be in this codebase. Therefore using absolute URLs seems like the simplest path both for our own implementation (we can treat each link independently under maintenance, and bulk-update them all together if we end up needing to) and for consumer ergonomics (so we can promise downstreams that we'll always give them absolute URLs and they don't need to worry about any local fixup logic).

We also keep old URLs redirecting to new URLs for a long as we possibly can after migrating content from place to place, so I'm not super concerned about the possibility of these moving to another place again.

There will of course still be some historical Terraform CLI releases that will emit relative URLs forever -- we're not going to retract them over this -- and so our own consumers like terraform-schema should probably have some support for resolving these relative to https://developer.hashicorp.com/ as hashicorp/terraform-schema#323 describes. But other consumers that don't need to support those older Terraform CLI versions can ignore it if they want to, once these older versions have become old enough to not be that concerning anymore.

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

No branches or pull requests

2 participants