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

helper/schema: Additional Go documentation for Resource and Schema types #912

Merged
merged 2 commits into from
Mar 23, 2022

Conversation

bflad
Copy link
Member

@bflad bflad commented Mar 23, 2022

Closes #467
Closes #601
Closes #705
Closes #735

This also spends some cycles fixing the Go documentation for struct fields to be aligned with each field individually, so pkg.go.dev and the Go language server can appropriately show the matching documentation.

Reference: #467
Reference: #601
Reference: #735

This also spends some cycles fixing the Go documentation for struct fields to be aligned with each field individually, so pkg.go.dev and the Go language server can appropriately show the matching documentation.
@bflad bflad added the documentation Improvements or additions to documentation label Mar 23, 2022
@bflad bflad added this to the v2.13.0 milestone Mar 23, 2022
@bflad bflad requested a review from a team as a code owner March 23, 2022 02:15
Copy link
Contributor

@detro detro left a comment

Choose a reason for hiding this comment

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

Looks great, but I left some comments that could help clarify or enrich even further some passages.

Awesome stuff.

// The *ResourceData parameter contains the plan and state data for this
// managed resource instance. The available data in the Get* methods is the
// the proposed state, which is the merged data of the practitioner
// configuration and any CustomizeDiff field logic. The SetId method must
Copy link
Contributor

Choose a reason for hiding this comment

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

How would you feel about having the part The SetId method must be called... on it's own paragraph, instead of being part of this one?

It's just so to highlight it prominently.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, I'll do that here and below.


// When Deprecated is set, this attribute is deprecated.
// ExactlyOneOf is a set of attribute paths, including this attribute,
Copy link
Contributor

Choose a reason for hiding this comment

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

... including this attribute, ...

Will Terraform error if one sets the ExactlyOneOf inconsistently across the involved attributes? Will it notice if one omits the current attribute?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will Terraform error

AtLeastOneOf, ConflictsWith, ExactlyOneOf, and RequiredWith are SDK-only validation implementations.

if one sets the ExactlyOneOf inconsistently across the involved attributes

Inconsistent ExactlyOneOf implementations across attributes will result in the superset "winning". For example,

"attr1": {
  ExactlyOneOf: []string{"attr1", "attr2", "attr3"}
},
"attr2": {
  ExactlyOneOf: []string{"attr1", "attr2", "attr3"}
},
"attr3": {
  ExactlyOneOf: []string{"attr2", "attr3"}
},

Will trigger the validation error from attr1 and attr2 if attr1 and attr3 are both configured.

Will it notice if one omits the current attribute?

"attr1": {
  ExactlyOneOf: []string{"attr2", "attr3"}
},
"attr2": {
  ExactlyOneOf: []string{"attr1", "attr3"}
},
"attr3": {
  ExactlyOneOf: []string{"attr1", "attr2"}
},

Will trigger all three validation errors if any two are configured.

@bflad bflad merged commit 8c490f2 into main Mar 23, 2022
@bflad bflad deleted the bflad-Resource-docs branch March 23, 2022 18:35
@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 Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
2 participants