Skip to content

Conversation

paladin-devops
Copy link
Contributor

@paladin-devops paladin-devops commented Feb 7, 2025

Description

This PR adds support for the proxied Terraform Registry endpoint to go-tfe, for fetching modules, documented here.

Testing plan

Run integration tests, setting the TFE_TOKEN, OAUTH_CLIENT_GITHUB_TOKEN, and GITHUB_REGISTRY_NO_CODE_MODULE_IDENTIFIER environment variables.

External links

https://developer.hashicorp.com/terraform/cloud-docs/api-docs/private-registry/modules#hcp-terraform-registry-implementation

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ go test ./... -v -run TestFunctionsAffectedByChange
=== RUN   TestRegistryModulesReadRegistry
--- PASS: TestRegistryModulesReadRegistry (46.70s)
=== RUN   TestRegistryModulesReadRegistry/fetch_module_from_registry
    --- PASS: TestRegistryModulesReadRegistry/fetch_module_from_registry (39.41s)
PASS

...

@paladin-devops paladin-devops self-assigned this Feb 7, 2025
@paladin-devops paladin-devops changed the title Support proxied Terraform registry endpoints Support proxied Terraform registry endpoint Feb 10, 2025
This tests reading a module from the registry.
@paladin-devops paladin-devops marked this pull request as ready for review February 10, 2025 21:45
@paladin-devops paladin-devops requested a review from a team as a code owner February 10, 2025 21:45
@datadog-terraform-cloud-hashicorp
Copy link

datadog-terraform-cloud-hashicorp bot commented Feb 10, 2025

Datadog Report

Branch report: registry-get-module
Commit report: e05099a
Test service: hashicorp/go-tfe

✅ 0 Failed, 1422 Passed, 167 Skipped, 19m 22.23s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.1%)

🔻 Code Coverage Decreases vs Default Branch (1)

  • datadog-ci junit upload 59.2% (-0.1%) - Details

@@ -572,6 +636,38 @@ func (r *registryModules) Read(ctx context.Context, moduleID RegistryModuleID) (

return rm, nil
}

// ReadRegistry fetches a registry module from the Terraform Registry.
func (r *registryModules) ReadRegistry(ctx context.Context, moduleID RegistryModuleID, version string) (*TerraformRegistryModule, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called ReadByVersion? It's returning a module but the function is called ReadRegistry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the proxied registry endpoint here always requires that the version be provided, but maybe a better name would be ReadFromRegistry? Perhaps @hashicorp/tf-core-cloud has an ideal name in mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method takes a version param, does it read the module or module-version?

A name suggestion would be something like ReadTerraformRegistryModule

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reads the module.

I will update this to be that name instead!

* rename the function

* remove unnecessary comment

* remove unnecessary call to fetch org in test

* update new method comment
@paladin-devops paladin-devops merged commit fdaf8ec into main Feb 18, 2025
7 checks passed
@paladin-devops paladin-devops deleted the registry-get-module branch February 18, 2025 22:11
Copy link

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

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