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

modify terraform providers schema -json to include fields for default, plan_modifiers, and validators #35646

Closed
drewmullen opened this issue Aug 27, 2024 · 5 comments
Labels
enhancement new new issue not yet triaged

Comments

@drewmullen
Copy link
Contributor

drewmullen commented Aug 27, 2024

Terraform Version

latest

Use Cases

I want to improve the documentation generated from: https://github.com/hashicorp/terraform-plugin-docs

Attempted Solutions

you can jam a lot of information in to the description field

Proposal

the json schema generated from a provider / resource schema should include information information on:

  • default
  • plan_modifiers
  • validators
"resource_schemas": {
  "resource_name": {
    "version": 0,
    "block": {
      "attributes": {
        "type": {
          "type": "string",
          "description_kind": "plain",
          "optional": true,

          # new fields to add to schema
          "default": "default",
          "validators": [
            "validator description 1"
          ],
          "plan_modifers": [
            "plan mod description 1"
          ]
        }
      },

The plan modifiers could pull from descriptions provided by each. ex: https://github.com/hashicorp/terraform-plugin-framework/blob/main/resource/schema/stringplanmodifier/requires_replace.go#L27

Validators also seem to have the concept: https://github.com/hashicorp/terraform-plugin-framework-validators/blob/main/stringvalidator/any.go#L46

References

@crw
Copy link
Contributor

crw commented Aug 27, 2024

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

@jbardin
Copy link
Member

jbardin commented Sep 10, 2024

@drewmullen,

Thanks for filing the issue. Things like validators, plan modifiers, or even defaults are all essentially abstract actions that a provider takes based on various configuration parameters, not concrete values that can be represented in the schema. Since what you are looking for is more for documentation rather than data handling, and is outside of the control of the Terraform CLI, we can track the issue in the referenced framework issue rather than here.

Thanks!

@jbardin jbardin closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
@drewmullen
Copy link
Contributor Author

drewmullen commented Sep 10, 2024

@jbardin I appreciate your input.

Since what you are looking for is more for documentation...
...outside of the control of the Terraform CLI

If i may ask a clarifying quesiton: yes, they are descriptions but those are programmatically available to the schema from the providers / validators. The CLI is the tool that coordinates the providers, where else would this possibly be implemented? Users would like programatic information about the resources included in a provider...

Perhaps the purpose of the schema isn't clear to me... To me, the schema should communicate relevant information about the resource's schemas. Today it does that but is missing a significant amount of information

@jbardin
Copy link
Member

jbardin commented Sep 10, 2024

The schema is used by the CLI for type information, including function signatures. Terraform is essentially a statically typed language, and needs that metadata to manipulate, encode and decode the configuration and state values. This happens to give a good starting point for documentation generation, but its intended purpose was not for documentation. Some additions were made to assist in documentation generation, but in the long run a more extensible design needs to be created.

Having this be driven by the developer experience team working on the provider framework makes sure the additions are reflective of their needs first, and can be implemented outside of the core CLI if possible. If there are changes useful to have the core CLI, we can integrated those into the plugin protocol as expose them needed.

Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants