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

Commit

Permalink
Merge branch 'master' into FACT-2569
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Filipovici committed Apr 28, 2020
2 parents b3124c2 + 2470182 commit bd4621e
Show file tree
Hide file tree
Showing 129 changed files with 1,918 additions and 671 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Metrics/ClassLength:
- 'lib/resolvers/windows/networking_resolver.rb'
- 'lib/custom_facts/util/collection.rb'
- 'lib/framework/core/options/option_store.rb'
- 'lib/framework/cli/cli.rb'

Style/DoubleNegation:
Exclude:
Expand Down
9 changes: 3 additions & 6 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-24 12:45:39 +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 @@ -71,8 +71,8 @@ RSpec/FilePath:
- 'spec/facter/resolvers/windows/system32_resolver_spec.rb'
- 'spec/facter/resolvers/windows/virtualization_resolver_spec.rb'
- 'spec/facter/resolvers/windows/win_os_description_resolver_spec.rb'
- 'spec/framework/config/block_list_spec.rb'
- 'spec/framework/config/config_reader_spec.rb'
- 'spec/framework/config/fact_groups_spec.rb'
- 'spec/framework/core/fact/external/external_fact_manager_spec.rb'
- 'spec/framework/core/fact/internal/internal_fact_manager_spec.rb'
- 'spec/framework/core/fact_loaders/class_discoverer_spec.rb'
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: 169
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
Expand Down Expand Up @@ -247,13 +247,10 @@ RSpec/VerifiedDoubles:
- 'spec/facter/resolvers/windows/uptime_resolver_spec.rb'
- 'spec/facter/resolvers/windows/virtualization_resolver_spec.rb'
- 'spec/facter/resolvers/windows/win_os_description_resolver_spec.rb'
- 'spec/framework/config/block_list_spec.rb'
- 'spec/framework/core/fact_loaders/external_fact_loader_spec.rb'
- 'spec/framework/core/fact_loaders/fact_loader_spec.rb'
- 'spec/framework/core/fact_manager_spec.rb'
- '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'
14 changes: 0 additions & 14 deletions block_groups.conf

This file was deleted.

169 changes: 169 additions & 0 deletions fact_groups.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"EC2": [
"ec2_metadata",
"ec2_userdata"
],
"GCE": [
"gce"
],
"augeas": [
"augeas",
"augeasversion"
],
"desktop management interface": [
"dmi",
"bios_vendor",
"bios_version",
"bios_release_date",
"boardassettag",
"boardmanufacturer",
"boardproductname",
"boardserialnumber",
"chassisassettag",
"manufacturer",
"productname",
"serialnumber",
"uuid",
"chassistype"
],
"file system": [
"mountpoints",
"filesystems",
"partitions"
],
"hypervisors": [
"hypervisors"
],
"id": [
"id",
"gid",
"identity"
],
"kernel": [
"kernel",
"kernelversion",
"kernelrelease",
"kernelmajversion"
],
"load_average": [
"load_averages"
],
"memory": [
"memory",
"memoryfree",
"memoryfree_mb",
"memorysize",
"memorysize_mb",
"swapfree",
"swapfree_mb",
"swapsize",
"swapsize_mb",
"swapencrypted"
],
"networking": [
"networking",
"hostname",
"ipaddress",
"ipaddress6",
"netmask",
"netmask6",
"network",
"network6",
"macaddress",
"interfaces",
"domain",
"fqdn",
"dhcp_servers"
],
"operating system": [
"os",
"operatingsystem",
"osfamily",
"operatingsystemrelease",
"operatingsystemmajrelease",
"hardwaremodel",
"architecture",
"lsbdistid",
"lsbdistrelease",
"lsbdistcodename",
"lsbdistdescription",
"lsbmajdistrelease",
"lsbminordistrelease",
"lsbrelease",
"macosx_buildversion",
"macosx_productname",
"macosx_productversion",
"macosx_productversion_major",
"macosx_productversion_minor",
"windows_edition_id",
"windows_installation_type",
"windows_product_name",
"windows_release_id",
"system32",
"selinux",
"selinux_enforced",
"selinux_policyversion",
"selinux_current_mode",
"selinux_config_mode",
"selinux_config_policy"
],
"path": [
"path"
],
"processor": [
"processors",
"processorcount",
"physicalprocessorcount",
"hardwareisa"
],
"ssh": [
"ssh",
"sshdsakey",
"sshrsakey",
"sshecdsakey",
"sshed25519key",
"sshfp_dsa",
"sshfp_rsa",
"sshfp_ecdsa",
"sshfp_ed25519"
],
"system profiler": [
"system_profiler",
"sp_boot_mode",
"sp_boot_rom_version",
"sp_boot_volume",
"sp_cpu_type",
"sp_current_processor_speed",
"sp_kernel_version",
"sp_l2_cache_core",
"sp_l3_cache",
"sp_local_host_name",
"sp_machine_model",
"sp_machine_name",
"sp_number_processors",
"sp_os_version",
"sp_packages",
"sp_physical_memory",
"sp_platform_uuid",
"sp_secure_vm",
"sp_serial_number",
"sp_smc_version_system",
"sp_uptime",
"sp_user_name"
],
"timezone": [
"timezone"
],
"uptime": [
"system_uptime",
"uptime",
"uptime_days",
"uptime_hours",
"uptime_seconds"
],
"virtualization": [
"virtual",
"is_virtual",
"cloud"
]
}
52 changes: 0 additions & 52 deletions lib/custom_facts/core/legacy_facter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def self.clear
# @api public
def self.reset
@collection = nil
reset_search_path!
end

# Loads all facts.
Expand All @@ -206,55 +205,4 @@ def self.reset
def self.loadfacts
collection.load_all
end

# Register directories to be searched for facts. The registered directories
# must be absolute paths or they will be ignored.
#
# @param dirs [String] directories to search
#
# @return [void]
#
# @api public
def self.search(*dirs)
@search_path += dirs
end

# Returns the registered search directories.
#
# @return [Array<String>] An array of the directories searched
#
# @api public
def self.search_path
@search_path.dup
end

# Reset the Facter search directories.
#
# @api private
# @return [void]
def self.reset_search_path!
@search_path = []
end

reset_search_path!

# Registers directories to be searched for external facts.
#
# @param dirs [Array<String>] directories to search
#
# @return [void]
#
# @api public
def self.search_external(dirs)
LegacyFacter::Util::Config.external_facts_dirs += dirs
end

# Returns the registered search directories.
#
# @return [Array<String>] An array of the directories searched
#
# @api public
def self.search_external_path
LegacyFacter::Util::Config.external_facts_dirs.dup
end
end
31 changes: 20 additions & 11 deletions lib/custom_facts/util/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ def self.windows_data_dir
ENV['ProgramData'] || ENV['APPDATA'] if LegacyFacter::Util::Config.windows?
end

def self.external_facts_dirs=(dir)
@external_facts_dirs = dir
def self.external_facts_dirs
Facter::Options.external_dir
end

def self.external_facts_dirs
@external_facts_dirs
def self.facts_cache_dir
@facts_cache_dir ||= setup_default_cache_dir
end

def self.setup_default_ext_facts_dirs
if LegacyFacter::Util::Root.root?
windows_dir = windows_data_dir
@external_facts_dirs = if windows_dir
[File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
else
['/opt/puppetlabs/facter/facts.d']
end
Facter::Options[:default_external_dir] = if windows_dir
[File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
else
['/opt/puppetlabs/facter/facts.d']
end
elsif ENV['HOME']
@external_facts_dirs =
Facter::Options[:default_external_dir] =
[File.expand_path(File.join(ENV['HOME'], '.puppetlabs', 'opt', 'facter', 'facts.d'))]
else
@external_facts_dirs = []
Facter::Options[:default_external_dir] = []
end
end

Expand All @@ -68,6 +68,15 @@ def self.override_binary_dir
@override_binary_dir
end

def self.setup_default_cache_dir
windows_dir = windows_data_dir
@facts_cache_dir = if windows_dir
File.join(windows_dir, 'PuppetLabs', 'facter', 'cache', 'cached_facts')
else
'/opt/puppetlabs/facter/cache/cached_facts'
end
end

def self.setup_default_override_binary_dir
@override_binary_dir = if LegacyFacter::Util::Config.windows?
nil
Expand Down
2 changes: 1 addition & 1 deletion lib/custom_facts/util/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def search_path

search_paths.delete_if { |path| !valid_search_path?(path) }

LegacyFacter.search_path.each do |path|
Facter::Options.custom_dir.each do |path|
if valid_search_path?(path)
search_paths << path
else
Expand Down
Loading

0 comments on commit bd4621e

Please sign in to comment.