opentofu icon indicating copy to clipboard operation
opentofu copied to clipboard

Stabilize OpenTofu module schema extraction feature

Open ghost opened this issue 1 year ago • 1 comments

The OpenTofu Registry Search currently uses a modified version of OpenTofu on the experiment/json_config_dump branch to extract module schema information. This branch has no PR open and risks being lost to a branch cleanup. Furthermore, the branch is not updated with main, meaning that new language features will likely break the schema extraction as modules start to adopt it.

We should stabilize this feature in line with the already-defined schema and merge it into main. This will also eliminate the need to create a custom build of OpenTofu for the Registry Search.

ghost avatar Feb 13 '25 07:02 ghost

This has some overlap with https://github.com/opentofu/opentofu/issues/2598, where what we ultimately accepted is a new command for generating a machine-readable representation of just the configuration without also generating a plan.

However, the requirements for registry documentation are slightly different in that we want a machine-readable representation of just one module, without the broader context of an overall configuration tree.

For example, we could continue to extend tofu show to also support tofu show -module=DIR -json as a variation of -config that just loads a single arbitrary module and returns a JSON description of it that follows the Configuration Representation except that the objects under "module_calls" would exclude the "module" property, which the normal format uses to describe the child modules in the module tree.

It might be nice to support a subset of this that can work without access to provider schemas -- which means that "expressions" could not be included in the resource objects, but other metadata could still be returned -- since that would make it possible to use this command against arbitrary modules without having to execute arbitrary providers. Supporting such a mode could then be a substitute for the command line tool from hashicorp/terraform-config-inspect, as long as we also extend the JSON configuration representation to include input variable and output value declarations.

apparentlymart avatar Apr 21 '25 21:04 apparentlymart

This issue describes one possible way to solve https://github.com/opentofu/opentofu/issues/2333, and so we're going to consolidate the discussion into that other issue that is now representing the use-cases rather than a specific implementation strategy to meet them.

apparentlymart avatar May 13 '25 16:05 apparentlymart