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

Fix Framework allows top-level schema attributes that conflict with Terraform meta-arguments #548

Merged
merged 4 commits into from Dec 12, 2022

Conversation

bendbennett
Copy link
Contributor

@bendbennett bendbennett commented Nov 21, 2022

Closes: #136

Once all references to tfsdk.Schema have been removed we can ammend fwschema/schema.go:

type Schema interface {
    /* ... */

    Validate() diag.Diagnostics
}

@bendbennett bendbennett added the bug Something isn't working label Nov 30, 2022
…ma and to provider metaschema to prevent the use of reserved names for top-level attributes and blocks and invalid names for attributes and blocks at any level of nesting (#136)
@bendbennett bendbennett marked this pull request as ready for review December 1, 2022 09:45
@bendbennett bendbennett requested a review from a team as a code owner December 1, 2022 09:45
@bflad bflad self-assigned this Dec 12, 2022
@bflad bflad added this to the v1.0.0 milestone Dec 12, 2022
Copy link
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks good to me 🚀 Just little things to followup on.

attributes := nestedObject.GetAttributes()

for k, v := range attributes {
d := validateAttributeFieldName(path.AtName(k), k, v)
Copy link
Member

Choose a reason for hiding this comment

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

Since the nested attributes might be done using list, map, or set mode, we'll also need to account for adding those intermediate steps (AtListIndex, AtMapKey, AtSetValue) to the path. We're not looking at a real configuration though, so it's a little awkward to make it "correct", although Terraform likely won't show the source configuration matching the path information when it is returned by the GetProviderSchema RPC.

Let's create a followup issue, but we should likely try to fix up this path information and consider including it in the diagnostic details in case it is not in Terraform's output. Maybe we can use something like the zero-value (e.g. AtListIndex(0), AtMapKey(""), AtSetValue(/* ? */)) for describing those intermediate path steps for static validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

blocks := nestedObject.GetBlocks()

for k, v := range blocks {
d := validateBlockFieldName(path.AtName(k), k, v)
Copy link
Member

Choose a reason for hiding this comment

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

Similarly for block pathing and block nesting modes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

provider/metaschema/schema.go Outdated Show resolved Hide resolved
provider/metaschema/schema.go Outdated Show resolved Hide resolved
provider/metaschema/schema_test.go Outdated Show resolved Hide resolved
Co-authored-by: Brian Flad <bflad417@gmail.com>
@bendbennett bendbennett merged commit 23973ba into main Dec 12, 2022
@bendbennett bendbennett deleted the bendbennett/issues-136 branch December 12, 2022 16:59
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 Jan 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Framework allows top-level schema attributes that conflict with Terraform meta-arguments
2 participants