You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common need in Jinja rendered states and files is to access nested attributes of pillar data, but you have to take steps to avoid referencing any undefined values in the chain with many non-trivial merged pillars - using myapp.cfg.pipeline.credentials.msk.keystore needs multiple levels of guard to avoid 'dict object' has no attribute 'msk' type errors. The default(...) construct doesn't help except when used for top-level items.
Describe the solution you'd like
Any nested element in chained attribute access which evaluates as Undefined should not throw an error, but continue to evaluate the whole reference as Undefined.
Jinja has supported a ChainableUndefined environment option since v2.11 in early 2020 which provides exactly this functionality at minimal implementation expense for the Salt project. The one significant complexity I foresee is how this should be optionally enabled - whether it can only be a global option, or should have a way to localise it to target states/files (and whether this applies transitively to include/imported files, rendered managed files etc).
Describe alternatives you've considered
Multiple levels of guard on all references - makes files much less readable/maintainable
Exhaustive setting of default values everywhere in pillar data - not always appropriate, bloats data and reduces maintainability
The text was updated successfully, but these errors were encountered:
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!
A common need in Jinja rendered states and files is to access nested attributes of pillar data, but you have to take steps to avoid referencing any undefined values in the chain with many non-trivial merged pillars - using
myapp.cfg.pipeline.credentials.msk.keystore
needs multiple levels of guard to avoid'dict object' has no attribute 'msk'
type errors. Thedefault(...)
construct doesn't help except when used for top-level items.Describe the solution you'd like
Any nested element in chained attribute access which evaluates as
Undefined
should not throw an error, but continue to evaluate the whole reference asUndefined
.Jinja has supported a
ChainableUndefined
environment option since v2.11 in early 2020 which provides exactly this functionality at minimal implementation expense for the Salt project. The one significant complexity I foresee is how this should be optionally enabled - whether it can only be a global option, or should have a way to localise it to target states/files (and whether this applies transitively to include/imported files, rendered managed files etc).Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: