Skip to content

Use tofu show -json -module=DIR to extract module metadata #340

@apparentlymart

Description

@apparentlymart

Currently the module metadata extraction uses an unreleased fork of OpenTofu CLI that has an extra command tofu metadata dump, written only for this purpose as a temporary solution:

cmd := exec.Command(command, "metadata", "dump", "-json")

In opentofu/opentofu#3003 and opentofu/opentofu#3013 we added an actually-documented alternative in the form of tofu show -json -module=DIR, which returns a subset of the JSON configuration representation which should include enough information to replace our use of tofu metadata dump.

At some point after OpenTofu v1.11.0 is released (thereby making these new features available in a stable release) we should switch to using the documented API instead of making a local build from a branch, and possibly consider making the automatic running of this automatically use the latest available non-prerelease version as described by our get.opentofu.org API, so it'll automatically adopt any improvements we release in future (though that's a tradeoff; fixing to a specific release until we intentionally change it means the registry UI is less likely to become broken if a future OpenTofu release has a bug.)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions