Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/FACT-2565' into FACT-2565
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Filipovici committed Apr 24, 2020
2 parents 548be28 + 6f29c46 commit 4e50d8b
Show file tree
Hide file tree
Showing 104 changed files with 1,017 additions and 331 deletions.
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PLEASE LABEL YOUR PULL REQUEST ACCORDINGLY!

Choose only one of the following:

"backwards-incompatible" - use this label for PRs that breaks some old functionality

"feature" - use this label for new added functionality

"bugfix" - use this label for PRs that contain fixes

"maintenance" - use this label for PRs that contain trivial changes (eg. changes in unit tests)

Also please add "community" additional label if you're part of puppet community (special attention will be provided for those PRs).
6 changes: 2 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 1000`
# on 2020-04-15 10:09:42 +0300 using RuboCop version 0.74.0.
# on 2020-04-16 12:37:29 +0300 using RuboCop version 0.74.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -190,7 +190,7 @@ RSpec/SubjectStub:
- 'spec/custom_facts/util/fact_spec.rb'
- 'spec/custom_facts/util/resolution_spec.rb'

# Offense count: 179
# Offense count: 172
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
Expand Down Expand Up @@ -254,6 +254,4 @@ RSpec/VerifiedDoubles:
- 'spec/framework/core/session_cache_spec.rb'
- 'spec/framework/formatters/hocon_fact_formatter_spec.rb'
- 'spec/framework/formatters/json_fact_formatter_spec.rb'
- 'spec/framework/formatters/legacy_fact_formatter_spec.rb'
- 'spec/framework/formatters/yaml_fact_formatter_spec.rb'
- 'spec/mocks/util.rb'
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- bundle exec rubocop
- bundle exec rubycritic --no-browser -f console
- bundle exec rake spec
- bundle exec rake commits

- rvm: 2.5
script:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@


## [4.0.17](https://github.com/puppetlabs/facter-ng/tree/4.0.17) (2020-04-21)

[Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.16...4.0.17)

### Fixed

- \(FACT-2562\) Correctly load custom and external fact directories [\#458](https://github.com/puppetlabs/facter-ng/pull/458) ([IrimieBogdan](https://github.com/IrimieBogdan))



## [4.0.16](https://github.com/puppetlabs/facter-ng/tree/4.0.16) (2020-04-15)

[Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.15...4.0.16)
Expand Down
32 changes: 32 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,39 @@ Dir.glob(File.join('tasks/**/*.rake')).each { |file| load file }

task default: :spec

desc 'verify that commit messages match CONTRIBUTING.md requirements'
task(:commits) do
# This rake task looks at the summary from every commit from this branch not
# in the branch targeted for a PR. This is accomplished by using the
# TRAVIS_COMMIT_RANGE environment variable, which is present in travis CI and
# populated with the range of commits the PR contains. If not available, this
# falls back to `master..HEAD` as a next best bet as `master` is unlikely to
# ever be absent.
commit_range = ENV['TRAVIS_COMMIT_RANGE'].nil? ? 'master..HEAD' : ENV['TRAVIS_COMMIT_RANGE'].sub(/\.\.\./, '..')
puts "Checking commits #{commit_range}"
`git log --no-merges --pretty=%s #{commit_range}`.each_line do |commit_summary|
# This regex tests for the currently supported commit summary tokens: maint, doc, gem, or fact-<number>.
# The exception tries to explain it in more full.
if /^\((maint|doc|docs|gem|fact-\d+)\)|revert/i.match(commit_summary).nil?
raise "\n\n\n\tThis commit summary didn't match CONTRIBUTING.md guidelines:\n" \
"\n\t\t#{commit_summary}\n" \
"\tThe commit summary (i.e. the first line of the commit message) should start with one of:\n" \
"\t\t(FACT-<digits>) # this is most common and should be a ticket at tickets.puppet.com\n" \
"\t\t(docs)\n" \
"\t\t(docs)(DOCUMENT-<digits>)\n" \
"\t\t(maint)\n" \
"\t\t(gem)\n" \
"\n\tThis test for the commit summary is case-insensitive.\n\n\n"
else
puts commit_summary.to_s
end
puts '...passed'
end
end

def retrieve_from_keyboard
return unless ARGV =~ /changelog/

puts "Please provide the next release tag:\n"
next_version = $stdin.gets.chomp
raise(ArgumentError, ' The string that you entered is invalid!') unless /[0-9]+\.[0-9]+\.[0-9]+/.match?(next_version)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.16
4.0.17
9 changes: 6 additions & 3 deletions lib/facter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def fact(user_query)
# @api public
def reset
LegacyFacter.reset
Options[:custom_dir] = []
Options[:external_dir] = []
LegacyFacter.search(*Options.custom_dir)
LegacyFacter.search_external(Options.external_dir)
nil
Expand All @@ -145,6 +147,7 @@ def reset
#
# @api public
def search(*dirs)
Options[:custom_dir] += dirs
LegacyFacter.search(*dirs)
end

Expand All @@ -156,6 +159,7 @@ def search(*dirs)
#
# @api public
def search_external(dirs)
Options[:external_dir] += dirs
LegacyFacter.search_external(dirs)
end

Expand All @@ -165,7 +169,7 @@ def search_external(dirs)
#
# @api public
def search_external_path
LegacyFacter.search_external_path
Options.external_dir
end

# Returns the registered search directories for custom facts.
Expand All @@ -174,7 +178,7 @@ def search_external_path
#
# @api public
def search_path
LegacyFacter.search_path
Options.custom_dir
end

# Gets a hash mapping fact names to their values
Expand All @@ -186,7 +190,6 @@ def search_path
def to_hash
log_blocked_facts

reset
resolved_facts = Facter::FactManager.instance.resolve_facts
Facter::SessionCache.invalidate_all_caches
Facter::FactCollection.new.build_fact_collection!(resolved_facts)
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/swap/available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Available

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_free)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/swap/available_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_free)

[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/swap/total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Total

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_total)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/swap/total_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TotalBytes
def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_total)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/swap/used.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Used

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_used_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/system/available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Available

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:memfree)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/system/available_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:memfree)

[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/system/total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Total

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:total)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/system/total_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TotalBytes
def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:total)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/debian/memory/system/used.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Used

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:used_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/swap/available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Available

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_free)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/swap/available_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AvailableBytes
def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_free)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/swap/total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Total

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_total)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/swap/total_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TotalBytes
def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_total)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/swap/used.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Used

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:swap_used_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/system/available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Available

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:memfree)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/system/available_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AvailableBytes
def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:memfree)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/system/total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Total

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:total)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/system/total_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TotalBytes
def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:total)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/el/memory/system/used.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Used

def call_the_resolver
fact_value = Facter::Resolvers::Linux::Memory.resolve(:used_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/macosx/memory/swap/available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Available

def call_the_resolver
fact_value = Facter::Resolvers::Macosx::SwapMemory.resolve(:available_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/macosx/memory/swap/available_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AvailableBytes
def call_the_resolver
fact_value = Facter::Resolvers::Macosx::SwapMemory.resolve(:available_bytes)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/macosx/memory/swap/total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Total

def call_the_resolver
fact_value = Facter::Resolvers::Macosx::SwapMemory.resolve(:total_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/macosx/memory/swap/total_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TotalBytes
def call_the_resolver
fact_value = Facter::Resolvers::Macosx::SwapMemory.resolve(:total_bytes)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/macosx/memory/swap/used.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Used

def call_the_resolver
fact_value = Facter::Resolvers::Macosx::SwapMemory.resolve(:used_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/macosx/memory/system/available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Available

def call_the_resolver
fact_value = Facter::Resolvers::Macosx::SystemMemory.resolve(:available_bytes)
fact_value = Facter::BytesToHumanReadable.convert(fact_value)
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facts/macosx/memory/system/available_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AvailableBytes
def call_the_resolver
fact_value = Facter::Resolvers::Macosx::SystemMemory.resolve(:available_bytes)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::BytesConverter.to_mb(fact_value), :legacy)]
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
Expand Down
Loading

0 comments on commit 4e50d8b

Please sign in to comment.