facter 3.12.1.cfacter.20181031 → 3.12.2.cfacter.20181217

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 872a037b021fcff2969e6ef2574a23d1b1b2e8feece7fa0b4b418a18ab1a6193
4
- data.tar.gz: 164693600bc4676addca957c74d0f8b973082fa2e17dce5bb44c67d8f3a33a4a
3
+ metadata.gz: 364520fb97a986c1682b878a85b491f6ab50c5da1ba5a74bf782636b7c29e890
4
+ data.tar.gz: 07c221de09300211796b4cdec443ca96486da6df7368687ad4b74869ab221188
5
5
  SHA512:
6
- metadata.gz: d48cffa1eaf135728be2fb5ee8a38edde2eff2120abee3a083e4430ac2cb6979333e124f66895519b1126d8db13b4e49c4a41cfb372873b4cee6d28c34fc6f2b
7
- data.tar.gz: a4989b358fa6aa5b103baae12a5baadcbf718427d2c91f6a1f22350f8093749b101133e3fc248d22f366d66d5178a14cf2dd3fefb2c8f92424906a6c893cb4a5
6
+ metadata.gz: 49033dc14634dce2a4c1a2c1c37f919fe6ac9d7f3d0cf4cf48e5038b7708e3fc11d4a9e1488249443198fc635f4080976b33d637ba25dc97efabde957258f004
7
+ data.tar.gz: 260954f857485b92e261a04978d6447c844bc4f3af2d1d023afd13104aa6844240d7521d7557fbf54a21c423f0795db29a3f6f400e604df1836602da5ca42885
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.2.2)
2
- project(FACTER VERSION 3.12.1)
2
+ project(FACTER VERSION 3.12.2)
3
3
 
4
4
  # Set this early, so it's available. AIX gets weird, man.
5
5
  if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
@@ -10,10 +10,12 @@ def location_for(place, fake_version = nil)
10
10
  end
11
11
  end
12
12
 
13
- gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 3.34")
14
- gem 'beaker-puppet', *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 0.13')
13
+ gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 4")
14
+ gem 'beaker-puppet', *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 1')
15
15
  gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 1.1")
16
16
  gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 0.5")
17
+ gem "beaker-vagrant", *location_for(ENV['BEAKER_VAGRANT_VERSION'] || "~> 0")
18
+ gem "beaker-vmpooler", *location_for(ENV['BEAKER_VMPOOLER_VERSION'] || "~> 1")
17
19
  gem 'rake', "~> 10.1.0"
18
20
  gem "multi_json", "~> 1.8"
19
21
 
@@ -1 +1,3 @@
1
1
  $LOAD_PATH << File.expand_path(File.dirname(__FILE__))
2
+
3
+ require 'beaker-puppet'
@@ -0,0 +1,106 @@
1
+ test_name 'Facter should appropriately resolve a custom fact when it conflicts with a builtin fact' do
2
+ tag 'risk:medium'
3
+
4
+ def create_custom_fact_on(host, custom_fact_dir, fact_file_name, fact)
5
+ fact_file_contents = <<-CUSTOM_FACT
6
+ Facter.add(:#{fact[:name]}) do
7
+ has_weight #{fact[:weight]}
8
+ setcode do
9
+ #{fact[:value]}
10
+ end
11
+ end
12
+ CUSTOM_FACT
13
+
14
+ fact_file_path = File.join(custom_fact_dir, fact_file_name)
15
+ create_remote_file(host, fact_file_path, fact_file_contents)
16
+ end
17
+
18
+ def clear_custom_facts_on(host, custom_fact_dir)
19
+ step "Clean-up the previous test's custom facts" do
20
+ on(agent, "rm -f #{custom_fact_dir}/*")
21
+ end
22
+ end
23
+
24
+ agents.each do |agent|
25
+ custom_fact_dir = agent.tmpdir('facter')
26
+ teardown do
27
+ on(agent, "rm -rf '#{custom_fact_dir}'")
28
+ end
29
+
30
+ fact_name = 'timezone'
31
+ builtin_value = on(agent, facter('timezone')).stdout.chomp
32
+
33
+ step "Verify that Facter uses the custom fact's value when its weight is > 0" do
34
+ custom_fact_value = "custom_timezone"
35
+ create_custom_fact_on(
36
+ agent,
37
+ custom_fact_dir,
38
+ 'custom_timezone.rb',
39
+ name: fact_name,
40
+ weight: 10,
41
+ value: "'#{custom_fact_value}'"
42
+ )
43
+
44
+ on(agent, facter("--custom-dir=#{custom_fact_dir} timezone")) do |result|
45
+ assert_match(/#{custom_fact_value}/, result.stdout.chomp, "Facter does not use the custom fact's value when its weight is > 0")
46
+ end
47
+ end
48
+
49
+ clear_custom_facts_on(agent, custom_fact_dir)
50
+
51
+ step "Verify that Facter uses the builtin fact's value when all conflicting custom facts fail to resolve" do
52
+ [ 'timezone_one.rb', 'timezone_two.rb'].each do |fact_file|
53
+ create_custom_fact_on(
54
+ agent,
55
+ custom_fact_dir,
56
+ fact_file,
57
+ { name: fact_name, weight: 10, value: nil }
58
+ )
59
+ end
60
+
61
+ on(agent, facter("--custom-dir=#{custom_fact_dir} timezone")) do |result|
62
+ assert_match(/#{builtin_value}/, result.stdout.chomp, "Facter does not use the builtin fact's value when all conflicting custom facts fail to resolve")
63
+ end
64
+ end
65
+
66
+ step "Verify that Facter gives precedence to the builtin fact over zero weight custom facts" do
67
+ step "when all custom facts have zero weight" do
68
+ {
69
+ 'timezone_one.rb' => "'timezone_one'",
70
+ 'timezone_two.rb' => "'timezone_two'"
71
+ }.each do |fact_file, fact_value|
72
+ create_custom_fact_on(
73
+ agent,
74
+ custom_fact_dir,
75
+ fact_file,
76
+ { name: fact_name, weight: 0, value: fact_value }
77
+ )
78
+ end
79
+
80
+ on(agent, facter("--custom-dir=#{custom_fact_dir} timezone")) do |result|
81
+ assert_match(/#{builtin_value}/, result.stdout.chomp, "Facter does not give precedence to the builtin fact when all custom facts have zero weight")
82
+ end
83
+ end
84
+
85
+ clear_custom_facts_on(agent, custom_fact_dir)
86
+
87
+ step "when some custom facts have zero weight" do
88
+ {
89
+ 'timezone_one.rb' => { weight: 10, value: nil },
90
+ 'timezone_two.rb' => { weight: 0, value: "'timezone_two'" }
91
+ }.each do |fact_file, fact|
92
+ create_custom_fact_on(
93
+ agent,
94
+ custom_fact_dir,
95
+ fact_file,
96
+ fact.merge(name: fact_name)
97
+ )
98
+ end
99
+
100
+ on(agent, facter("--custom-dir=#{custom_fact_dir} timezone")) do |result|
101
+ assert_match(/#{builtin_value}/, result.stdout.chomp, "Facter does not give precedence to the builtin fact when only some custom facts have zero weight")
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
@@ -26,12 +26,12 @@ test_name 'C59029: networking facts should be fully populated' do
26
26
  refute_empty(primary_interface)
27
27
 
28
28
  expected_bindings = {
29
- "\"networking.interfaces.#{primary_interface}.bindings.0.address\"" => @ip_regex,
30
- "\"networking.interfaces.#{primary_interface}.bindings.0.netmask\"" => @netmask_regex,
31
- "\"networking.interfaces.#{primary_interface}.bindings.0.network\"" => @ip_regex,
32
- "\"networking.interfaces.#{primary_interface}.bindings6.0.address\"" => /[a-f0-9:]+/,
33
- "\"networking.interfaces.#{primary_interface}.bindings6.0.netmask\"" => /[a-f0-9:]+/,
34
- "\"networking.interfaces.#{primary_interface}.bindings6.0.network\"" => /[a-f0-9:]+/
29
+ "networking.interfaces.#{primary_interface}.bindings.0.address" => @ip_regex,
30
+ "networking.interfaces.#{primary_interface}.bindings.0.netmask" => @netmask_regex,
31
+ "networking.interfaces.#{primary_interface}.bindings.0.network" => @ip_regex,
32
+ "networking.interfaces.#{primary_interface}.bindings6.0.address" => /[a-f0-9:]+/,
33
+ "networking.interfaces.#{primary_interface}.bindings6.0.netmask" => /[a-f0-9:]+/,
34
+ "networking.interfaces.#{primary_interface}.bindings6.0.network" => /[a-f0-9:]+/
35
35
  }
36
36
 
37
37
  if agent['platform'] =~ /eos|solaris|aix|cisco/
@@ -41,9 +41,9 @@ test_name 'C59029: networking facts should be fully populated' do
41
41
  expected_networking.delete("networking.network6")
42
42
 
43
43
  #remove invalid bindings for the primary networking interface eccentric platforms
44
- expected_bindings.delete("\"networking.interfaces.#{primary_interface}.bindings6.0.address\"")
45
- expected_bindings.delete("\"networking.interfaces.#{primary_interface}.bindings6.0.netmask\"")
46
- expected_bindings.delete("\"networking.interfaces.#{primary_interface}.bindings6.0.network\"")
44
+ expected_bindings.delete("networking.interfaces.#{primary_interface}.bindings6.0.address")
45
+ expected_bindings.delete("networking.interfaces.#{primary_interface}.bindings6.0.netmask")
46
+ expected_bindings.delete("networking.interfaces.#{primary_interface}.bindings6.0.network")
47
47
  end
48
48
 
49
49
  if agent['platform'] =~ /aix|sparc|cisco|huawei|sles|s390x/
@@ -57,19 +57,19 @@ test_name 'C59029: networking facts should be fully populated' do
57
57
  expected_networking.delete("networking.netmask")
58
58
 
59
59
  #remove invalid bindings for Cisco's primary networking interface
60
- expected_bindings.delete("\"networking.interfaces.#{primary_interface}.bindings.0.netmask\"")
61
- expected_bindings.delete("\"networking.interfaces.#{primary_interface}.bindings.0.network\"")
60
+ expected_bindings.delete("networking.interfaces.#{primary_interface}.bindings.0.netmask")
61
+ expected_bindings.delete("networking.interfaces.#{primary_interface}.bindings.0.network")
62
62
  end
63
63
 
64
64
  step "Ensure the Networking fact resolves with reasonable values for at least one interface" do
65
65
  expected_networking.each do |fact, value|
66
- assert_match(value, fact_on(agent, fact))
66
+ assert_match(value, fact_on(agent, fact).to_s)
67
67
  end
68
68
  end
69
69
 
70
70
  step "Ensure bindings for the primary networking interface are present" do
71
71
  expected_bindings.each do |fact, value|
72
- assert_match(value, fact_on(agent, fact))
72
+ assert_match(value, fact_on(agent, fact).to_s)
73
73
  end
74
74
  end
75
75
  end
@@ -38,7 +38,7 @@ PROJECT_NAME = facter
38
38
  # could be handy for archiving the generated documentation or if some version
39
39
  # control system is used.
40
40
 
41
- PROJECT_NUMBER = 3.12.1
41
+ PROJECT_NUMBER = 3.12.2
42
42
 
43
43
  # Using the PROJECT_BRIEF tag one can provide an optional one line description
44
44
  # for a project that appears at the top of each page and should give viewer a
@@ -83,53 +83,69 @@ namespace facter { namespace ruby {
83
83
  });
84
84
 
85
85
  _resolving = true;
86
-
87
- // If no resolutions or the top resolution has a weight of 0, first check the native collection for the fact
88
- // This way we treat the "built-in" as implicitly having a resolution with weight 0
89
86
  bool add = true;
90
- if (_resolutions.empty() || ruby.to_native<resolution>(_resolutions.front())->weight() == 0) {
91
- // Check to see the value is in the collection
92
- auto value = facts[ruby.to_string(_name)];
93
- if (value) {
94
- // Already in collection, do not add
95
- add = false;
96
- _value = facter->to_ruby(value);
97
- _weight = value->weight();
98
- }
99
- }
100
87
 
101
- if (ruby.is_nil(_value)) {
102
- vector<VALUE>::iterator it;
103
- ruby.rescue([&]() {
104
- volatile VALUE value = ruby.nil_value();
105
- size_t weight = 0;
106
-
107
- // Look through the resolutions and find the first allowed resolution that resolves
108
- for (it = _resolutions.begin(); it != _resolutions.end(); ++it) {
109
- auto res = ruby.to_native<resolution>(*it);
110
- if (!res->suitable(*facter)) {
111
- continue;
112
- }
113
- value = res->value();
114
- if (!ruby.is_nil(value)) {
115
- weight = res->weight();
116
- break;
117
- }
88
+ vector<VALUE>::iterator it;
89
+ ruby.rescue([&]() {
90
+ volatile VALUE value = ruby.nil_value();
91
+ size_t weight = 0;
92
+
93
+ // Look through the resolutions and find the first allowed resolution that resolves
94
+ for (it = _resolutions.begin(); it != _resolutions.end(); ++it) {
95
+ auto res = ruby.to_native<resolution>(*it);
96
+ if (!res->suitable(*facter)) {
97
+ continue;
98
+ }
99
+ value = res->value();
100
+ if (!ruby.is_nil(value)) {
101
+ weight = res->weight();
102
+ break;
118
103
  }
104
+ }
119
105
 
120
- // Set the value to what was resolved
121
- _value = value;
122
- _weight = weight;
123
- return 0;
124
- }, [&](VALUE ex) {
125
- LOG_ERROR("error while resolving custom fact \"{1}\": {2}", ruby.rb_string_value_ptr(&_name), ruby.exception_to_string(ex));
106
+ // Set the value to what was resolved
107
+ _value = value;
108
+ _weight = weight;
126
109
 
127
- // Failed, so set to nil
128
- _value = ruby.nil_value();
129
- _weight = 0;
110
+ if (! ruby.is_nil(_value) && _weight != 0) {
130
111
  return 0;
131
- });
132
- }
112
+ }
113
+
114
+ // There's two possibilities here:
115
+ // 1. None of our resolvers could resolve the value
116
+ // 2. A resolver of weight 0 resolved the value
117
+ //
118
+ // In both cases, we attempt to use the "built-in" fact's
119
+ // value. This serves as a fallback resolver for Case (1)
120
+ // while for Case (2), we want built-in values to take
121
+ // precedence over 0-weight custom facts.
122
+
123
+ auto builtin_value = facts[ruby.to_string(_name)];
124
+ if (! builtin_value) {
125
+ return 0;
126
+ }
127
+ auto builtin_ruby_value = facter->to_ruby(builtin_value);
128
+
129
+ // We need this check for Case (2). Otherwise, we risk
130
+ // overwriting our resolved value in the small chance
131
+ // that builtin_value exists, but its ruby value is
132
+ // nil.
133
+ if (! ruby.is_nil(builtin_ruby_value)) {
134
+ // Already in collection, do not add
135
+ add = false;
136
+ _value = builtin_ruby_value;
137
+ _weight = builtin_value->weight();
138
+ }
139
+
140
+ return 0;
141
+ }, [&](VALUE ex) {
142
+ LOG_ERROR("error while resolving custom fact \"{1}\": {2}", ruby.rb_string_value_ptr(&_name), ruby.exception_to_string(ex));
143
+
144
+ // Failed, so set to nil
145
+ _value = ruby.nil_value();
146
+ _weight = 0;
147
+ return 0;
148
+ });
133
149
 
134
150
  if (add) {
135
151
  facts.add_custom(ruby.to_string(_name), ruby.is_nil(_value) ? nullptr : make_value<ruby::ruby_value>(_value), _weight);
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.2.2)
2
- project(leatherman VERSION 1.5.3)
2
+ project(leatherman VERSION 1.5.4)
3
3
 
4
4
  if (WIN32)
5
5
  link_libraries("-Wl,--nxcompat -Wl,--dynamicbase")
@@ -2,7 +2,10 @@
2
2
  # Each of our project dirs sets CMAKE_CXX_FLAGS based on these. We do
3
3
  # not set CMAKE_CXX_FLAGS globally because gtest is not warning-clean.
4
4
  if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "\\w*Clang")
5
- set(LEATHERMAN_CXX_FLAGS "-std=c++11 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-tautological-constant-out-of-range-compare ${CMAKE_CXX_FLAGS}")
5
+ if (ENABLE_CXX_WERROR)
6
+ set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
7
+ endif()
8
+ set(LEATHERMAN_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wno-unused-parameter -Wno-tautological-constant-out-of-range-compare ${CMAKE_CXX_FLAGS}")
6
9
 
7
10
  # Clang warns that 'register' is deprecated; 'register' is used throughout boost, so it can't be an error yet.
8
11
  # The warning flag is different on different clang versions so we need to extract the clang version.
@@ -40,8 +43,12 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
40
43
  # it's also sometimes wrong
41
44
  set(CMAKE_CXX_FLAGS "-Wno-maybe-uninitialized ${CMAKE_CXX_FLAGS}")
42
45
 
46
+ if (ENABLE_CXX_WERROR)
47
+ set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
48
+ endif()
49
+
43
50
  # missing-field-initializers is disabled because GCC can't make up their mind how to treat C++11 initializers
44
- set(LEATHERMAN_CXX_FLAGS "-std=c++11 -Wall -Werror -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-unknown-pragmas -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}")
51
+ set(LEATHERMAN_CXX_FLAGS "-std=c++11 -Wall -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-unknown-pragmas -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}")
45
52
  if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
46
53
  set(LEATHERMAN_CXX_FLAGS "-Wextra ${LEATHERMAN_CXX_FLAGS}")
47
54
  endif()
@@ -1,4 +1,5 @@
1
1
  include(leatherman)
2
+ defoption(ENABLE_CXX_WERROR "Enables the -Werror compiler option" ON)
2
3
  defoption(COVERALLS "Generate code coverage using Coveralls.io" OFF)
3
4
  defoption(BOOST_STATIC "Use Boost's static libraries" OFF)
4
5
  defoption(CURL_STATIC "Use curl's static libraries" OFF)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.1.cfacter.20181031
4
+ version: 3.12.2.cfacter.20181217
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-31 00:00:00.000000000 Z
12
+ date: 2018-12-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: info@puppet.com
@@ -203,6 +203,7 @@ files:
203
203
  - ext/facter/facter/acceptance/lib/puppet/acceptance/common_utils.rb
204
204
  - ext/facter/facter/acceptance/lib/puppet/acceptance/git_utils.rb
205
205
  - ext/facter/facter/acceptance/lib/puppet/acceptance/install_utils.rb
206
+ - ext/facter/facter/acceptance/tests/custom_facts/conflicts_with_builtin_fact.rb
206
207
  - ext/facter/facter/acceptance/tests/custom_facts/custom_fact_with_10001_weight_overrides_external_fact.rb
207
208
  - ext/facter/facter/acceptance/tests/custom_facts/having_multiple_facts_in_one_file.rb
208
209
  - ext/facter/facter/acceptance/tests/custom_facts/using_win32ole_should_not_hang.rb