-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Property validation should allow for cross-property validation; lazy property validation should always be forced at converge time before running the action #6505
Comments
can you solve this problem a lot easier by just writing an action_helper like the only real utility to doing property validation in the resource is to catch errors at compile time. if you're requiring an action and doing validation between properties, then you're already going to have to lazy validation to converge time (when you have that information accurately available), and might as well do it a lot more directly in the action class itself. |
This kind of thing usually belongs in |
even in |
Yes what I’ve been doing so far is an action helper method like you’ve described. If youre not interested in implementing this and think the helper is a better approach thats fine with me. |
Yeah, the action helper approach is much clearer behavior on both sides (both for the core chef author of the properties code, and for the writer of custom resources). A meta-question is if you went down this road due to being excessively paranoid about input validation. We used to do a lot of regex checking against e.g. usernames in core chef, but when you go down that road and start worrying about UTF-8 and Latin-1 and all the variations, and strange hacks people use for directory services, then the result was that we just banned a few always-bad characters like ':' on unix-related usernames, and then rely on the underlying O/S useradd to barf for us and catch the ShellOut exception. Trying to precisely replicate the validation that different platforms used across all the different O/S distros and versions was just going to be a neverending source of bugs and pain -- so instead of having Chef do validation we allowed the distro to be the source of truth... Just something to consider... |
Doing this as validation in |
I think we also have issues around if you lazy a required value and such as well. We should really run through all the properties and force validation at converge time before running the action to make sure that all lazy validation is forced to be run. |
We have the |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I want to be able to validate properties of custom resources using the
callbacks
validator as described in the docs with more complexity:I quickly looked through the validator code and I think there are two possible approaches to this:
callback
lambdas to also receive theresource
object with access to other properties and the action:callback
lambdas to also receive the action, and introduce arequired_with
validator that requires at least one of the properties to be set:The text was updated successfully, but these errors were encountered: