facter 4.5.1 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/facter +1 -1
- data/lib/docs/generate.rb +1 -6
- data/lib/facter/custom_facts/core/directed_graph.rb +2 -4
- data/lib/facter/custom_facts/core/execution/base.rb +1 -1
- data/lib/facter/custom_facts/core/execution/posix.rb +6 -2
- data/lib/facter/custom_facts/core/execution/windows.rb +4 -1
- data/lib/facter/custom_facts/core/execution.rb +1 -1
- data/lib/facter/custom_facts/core/file_loader.rb +0 -4
- data/lib/facter/custom_facts/core/suitable.rb +1 -1
- data/lib/facter/custom_facts/util/collection.rb +2 -4
- data/lib/facter/custom_facts/util/confine.rb +4 -1
- data/lib/facter/custom_facts/util/fact.rb +1 -1
- data/lib/facter/custom_facts/util/loader.rb +2 -2
- data/lib/facter/custom_facts/util/resolution.rb +8 -4
- data/lib/facter/custom_facts/util/values.rb +1 -1
- data/lib/facter/facts/amzn/os/distro/release.rb +6 -1
- data/lib/facter/facts/amzn/os/release.rb +5 -0
- data/lib/facter/facts/linux/dmi/product/version.rb +19 -0
- data/lib/facter/facts/linux/kernelmajversion.rb +1 -1
- data/lib/facter/facts/macosx/is_virtual.rb +1 -1
- data/lib/facter/facts/macosx/virtual.rb +3 -3
- data/lib/facter/facts/mariner/os/release.rb +1 -1
- data/lib/facter/facts/photon/os/release.rb +1 -1
- data/lib/facter/facts/solaris/kernelmajversion.rb +1 -1
- data/lib/facter/facts/solaris/ldom.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/kvm.rb +1 -1
- data/lib/facter/facts/windows/interfaces.rb +1 -1
- data/lib/facter/framework/benchmarking/timer.rb +2 -2
- data/lib/facter/framework/cli/cli.rb +6 -8
- data/lib/facter/framework/cli/cli_launcher.rb +1 -1
- data/lib/facter/framework/config/fact_groups.rb +1 -1
- data/lib/facter/framework/core/cache_manager.rb +5 -6
- data/lib/facter/framework/core/fact_loaders/class_discoverer.rb +4 -3
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +1 -3
- data/lib/facter/framework/core/fact_manager.rb +4 -4
- data/lib/facter/framework/core/file_loader.rb +736 -733
- data/lib/facter/framework/core/options/config_file_options.rb +4 -6
- data/lib/facter/framework/formatters/hocon_fact_formatter.rb +3 -2
- data/lib/facter/framework/formatters/legacy_fact_formatter.rb +4 -4
- data/lib/facter/framework/logging/logger.rb +6 -6
- data/lib/facter/framework/logging/logger_helper.rb +10 -11
- data/lib/facter/framework/parsers/query_parser.rb +24 -20
- data/lib/facter/resolvers/aix/disks.rb +1 -1
- data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
- data/lib/facter/resolvers/aix/networking.rb +1 -1
- data/lib/facter/resolvers/aix/partitions.rb +2 -2
- data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
- data/lib/facter/resolvers/amzn/os_release_rpm.rb +40 -0
- data/lib/facter/resolvers/dmi.rb +2 -1
- data/lib/facter/resolvers/fips_enabled.rb +1 -1
- data/lib/facter/resolvers/freebsd/dmi.rb +1 -1
- data/lib/facter/resolvers/freebsd/swap_memory.rb +1 -1
- data/lib/facter/resolvers/freebsd/system_memory.rb +15 -7
- data/lib/facter/resolvers/freebsd/virtual.rb +1 -1
- data/lib/facter/resolvers/linux/hostname.rb +1 -1
- data/lib/facter/resolvers/macosx/dmi.rb +1 -1
- data/lib/facter/resolvers/macosx/filesystems.rb +1 -1
- data/lib/facter/resolvers/memory.rb +1 -1
- data/lib/facter/resolvers/networking.rb +3 -3
- data/lib/facter/resolvers/os_release.rb +1 -1
- data/lib/facter/resolvers/partitions.rb +2 -2
- data/lib/facter/resolvers/processors_lscpu.rb +2 -2
- data/lib/facter/resolvers/solaris/ffi/ffi.rb +2 -2
- data/lib/facter/resolvers/solaris/ffi/functions.rb +2 -2
- data/lib/facter/resolvers/solaris/mountpoints.rb +1 -1
- data/lib/facter/resolvers/solaris/networking.rb +2 -2
- data/lib/facter/resolvers/solaris/os_release.rb +2 -2
- data/lib/facter/resolvers/uname.rb +10 -6
- data/lib/facter/resolvers/virt_what.rb +2 -1
- data/lib/facter/resolvers/windows/memory.rb +3 -2
- data/lib/facter/resolvers/windows/product_release.rb +7 -7
- data/lib/facter/resolvers/xen.rb +3 -1
- data/lib/facter/util/aix/info_extractor.rb +1 -1
- data/lib/facter/util/aix/odm_query.rb +1 -1
- data/lib/facter/util/api_debugger.rb +2 -2
- data/lib/facter/util/facts/facts_utils.rb +2 -1
- data/lib/facter/util/facts/posix/virtual_detector.rb +8 -5
- data/lib/facter/util/facts/unit_converter.rb +2 -2
- data/lib/facter/util/file_helper.rb +1 -2
- data/lib/facter/util/macosx/system_profile_executor.rb +3 -3
- data/lib/facter/util/resolvers/fingerprint.rb +1 -7
- data/lib/facter/util/resolvers/networking/networking.rb +4 -3
- data/lib/facter/util/resolvers/networking/primary_interface.rb +2 -0
- data/lib/facter/util/resolvers/ssh.rb +1 -9
- data/lib/facter/util/resolvers/ssh_helper.rb +2 -0
- data/lib/facter/util/utils.rb +2 -2
- data/lib/facter/version.rb +1 -1
- data/lib/facter.rb +7 -0
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cde774257133c7283c2bd6a697e8892d2614ee63d89b52d64648eb6cb8e92c2
|
4
|
+
data.tar.gz: a24ba725108a86b796e07cfd01f3f9ed11c03558f7fba8df77e213fbc48c3c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa441a192b26deafd97f2cda183d2aff0194dcdbd40fb7c75c610cb8e3678fbefdd29d16d7f262da3d6e45f89f99a87cdaf305100552e1d8bf4050a4fe7562d
|
7
|
+
data.tar.gz: a512d5720fcd1d4af1b4334a1d99831642c0cecf9f0f6a61d37d9561fa83b2eda4f1724c81b2afb324502a7171a77c7b837275f3f8530de872c6fc51d19c9217
|
data/bin/facter
CHANGED
data/lib/docs/generate.rb
CHANGED
@@ -17,12 +17,7 @@ def format_facts(fact_hash)
|
|
17
17
|
scope = OpenStruct.new({
|
18
18
|
facts: fact_hash
|
19
19
|
})
|
20
|
-
|
21
|
-
erb = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
22
|
-
ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
|
23
|
-
else
|
24
|
-
ERB.new(File.read(PATH_TO_TEMPLATE), nil, '-')
|
25
|
-
end
|
20
|
+
erb = ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
|
26
21
|
erb.result(scope.instance_eval { binding })
|
27
22
|
end
|
28
23
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Facter
|
2
4
|
module Core
|
3
5
|
module Execution
|
@@ -36,7 +38,8 @@ module Facter
|
|
36
38
|
exe = nil
|
37
39
|
args = nil
|
38
40
|
|
39
|
-
|
41
|
+
match = command.match(DOUBLE_QUOTED_COMMAND) || command.match(SINGLE_QUOTED_COMMAND)
|
42
|
+
if match
|
40
43
|
exe, args = match.captures
|
41
44
|
else
|
42
45
|
exe, args = command.split(/ /, 2)
|
@@ -44,7 +47,8 @@ module Facter
|
|
44
47
|
|
45
48
|
return unless exe && (expanded = which(exe))
|
46
49
|
|
47
|
-
expanded =
|
50
|
+
expanded = expanded.dup
|
51
|
+
expanded = +"'#{expanded}'" if /\s/.match?(expanded)
|
48
52
|
expanded << " #{args}" if args
|
49
53
|
|
50
54
|
expanded
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Facter
|
2
4
|
module Core
|
3
5
|
module Execution
|
@@ -56,7 +58,8 @@ module Facter
|
|
56
58
|
|
57
59
|
return unless exe && (expanded = which(exe))
|
58
60
|
|
59
|
-
expanded =
|
61
|
+
expanded = expanded.dup
|
62
|
+
expanded = +"\"#{expanded}\"" if /\s+/.match?(expanded)
|
60
63
|
expanded << " #{args}" if args
|
61
64
|
|
62
65
|
expanded
|
@@ -2,14 +2,12 @@
|
|
2
2
|
|
3
3
|
require_relative '../../../facter/custom_facts/util/fact'
|
4
4
|
require_relative '../../../facter/custom_facts/util/collection'
|
5
|
-
require_relative '../../../facter/custom_facts/util/fact'
|
6
5
|
require_relative '../../../facter/custom_facts/util/loader'
|
7
6
|
require_relative '../../../facter/custom_facts/core/execution/base'
|
8
7
|
require_relative '../../../facter/custom_facts/core/execution/windows'
|
9
8
|
require_relative '../../../facter/custom_facts/core/execution/posix'
|
10
9
|
require_relative '../../../facter/custom_facts/util/values'
|
11
10
|
require_relative '../../../facter/custom_facts/util/confine'
|
12
|
-
|
13
11
|
require_relative '../../../facter/custom_facts/util/config'
|
14
12
|
|
15
13
|
require_relative '../../../facter/custom_facts/util/normalization'
|
@@ -18,10 +16,8 @@ require_relative '../../../facter/custom_facts/core/resolvable'
|
|
18
16
|
require_relative '../../../facter/custom_facts/core/suitable'
|
19
17
|
require_relative '../../../facter/custom_facts/util/resolution'
|
20
18
|
require_relative '../../../facter/custom_facts/core/directed_graph'
|
21
|
-
require_relative '../../../facter/custom_facts/core/resolvable'
|
22
19
|
require_relative '../../../facter/custom_facts/core/aggregate'
|
23
20
|
require_relative '../../../facter/custom_facts/util/composite_loader'
|
24
21
|
require_relative '../../../facter/custom_facts/util/parser'
|
25
22
|
require_relative '../../../facter/custom_facts/util/directory_loader'
|
26
23
|
require_relative '../../../facter/custom_facts/util/nothing_loader'
|
27
|
-
require_relative '../../../facter/custom_facts/util/nothing_loader'
|
@@ -80,7 +80,7 @@ module LegacyFacter
|
|
80
80
|
|
81
81
|
# Flush all cached values.
|
82
82
|
def flush
|
83
|
-
@facts.
|
83
|
+
@facts.each_value(&:flush)
|
84
84
|
@external_facts_loaded = nil
|
85
85
|
end
|
86
86
|
|
@@ -134,9 +134,7 @@ module LegacyFacter
|
|
134
134
|
load_external_facts
|
135
135
|
end
|
136
136
|
|
137
|
-
attr_reader :internal_loader
|
138
|
-
|
139
|
-
attr_reader :external_loader
|
137
|
+
attr_reader :internal_loader, :external_loader
|
140
138
|
|
141
139
|
# Return a hash of all of our facts.
|
142
140
|
def to_hash
|
@@ -63,7 +63,10 @@ module LegacyFacter
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
# we're intentionally using case equality (triple equals) because we
|
67
|
+
# support matching against anything that supports === such as ranges,
|
68
|
+
# regular expressions, etc
|
69
|
+
@values.any? { |v| convert(v) === value } # rubocop:disable Style/CaseEquality
|
67
70
|
end
|
68
71
|
|
69
72
|
private
|
@@ -86,7 +86,7 @@ module Facter
|
|
86
86
|
resolve
|
87
87
|
rescue StandardError => e
|
88
88
|
msg = "Unable to add resolve #{resolution_name.inspect} for fact '#{@name}': #{e.message}"
|
89
|
-
msg += "\n
|
89
|
+
msg += "\n#{e.backtrace.join("\n")}" if Options[:trace]
|
90
90
|
log.error(msg, true)
|
91
91
|
nil
|
92
92
|
end
|
@@ -18,7 +18,7 @@ module LegacyFacter
|
|
18
18
|
shortname = fact.to_s.downcase
|
19
19
|
load_env(shortname)
|
20
20
|
|
21
|
-
filename = shortname
|
21
|
+
filename = "#{shortname}.rb"
|
22
22
|
|
23
23
|
paths = search_path
|
24
24
|
paths&.each do |dir|
|
@@ -40,7 +40,7 @@ module LegacyFacter
|
|
40
40
|
paths = search_path
|
41
41
|
paths&.each do |dir|
|
42
42
|
# clean the search path of wrong slashes and backslashes
|
43
|
-
dir = dir.gsub(%r{[
|
43
|
+
dir = dir.gsub(%r{[/\\]+}, File::SEPARATOR)
|
44
44
|
# dir is already an absolute path
|
45
45
|
Dir.glob(File.join(dir, '*.rb')).each do |path|
|
46
46
|
# exclude dirs that end with .rb
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This represents a fact resolution. A resolution is a concrete
|
2
4
|
# implementation of a fact. A single fact can have many resolutions and
|
3
5
|
# the correct resolution will be chosen at runtime. Each time
|
@@ -88,7 +90,7 @@ module Facter
|
|
88
90
|
# @api private
|
89
91
|
def evaluate(&block)
|
90
92
|
if @last_evaluated
|
91
|
-
msg = "Already evaluated #{@name}"
|
93
|
+
msg = +"Already evaluated #{@name}"
|
92
94
|
msg << " at #{@last_evaluated}" if msg.is_a? String
|
93
95
|
msg << ', reevaluating anyways'
|
94
96
|
log.warn msg
|
@@ -157,9 +159,11 @@ module Facter
|
|
157
159
|
#
|
158
160
|
# @api private
|
159
161
|
def <=>(other)
|
160
|
-
|
161
|
-
|
162
|
-
|
162
|
+
if weight == other.weight
|
163
|
+
compare_equal_weights(other)
|
164
|
+
else
|
165
|
+
weight <=> other.weight
|
166
|
+
end
|
163
167
|
end
|
164
168
|
|
165
169
|
private
|
@@ -90,7 +90,7 @@ module LegacyFacter
|
|
90
90
|
|
91
91
|
if structure.is_a? Hash
|
92
92
|
structure.each_pair do |name, value|
|
93
|
-
new_path = "#{path}_#{name}".gsub(%r{
|
93
|
+
new_path = "#{path}_#{name}".gsub(%r{-|/}, '_')
|
94
94
|
results.merge! flatten_structure(new_path, value)
|
95
95
|
end
|
96
96
|
elsif structure.is_a? Array
|
@@ -20,10 +20,15 @@ module Facts
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def determine_release_version
|
23
|
+
# For backwards compatibility, use system-release for AL1/AL2
|
23
24
|
version = Facter::Resolvers::ReleaseFromFirstLine.resolve(:release, release_file: '/etc/system-release')
|
25
|
+
if !version.nil? && version != '2'
|
26
|
+
# Use os-release for AL2023 and up
|
27
|
+
version = Facter::Resolvers::Amzn::OsReleaseRpm.resolve(:version)
|
28
|
+
end
|
24
29
|
version ||= Facter::Resolvers::OsRelease.resolve(:version_id)
|
25
30
|
|
26
|
-
Facter::Util::Facts.release_hash_from_string(version)
|
31
|
+
Facter::Util::Facts.release_hash_from_string(version, include_patch: true)
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
@@ -18,7 +18,12 @@ module Facts
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def determine_release_version
|
21
|
+
# For backwards compatibility, use system-release for AL1/AL2
|
21
22
|
version = Facter::Resolvers::ReleaseFromFirstLine.resolve(:release, release_file: '/etc/system-release')
|
23
|
+
if !version.nil? && version != '2'
|
24
|
+
# Use os-release for AL2023 and up
|
25
|
+
version = Facter::Resolvers::Amzn::OsReleaseRpm.resolve(:version)
|
26
|
+
end
|
22
27
|
version ||= Facter::Resolvers::OsRelease.resolve(:version_id)
|
23
28
|
|
24
29
|
Facter::Util::Facts.release_hash_from_string(version)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Linux
|
5
|
+
module Dmi
|
6
|
+
module Product
|
7
|
+
class Version
|
8
|
+
FACT_NAME = 'dmi.product.version'
|
9
|
+
ALIASES = 'productversion'
|
10
|
+
|
11
|
+
def call_the_resolver
|
12
|
+
fact_value = Facter::Resolvers::Linux::DmiBios.resolve(:product_version)
|
13
|
+
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -23,7 +23,7 @@ module Facts
|
|
23
23
|
return 'virtualbox' if boot_rom_version&.start_with?('VirtualBox')
|
24
24
|
|
25
25
|
subsystem_vendor_id = Facter::Resolvers::Macosx::SystemProfiler.resolve(:subsystem_vendor_id)
|
26
|
-
|
26
|
+
'parallels' if subsystem_vendor_id&.start_with?('0x1ab8')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -15,17 +15,17 @@ module Facts
|
|
15
15
|
|
16
16
|
def check_vmware
|
17
17
|
model_identifier = Facter::Resolvers::Macosx::SystemProfiler.resolve(:model_identifier)
|
18
|
-
|
18
|
+
'vmware' if model_identifier&.start_with?('VMware')
|
19
19
|
end
|
20
20
|
|
21
21
|
def check_virtualbox
|
22
22
|
boot_rom_version = Facter::Resolvers::Macosx::SystemProfiler.resolve(:boot_rom_version)
|
23
|
-
|
23
|
+
'virtualbox' if boot_rom_version&.start_with?('VirtualBox')
|
24
24
|
end
|
25
25
|
|
26
26
|
def check_parallels
|
27
27
|
subsystem_vendor_id = Facter::Resolvers::Macosx::SystemProfiler.resolve(:subsystem_vendor_id)
|
28
|
-
|
28
|
+
'parallels' if subsystem_vendor_id&.start_with?('0x1ab8')
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -20,7 +20,7 @@ module Facts
|
|
20
20
|
def from_specific_file
|
21
21
|
version = Facter::Resolvers::SpecificReleaseFile.resolve(:release,
|
22
22
|
{ release_file: '/etc/mariner-release',
|
23
|
-
regex: /CBL
|
23
|
+
regex: /CBL-Mariner ([0-9.]+)/ })
|
24
24
|
Facter::Util::Facts.release_hash_from_matchdata(version)
|
25
25
|
end
|
26
26
|
|
@@ -8,7 +8,7 @@ module Facts
|
|
8
8
|
def call_the_resolver
|
9
9
|
full_version = Facter::Resolvers::Uname.resolve(:kernelversion)
|
10
10
|
versions_split = full_version.split('.')
|
11
|
-
major_version = versions_split.length > 2 ? versions_split[0]
|
11
|
+
major_version = versions_split.length > 2 ? "#{versions_split[0]}.#{versions_split[1]}" : versions_split[0]
|
12
12
|
Facter::ResolvedFact.new(FACT_NAME, major_version)
|
13
13
|
end
|
14
14
|
end
|
@@ -54,7 +54,7 @@ module Facts
|
|
54
54
|
def create_resolved_facts_list(fact_value)
|
55
55
|
resolved_facts = [Facter::ResolvedFact.new(FACT_NAME, fact_value)]
|
56
56
|
ALIASES.each do |fact_alias|
|
57
|
-
key = fact_alias.split('_')[1
|
57
|
+
key = fact_alias.split('_')[1..].map!(&:to_sym)
|
58
58
|
resolved_facts << Facter::ResolvedFact.new(fact_alias, fact_value.dig(*key), :legacy)
|
59
59
|
end
|
60
60
|
|
@@ -29,7 +29,7 @@ module Facts
|
|
29
29
|
|
30
30
|
return { openstack: true } if /^OpenStack/.match?(Facter::Resolvers::DMIComputerSystem.resolve(:name))
|
31
31
|
|
32
|
-
|
32
|
+
{ amazon: true } if /^Amazon/.match?(manufacturer)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -9,7 +9,7 @@ module Facts
|
|
9
9
|
def call_the_resolver
|
10
10
|
fact_value = Facter::Resolvers::Windows::Networking.resolve(:interfaces)
|
11
11
|
|
12
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
12
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value&.keys&.join(','), :legacy)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -7,9 +7,9 @@ module Facter
|
|
7
7
|
module Benchmarking
|
8
8
|
class Timer
|
9
9
|
class << self
|
10
|
-
def measure(fact_name, prefix_message = '')
|
10
|
+
def measure(fact_name, prefix_message = '', &block)
|
11
11
|
if Options[:timing]
|
12
|
-
time = Benchmark.measure
|
12
|
+
time = Benchmark.measure(&block)
|
13
13
|
|
14
14
|
log = "fact '#{fact_name}', took: #{time.format('%r')} seconds"
|
15
15
|
prefix_message = "#{prefix_message} " unless prefix_message.empty?
|
@@ -113,7 +113,7 @@ module Facter
|
|
113
113
|
negate_options = %w[block cache custom_facts external_facts]
|
114
114
|
|
115
115
|
template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb')
|
116
|
-
erb = ERB.new(File.read(template),
|
116
|
+
erb = ERB.new(File.read(template), trim_mode: '-')
|
117
117
|
erb.filename = template
|
118
118
|
puts erb.result(binding)
|
119
119
|
end
|
@@ -148,7 +148,7 @@ module Facter
|
|
148
148
|
options = @options.map { |(k, v)| [k.to_sym, v] }.to_h
|
149
149
|
Facter::Options.init_from_cli(options)
|
150
150
|
|
151
|
-
block_groups = Facter::FactGroups.new.groups.to_yaml.lines[1
|
151
|
+
block_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..].join
|
152
152
|
block_groups.gsub!(/:\s*\n/, "\n")
|
153
153
|
|
154
154
|
puts block_groups
|
@@ -160,7 +160,7 @@ module Facter
|
|
160
160
|
options = @options.map { |(k, v)| [k.to_sym, v] }.to_h
|
161
161
|
Facter::Options.init_from_cli(options)
|
162
162
|
|
163
|
-
cache_groups = Facter::FactGroups.new.groups.to_yaml.lines[1
|
163
|
+
cache_groups = Facter::FactGroups.new.groups.to_yaml.lines[1..].join
|
164
164
|
cache_groups.gsub!(/:\s*\n/, "\n")
|
165
165
|
|
166
166
|
puts cache_groups
|
@@ -183,8 +183,6 @@ module Facter
|
|
183
183
|
Facter::Util::FileHelper.safe_read("#{path}fixtures/facter_help_header")
|
184
184
|
end
|
185
185
|
|
186
|
-
IGNORE_OPTIONS = %w[log_level color no_color].freeze
|
187
|
-
|
188
186
|
def add_class_options_to_help
|
189
187
|
help_class_options = +''
|
190
188
|
class_options = Cli.class_options
|
@@ -200,9 +198,9 @@ module Facter
|
|
200
198
|
|
201
199
|
def add_commands_to_help
|
202
200
|
help_command_options = +''
|
203
|
-
Cli.commands
|
204
|
-
.select { |
|
205
|
-
.each do |
|
201
|
+
Cli.commands.values
|
202
|
+
.select { |command_class| command_class.instance_of?(Thor::Command) }
|
203
|
+
.each do |command|
|
206
204
|
help_command_options << build_option(
|
207
205
|
command['name'],
|
208
206
|
[command['usage'].split(',')[1]],
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative '../../../facter/framework/logging/logger
|
4
|
+
require_relative '../../../facter/framework/logging/logger'
|
5
5
|
Facter::Log.output(STDERR)
|
6
6
|
require_relative '../../../facter'
|
7
7
|
require_relative '../../../facter/framework/cli/cli'
|
@@ -43,15 +43,14 @@ module Facter
|
|
43
43
|
|
44
44
|
def fact_cache_enabled?(fact_name)
|
45
45
|
fact = @fact_groups.get_fact(fact_name)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
if fact
|
47
|
+
!fact[:ttls].nil?
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
51
51
|
|
52
52
|
# fact_group = @fact_groups.get_fact_group(fact_name)
|
53
53
|
# delete_cache(fact_group) if fact_group && !cached
|
54
|
-
cached
|
55
54
|
end
|
56
55
|
|
57
56
|
private
|
@@ -21,9 +21,10 @@ module Facter
|
|
21
21
|
|
22
22
|
def find_nested_classes(mod, discovered_classes)
|
23
23
|
mod.constants.each do |constant_name|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
obj = mod.const_get(constant_name)
|
25
|
+
if obj.instance_of? Class
|
26
|
+
discovered_classes << obj
|
27
|
+
elsif obj.instance_of? Module
|
27
28
|
find_nested_classes(Module.const_get("#{mod.name}::#{constant_name}"), discovered_classes)
|
28
29
|
end
|
29
30
|
end
|
@@ -100,13 +100,11 @@ module Facter
|
|
100
100
|
|
101
101
|
reject_list_core, reject_list_legacy = construct_reject_lists(blocked_facts, facts)
|
102
102
|
|
103
|
-
facts
|
103
|
+
facts.reject do |fact|
|
104
104
|
reject_list_core.include?(fact) || reject_list_core.find do |fact_to_block|
|
105
105
|
fact_to_block.klass == fact.klass
|
106
106
|
end || reject_list_legacy.include?(fact)
|
107
107
|
end
|
108
|
-
|
109
|
-
facts
|
110
108
|
end
|
111
109
|
|
112
110
|
def construct_reject_lists(blocked_facts, facts)
|
@@ -25,7 +25,7 @@ module Facter
|
|
25
25
|
|
26
26
|
resolved_facts = override_core_facts(internal_facts, external_facts)
|
27
27
|
|
28
|
-
resolved_facts
|
28
|
+
resolved_facts.concat(cached_facts)
|
29
29
|
cache_manager.cache_facts(resolved_facts)
|
30
30
|
|
31
31
|
FactFilter.new.filter_facts!(resolved_facts, user_query)
|
@@ -84,7 +84,7 @@ module Facter
|
|
84
84
|
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
85
85
|
|
86
86
|
resolved_facts = @internal_fact_mgr.resolve_facts(searched_facts)
|
87
|
-
resolved_facts
|
87
|
+
resolved_facts.concat(cached_facts)
|
88
88
|
|
89
89
|
FactFilter.new.filter_facts!(resolved_facts, user_query)
|
90
90
|
|
@@ -101,7 +101,7 @@ module Facter
|
|
101
101
|
searched_facts, cached_facts = @cache_manager.resolve_facts(searched_facts)
|
102
102
|
|
103
103
|
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
104
|
-
resolved_facts
|
104
|
+
resolved_facts.concat(cached_facts)
|
105
105
|
resolved_facts if resolved_facts.any?
|
106
106
|
end
|
107
107
|
|
@@ -115,7 +115,7 @@ module Facter
|
|
115
115
|
|
116
116
|
resolved_facts = @external_fact_mgr.resolve_facts(searched_facts)
|
117
117
|
resolved_facts = override_core_facts(core_facts, resolved_facts)
|
118
|
-
resolved_facts
|
118
|
+
resolved_facts.concat(cached_facts)
|
119
119
|
|
120
120
|
resolved_facts unless resolved_facts.map(&:value).compact.empty?
|
121
121
|
end
|