Repository navigation
Conversation
A two-segment name, namespace/type, is a provider. Versions come from the Provider Registry Protocol's version list, which every registry serves, with each version's protocols and platforms in its metadata. The package reads registry.terraform.io's provider details and falls back to the version list on registries that have none, such as registry.opentofu.org. Providers declare no dependencies, and have no single download URL, since each platform has its own archive.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Terraform providers to the
terraformregistry, which so far handles modules only. Module dependencies already list providers asnamespace/type, so that's the name a provider takes here: two segments for a provider (hashicorp/random), three for a module (hashicorp/consul/aws), as in a source address without its hostname.Draft, because a few choices below need a decision first.
Behaviour
FetchVersionsreads the Provider Registry Protocol's version list,GET /v1/providers/{namespace}/{type}/versions. Every registry serves it (checked against registry.terraform.io and registry.opentofu.org). Each version hasprotocolsandplatforms(linux_amd64, …) in its metadata. The list is unordered, so versions are sorted newest first withvers.FetchPackagereads registry.terraform.io's provider details,GET /v1/providers/{namespace}/{type}: description, source repository, latest version, andtieranddownloadsin the metadata. Other registries answer 404 there; for them the package falls back to the version list, with the latest version fromcore.SelectLatestVersion.FetchDependenciesreturns none without a request, since providers declare none.FetchMaintainersreturns the namespace, as for modules.NotFoundError.URLs
RegistryandDocumentationlink tohttps://registry.terraform.io/providers/{namespace}/{type}/{version|latest}[/docs]. For any other base URL they're empty, since other registries have no pages at those paths.Downloadis empty for a provider: each platform has its own archive, named byGET /v1/providers/{namespace}/{type}/{version}/download/{os}/{arch}.PURLispkg:terraform/{namespace}/{type}@{version}, withrepository_urlfor any registry but the default one. It's built withpurl.New, so it doesn't depend on Add the terraform type proposed in purl-spec#889 purl#66 (which teachesMakePURLthe type).Open questions
download_url, filename and the SHA-256 from the download endpoint. That's one request per platform, about 15 for a typical provider, so I left it out ofFetchVersions. It could go in aFetchVersion, which onlyFetchVersionFromPURLcalls.RegistryandDocumentationempty off registry.terraform.io. The module URLs always point at registry.terraform.io whatever the base URL; I didn't change that here.Tests
internal/terraform/provider_test.go, against an HTTP test server with responses trimmed from registry.terraform.io and registry.opentofu.org:The module tests are unchanged. The new code was mutation-checked; each change fails a test.