-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
RFC: Add option to suppress legacy facts #143
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #143 +/- ##
==========================================
- Coverage 94.93% 87.50% -7.44%
==========================================
Files 2 3 +1
Lines 158 168 +10
==========================================
- Hits 150 147 -3
- Misses 8 21 +13
☔ View full report in Codecov by Sentry. |
b9c17a6
to
f81d6eb
Compare
lib/rspec-puppet-facts.rb
Outdated
end | ||
|
||
RSpec.configure do |c| | ||
c.add_setting :default_facter_version, | ||
:default => RspecPuppetFacts.facter_version_for_puppet_version(Puppet.version) | ||
c.add_setting :facterdb_string_keys, :default => false | ||
c.add_setting :legacy_facts, :default => RspecPuppetFacts.legacy_facts_default_for_puppet_version(Puppet.version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following discussion with @ekohl perhaps this setting should get bumped up into rspec-puppet
itself so that it can be used by both rspec-puppet-facts
and the native facter implementation there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than putting the configuration in rspec-puppet, I think this can make sense as a start.
The next steps should be to drop fact sets from FacterDB without modern facts (IIRC Facter < 3) and rewrite all the code here to only use modern facts.
# @return [Boolean] Is the fact a legacy fact | ||
# @param [Symbol] fact Fact name | ||
def self.legacy_fact?(fact) | ||
legacy_facts.include?(fact) or fact.to_s.match(Regexp.union(legacy_fact_regexes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can store the union in a cache somewhere.
In Ruby it's common to use ||
and I think this could use match?
since you don't need the actual result.
legacy_facts.include?(fact) or fact.to_s.match(Regexp.union(legacy_fact_regexes)) | |
legacy_facts.include?(fact) || fact.to_s.match?(Regexp.union(legacy_fact_regexes)) |
f81d6eb
to
4986331
Compare
4986331
to
e87a0de
Compare
some rubocop autofix will help here, I'm fine with the general code. |
I'm not though! ;) Since |
By default legacy facts will be removed in Puppet 8. This change mimics that.