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

tfsdk: Return warning diagnostic when using Attribute or Schema type DeprecationMessage field #93

Merged
merged 4 commits into from
Aug 16, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Aug 10, 2021

Closes #71

@bflad bflad added the bug Something isn't working label Aug 10, 2021
@bflad bflad requested a review from a team August 10, 2021 16:30
@bflad bflad added this to the v0.3.0 milestone Aug 10, 2021
@@ -344,4 +344,13 @@ func (a Attribute) validate(ctx context.Context, req ValidateAttributeRequest, r
return
}
}

if a.DeprecationMessage != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't we only want to return the error if the value wasn't null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we would! Good catch. Testing updated to catch this:

--- FAIL: TestAttributeValidate (0.00s)
    --- FAIL: TestAttributeValidate/deprecation-message-null (0.00s)
        attribute_test.go:1313: Unexpected response (+wanted, -got):   tfsdk.ValidateAttributeResponse{
            -   Diagnostics: []*tfprotov6.Diagnostic{
            -           &{
            -                   Severity:  s"WARNING",
            -                   Summary:   "Attribute Deprecated",
            -                   Detail:    "Use something else instead.",
            -                   Attribute: s`AttributeName("test")`,
            -           },
            -   },
            +   Diagnostics: nil,
              }

Fix will be included in next commit.

@@ -803,6 +803,39 @@ func TestAttributeValidate(t *testing.T) {
},
resp: ValidateAttributeResponse{},
},
"deprecation-message": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would love to see a test for when the value is:

  • present
  • absent
  • unknown

@bflad bflad requested a review from paddycarver August 16, 2021 17:17
@bflad bflad merged commit abe64d6 into main Aug 16, 2021
@bflad bflad deleted the b-DeprecationMessage-field branch August 16, 2021 17:40
@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 Sep 16, 2021
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.

Actually use DeprecationMessage on resources, data sources, providers, and attributes.
2 participants