Skip to content

fix: use filter_set and then the .names methode#276

Merged
rwaffen merged 5 commits intovoxpupuli:mainfrom
rwaffen:update_outputs
Mar 5, 2026
Merged

fix: use filter_set and then the .names methode#276
rwaffen merged 5 commits intovoxpupuli:mainfrom
rwaffen:update_outputs

Conversation

@rwaffen
Copy link
Copy Markdown
Member

@rwaffen rwaffen commented Mar 5, 2026

this has the benefit that it also works with empty sets and does not raise an error when trying to map empty arrays for names

@rwaffen rwaffen added the bug Something isn't working label Mar 5, 2026
Comment thread plans/patch_batch.pp
# get nodes that are 'clean' from health check results
$nodes_to_patch = ($health_checks.filter_set |$item| { $item.value['state'] == 'clean' }).map |$n| { $n.target }
$health_check_failed = ($health_checks.filter_set |$item| { $item.status == 'failure' }).map |$n| { $n.name }.sort
$health_check_failed = ($health_checks.filter_set |$item| { $item.status == 'failure' }).names
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh lol, I wasn't aware of .names

Copy link
Copy Markdown
Member Author

@rwaffen rwaffen Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works only with sets. if you .filter an ok_set you dont really have a set anymore and that does not work, so i use filter_set and then can use .names 🤷

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have this as a bookmark and should read it more ofter 😄
https://help.puppet.com/bolt/current/topics/bolt_types_reference.htm

@rwaffen rwaffen merged commit 25396e3 into voxpupuli:main Mar 5, 2026
14 checks passed
@rwaffen rwaffen deleted the update_outputs branch March 5, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants