-
Notifications
You must be signed in to change notification settings - Fork 232
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: Allow self references with AllowOneOf, ExactlyOneOf, and RequiredWith in InternalValidate #418
helper/schema: Allow self references with AllowOneOf, ExactlyOneOf, and RequiredWith in InternalValidate #418
Conversation
…OneOf/ExactlyOneOf Reference: hashicorp#407 Reference: hashicorp#416 Includes TODO items for logic that needs adjustment to work as expected. `AtLeastOneOf` and `ExactlyOneOf` at the attribute level should not only allow self-reference, but also require it.
…ExactlyOneOf in InternalValidate Reference: hashicorp#407 Reference: hashicorp#416
helper/schema/schema.go
Outdated
@@ -948,6 +954,11 @@ func checkKeysAgainstSchemaFlags(k string, keys []string, topSchemaMap schemaMap | |||
return fmt.Errorf("%s cannot contain Computed(When) attribute (%s)", k, key) | |||
} | |||
} | |||
|
|||
if requireSelfReference && !foundSelfReference { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AtLeastOneOf
and ExactlyOneOf
were implemented with an idempotent line that adds itself and removes duplicate, it allows the self reference to be optional. I would change this PR to have a flag for allowSelfRef
and ditch the requirement for it, but rather disallow for ConflictsWith
(and possibly RequiredWith
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we remove that line in validateRequiredWith
I would actually ONLY have this error for ConflictsWith
, just to be consistent, I will approve either final implementation.
Per Alex's comment, may be worth referencing back to the RFC, there was some discussion about the requirement of the self reference, I think we landed on not requiring it for a reason, though I can't recall the reason 😂 |
I'll update this to be allow vs require and add |
…ow, add InternalValidate unit testing for RequiredWhen Reference: hashicorp#418 (review)
…ow, add InternalValidate unit testing for RequiredWhen Reference: hashicorp#418 (review)
Implementation updated and submitted v1 backport: #423 |
…ow, add InternalValidate unit testing for RequiredWhen Reference: #418 (review)
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. |
Reference: #407
Reference: #416