Skip to content

[master] Access pillar data while rendering pillars#64043

Open
dwoz wants to merge 16 commits intosaltstack:masterfrom
dwoz:pillarwhilerender
Open

[master] Access pillar data while rendering pillars#64043
dwoz wants to merge 16 commits intosaltstack:masterfrom
dwoz:pillarwhilerender

Conversation

@dwoz
Copy link
Copy Markdown
Contributor

@dwoz dwoz commented Apr 8, 2023

What does this PR do?

Pillar dunder is now available in extension modules during pillar render

Fixes: #65724

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

@dwoz dwoz requested a review from a team as a code owner April 8, 2023 17:26
@dwoz dwoz requested review from twangboy and removed request for a team April 8, 2023 17:26
@salt-project-bot-prod-environment salt-project-bot-prod-environment bot changed the title [WIP] Access pillar data while rendering pillars [master][WIP] Access pillar data while rendering pillars Apr 8, 2023
s0undt3ch
s0undt3ch previously approved these changes Apr 8, 2023
@frebib
Copy link
Copy Markdown
Contributor

frebib commented Jul 5, 2023

An interesting thought I had was that it's probably not even necessary to call salt.loader.minion_mods() to update the pillar object- we could simply replace the pillar in the pack and save the overhead of reloading all of the modules

>>> mods = salt.loader.minion_mods(opts, utils=utils)
>>> mods.pack["__pillar__"]
{'foo': 'bar', 'baz': 123}
>>> mods["pillar.get"]("foo")
'bar'
>>> mods["pillar.get"]("baz")
123
>>> mods["pillar.get"]("aaaaaa")
''

>>> opts["pillar"].update({"aaaaaa": 5555})
>>> mods.pack["__pillar__"] = opts["pillar"]
>>> mods["pillar.get"]("aaaaaa")
5555

@frebib
Copy link
Copy Markdown
Contributor

frebib commented Jul 7, 2023

Yep, I can confirm that with some tweaks this does solve the same problem as my patch, but in a much less shitty way. Thanks @dwoz
I'd love to see this in 3007

@dwoz dwoz force-pushed the pillarwhilerender branch from 444dc4b to 21c5873 Compare November 8, 2023 22:19
@dwoz dwoz changed the title [master][WIP] Access pillar data while rendering pillars [master] Access pillar data while rendering pillars Nov 8, 2023
@dwoz dwoz force-pushed the pillarwhilerender branch from 36ef0c3 to 673960b Compare December 6, 2023 22:09
@twangboy
Copy link
Copy Markdown
Contributor

twangboy commented Apr 9, 2024

Looks like the failing tests are valid

twangboy
twangboy previously approved these changes Jul 3, 2025
twangboy
twangboy previously approved these changes Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] access pillar dunder in extension modules during pillar render

5 participants