-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
Track source of vars #66102
Track source of vars #66102
Conversation
b9e6e6c
to
1edb2d0
Compare
1edb2d0
to
e51fe8f
Compare
Does this implementation only tag the toplevel vars with source? If so, you should add a comment in a few places (I don't see an obvious single place where the comment should live) that notes that is the case. |
Yes, this only tracks top-level vars. I'm not even sure how you would track non-top-level vars to make it meaningful to add that comment. |
But the fact that it is very hard to track non-top-level vars is not a reason not to comment that only toplevel vars are tracked. |
a3aad60
to
3153fed
Compare
Added a couple of suggestions for comments pointing to the primary documentation of how vars source tracking works. Suggestion for the docstring of the new classmethod that might make it clearer to someone coming fresh to the code. Looks good to me after the first two are merged. The docstring change is at your option. |
rebuild_merge |
Failing tests are unrelated to this PR. Merging. |
SUMMARY
Track the source of variables when calling
get_vars()
inVarsManager
This is useful for debugging where ansible is getting a particular variable and for doing things like throwing deprecation warnings when using variables from certain sources (such as top-level facts).
This implementation cheats a bit by tracking which precedence level (and which file source, if available) a var comes from as the varset is built in
get_vars()
, rather than tracking each var from its original source. While creating a variable proxy/wrapper class and using it for each var would be the "better" approach, it's not practical to do so for simple variable types such asbool
andint
without breaking a lot of things or requiring a lot of hacks, mostly due to the JSON encoder.This PR is the spiritual successor for #41811
ISSUE TYPE
COMPONENT NAME
VarsManager
ADDITIONAL INFORMATION
N/A