Skip to content
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

Provide filter_results to refine a search #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Jul 21, 2023

rspec-puppet-facts has a pattern where it does a lot of small searches for every OS. By doing a single complex FacterDB.get_facts call to get the only supported operating systems and then further refining that result it can use the cache provided by FacterDB.get_facts.

This is quite hacky now because it duplicates internals from JGrep to avoid serializing to JSON and parsing that again. The conversions to symbols and back to strings is also inefficient.

voxpupuli/rspec-puppet-facts#158 was the inspiration for this.

lib/facterdb.rb Outdated
# @param filter [Object] The filter to convert to jgrep string
# @return [Array[Hash[Symbol, Any]]] Array of hashes of facts
def self.filter_results(results, filter)
# TODO: it's really inefficient to do to_s and to_sym all the time
Copy link
Member

Choose a reason for hiding this comment

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

I think we should rebase this for the facterdb 3 release when we switch to strings by default

rspec-puppet-facts has a pattern where it does a lot of small searches
for every OS. By doing a single complex FacterDB.get_facts call to get
the only supported operating systems and then further refining that
result it can use the cache provided by FacterDB.get_facts.

This is quite hacky now because it duplicates internals from JGrep to
avoid serializing to JSON and parsing that again.
@ekohl
Copy link
Member Author

ekohl commented Jun 17, 2024

Rebased, but not further tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants