rspec-puppet-facts 4.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -12
- data/README.md +56 -29
- data/Rakefile +12 -0
- data/lib/rspec-puppet-facts/version.rb +1 -1
- data/lib/rspec-puppet-facts.rb +2 -1
- data/rspec-puppet-facts.gemspec +2 -2
- data/spec/fixtures/metadata.json +0 -1
- data/spec/rspec_puppet_facts_spec.rb +1 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da12216f356aa371b255a495fa7eb0f3d3eb8b553aac7eed5e17c3098540f8f8
|
4
|
+
data.tar.gz: d774a6780c00fc787131c80f7bcbdb277e8b80b16c9b121be38f1ed4126f7f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5350e14d6a9c61a6d1f01a7cbf0773048b10d305dd0901199d760106c8aa8e98ab8aa9d506a44f7142dbf6399b6dadb11322bc9682f8145c92a8598d2c2c9511
|
7
|
+
data.tar.gz: 52c83ec12e7926331107efd13642e68232bad5906a92a88c8cdb765247635d02239f9e0f942b40a70cbbb23256d0de8d15486935f1225eb88fa981557ad0110f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [5.0.0](https://github.com/voxpupuli/rspec-puppet-facts/tree/5.0.0) (2024-07-04)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/voxpupuli/rspec-puppet-facts/compare/4.0.0...5.0.0)
|
6
|
+
|
7
|
+
**Breaking changes:**
|
8
|
+
|
9
|
+
- Switch to FacterDB 3 / drop legacy facts [\#187](https://github.com/voxpupuli/rspec-puppet-facts/pull/187) ([bastelfreak](https://github.com/bastelfreak))
|
10
|
+
|
11
|
+
**Implemented enhancements:**
|
12
|
+
|
13
|
+
- Deprecate symbolized facts [\#193](https://github.com/voxpupuli/rspec-puppet-facts/pull/193) ([bastelfreak](https://github.com/bastelfreak))
|
14
|
+
|
15
|
+
**Fixed bugs:**
|
16
|
+
|
17
|
+
- handle stringified facterversion properly [\#191](https://github.com/voxpupuli/rspec-puppet-facts/pull/191) ([bastelfreak](https://github.com/bastelfreak))
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- Update voxpupuli-rubocop requirement from ~\> 2.7.0 to ~\> 2.8.0 [\#192](https://github.com/voxpupuli/rspec-puppet-facts/pull/192) ([dependabot[bot]](https://github.com/apps/dependabot))
|
22
|
+
|
3
23
|
## [4.0.0](https://github.com/voxpupuli/rspec-puppet-facts/tree/4.0.0) (2024-06-10)
|
4
24
|
|
5
25
|
[Full Changelog](https://github.com/voxpupuli/rspec-puppet-facts/compare/3.0.0...4.0.0)
|
@@ -27,28 +47,41 @@
|
|
27
47
|
|
28
48
|
**symbolized facts deprecation**
|
29
49
|
|
30
|
-
With the release of rspec-puppet-facts
|
50
|
+
With the release of rspec-puppet-facts 6.0.0 we will remove support for symbolized facts. At the moment people typically use this in their unit files:
|
31
51
|
|
32
52
|
```ruby
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
53
|
+
on_supported_os.each do |os, os_facts|
|
54
|
+
case os_facts[:os]['name']
|
55
|
+
when 'Archlinux'
|
56
|
+
context 'on Archlinux' do
|
57
|
+
it { is_expected.to contain_package('borg') }
|
58
|
+
end
|
59
|
+
when 'Ubuntu'
|
37
60
|
end
|
38
|
-
|
61
|
+
end
|
39
62
|
```
|
40
63
|
|
41
|
-
For history reasons the first level of facts were symbols. You will have to update it to strings with the
|
64
|
+
For history reasons the first level of facts were symbols. You will have to update it to strings with the 6.0.0 release:
|
42
65
|
|
43
66
|
```ruby
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
67
|
+
on_supported_os.each do |os, os_facts|
|
68
|
+
case os_facts['os']['name']
|
69
|
+
when 'Archlinux'
|
70
|
+
context 'on Archlinux' do
|
71
|
+
it { is_expected.to contain_package('borg') }
|
72
|
+
end
|
73
|
+
when 'Ubuntu'
|
48
74
|
end
|
49
|
-
|
75
|
+
end
|
50
76
|
```
|
51
77
|
|
78
|
+
As an alternative you can configure the old behaviour:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
RSpec.configure do |c|
|
82
|
+
c.facterdb_string_keys = false
|
83
|
+
end
|
84
|
+
```
|
52
85
|
|
53
86
|
**Breaking changes:**
|
54
87
|
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ If you're using Bundler to manage gems in your module repository, install `rspec
|
|
22
22
|
1. Add the following line to your `Gemfile`:
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
gem 'rspec-puppet-facts', :
|
25
|
+
gem 'rspec-puppet-facts', require: false
|
26
26
|
```
|
27
27
|
|
28
28
|
2. Run `bundle install`.
|
@@ -54,38 +54,18 @@ By default, `rspec-puppet-facts` provides the facts only for `x86_64` architectu
|
|
54
54
|
* `'operatingsystem'` - The name of the operating system, as a string.
|
55
55
|
* `'operatingsystemrelease'` - An array of version numbers, as strings.
|
56
56
|
|
57
|
-
This is particularly useful if your module is split into operating system subclasses. For example, if you had a class called `myclass::debian` that you wanted to test against Debian
|
57
|
+
This is particularly useful if your module is split into operating system subclasses. For example, if you had a class called `myclass::debian` that you wanted to test against Debian 12 and Debian 11 on both `x86_64` _and_ `i386` architectures, you could write the following test:
|
58
58
|
|
59
59
|
```ruby
|
60
60
|
require 'spec_helper'
|
61
61
|
|
62
|
-
describe 'myclass::debian' do
|
63
|
-
test_on = {
|
64
|
-
:hardwaremodels => ['x86_64', 'i386'],
|
65
|
-
:supported_os => [
|
66
|
-
{
|
67
|
-
'operatingsystem' => 'Debian',
|
68
|
-
'operatingsystemrelease' => ['6', '7'],
|
69
|
-
},
|
70
|
-
],
|
71
|
-
}
|
72
|
-
|
73
|
-
on_supported_os(test_on).each do |os, os_facts|
|
74
|
-
let (:facts) { os_facts }
|
75
|
-
it { is_expected.to compile.with_all_deps }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
```
|
79
|
-
Ruby 1.9 and later:
|
80
|
-
```ruby
|
81
|
-
require 'spec_helper'
|
82
|
-
|
83
62
|
describe 'myclass::raspbian' do
|
84
63
|
test_on = {
|
64
|
+
hardwaremodels: ['x86_64', 'i386'],
|
85
65
|
supported_os: [
|
86
66
|
{
|
87
67
|
'operatingsystem' => 'Debian',
|
88
|
-
'operatingsystemrelease' => ['
|
68
|
+
'operatingsystemrelease' => ['12', '11'],
|
89
69
|
},
|
90
70
|
],
|
91
71
|
}
|
@@ -98,10 +78,9 @@ end
|
|
98
78
|
|
99
79
|
## Specifying a default Facter version
|
100
80
|
|
101
|
-
By default, `on_supported_os` will return the facts for the version of Facter
|
102
|
-
|
103
|
-
overridden by setting the `default_facter_version` RSpec setting in your
|
104
|
-
`spec/spec_helper.rb` file.
|
81
|
+
By default, `on_supported_os` will return the facts for the version of Facter that it has loaded. It will check for the loaded Puppet version and maps that to the Facter version that Perforce released in the matching AIO.
|
82
|
+
The mapping is stored in `ext/puppet_agent_components.json` (check the [maintenance](#maintenance) section for details) and computated in the `facter_version_for_puppet_version` method.
|
83
|
+
This behaviour can be overridden by setting the `default_facter_version` RSpec setting in your `spec/spec_helper.rb` file.
|
105
84
|
|
106
85
|
```ruby
|
107
86
|
RSpec.configure do |c|
|
@@ -109,6 +88,54 @@ RSpec.configure do |c|
|
|
109
88
|
end
|
110
89
|
```
|
111
90
|
|
91
|
+
## Symbolized vs stringified facts
|
92
|
+
|
93
|
+
For a long long time, the first level of keys in a factsets were symbols.
|
94
|
+
This was fine before there were structured facts, but structured facts ended up as nested hashes that always had strings.
|
95
|
+
This doesn't make sense and easy to get wrong.
|
96
|
+
The original data contains only strings so conversion actually costs performance.
|
97
|
+
|
98
|
+
The option to switch between symbolized vs stringified facts was introduced in [25634f4481f20f2fc7444e867928ca607234e33e](https://github.com/voxpupuli/rspec-puppet-facts/commit/25634f4481f20f2fc7444e867928ca607234e33e) (Release [1.9.5](https://github.com/voxpupuli/rspec-puppet-facts/blob/master/CHANGELOG.md#2019-07-29---release-195)), but version 5.0.0 has resolved various implementation bugs.
|
99
|
+
|
100
|
+
This can be configured like this:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
RSpec.configure do |c|
|
104
|
+
c.facterdb_string_keys = false
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
In the 5.x release series of rspec-puppet-facts the default `false` is deprecated.
|
109
|
+
With the 6.0.0 release we will flip it to `true` (https://github.com/voxpupuli/rspec-puppet-facts/pull/189).
|
110
|
+
|
111
|
+
You may have the following rspec-puppet test using deprecated symbolized facts:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
on_supported_os.each do |os, os_facts|
|
115
|
+
case os_facts[:os]['name']
|
116
|
+
when 'Archlinux'
|
117
|
+
context 'on Archlinux' do
|
118
|
+
it { is_expected.to contain_package('borg') }
|
119
|
+
end
|
120
|
+
when 'Ubuntu'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
125
|
+
With the string facts, the same test looks like:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
on_supported_os.each do |os, os_facts|
|
129
|
+
case os_facts['os']['name']
|
130
|
+
when 'Archlinux'
|
131
|
+
context 'on Archlinux' do
|
132
|
+
it { is_expected.to contain_package('borg') }
|
133
|
+
end
|
134
|
+
when 'Ubuntu'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
112
139
|
## Usage
|
113
140
|
|
114
141
|
Use the `on_supported_os` iterator to loop through all of your module's supported operating systems. This allows you to simplify your tests and remove a lot of duplicate code.
|
@@ -475,7 +502,7 @@ fact sets that only make sense in your environment or might contain sensitive in
|
|
475
502
|
To supply external facts to facterdb just set the `FACTERDB_SEARCH_PATHS` environment variable with one or more
|
476
503
|
paths to your facts.
|
477
504
|
|
478
|
-
When separating paths please use the default path separator character supported by your OS.
|
505
|
+
When separating paths please use the default path separator character supported by your OS.
|
479
506
|
* Unix/Linux/OSX = `:`
|
480
507
|
* Windows = `;`
|
481
508
|
|
data/Rakefile
CHANGED
@@ -60,6 +60,18 @@ else
|
|
60
60
|
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
|
61
61
|
config.future_release = gem_version
|
62
62
|
end
|
63
|
+
|
64
|
+
# Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
|
65
|
+
require 'rbconfig'
|
66
|
+
if RbConfig::CONFIG['host_os'].include?('linux')
|
67
|
+
task :changelog do
|
68
|
+
puts 'Fixing line endings...'
|
69
|
+
changelog_file = File.join(__dir__, 'CHANGELOG.md')
|
70
|
+
changelog_txt = File.read(changelog_file)
|
71
|
+
new_contents = changelog_txt.gsub("\r\n", "\n")
|
72
|
+
File.open(changelog_file, 'w') { |file| file.puts new_contents }
|
73
|
+
end
|
74
|
+
end
|
63
75
|
end
|
64
76
|
|
65
77
|
begin
|
data/lib/rspec-puppet-facts.rb
CHANGED
@@ -116,9 +116,10 @@ module RspecPuppetFacts
|
|
116
116
|
# FacterDB may have newer versions of facter data for which it contains a subset of all possible
|
117
117
|
# facter data (see FacterDB 0.5.2 for Facter releases 3.8 and 3.9). In this situation we need to
|
118
118
|
# cycle through and downgrade Facter versions per platform type until we find matching Facter data.
|
119
|
+
facterversion_key = RSpec.configuration.facterdb_string_keys ? 'facterversion' : :facterversion
|
119
120
|
filter.each do |filter_spec|
|
120
121
|
versions = FacterDB.get_facts(filter_spec, symbolize_keys: !RSpec.configuration.facterdb_string_keys).to_h do |facts|
|
121
|
-
[Gem::Version.new(facts[
|
122
|
+
[Gem::Version.new(facts[facterversion_key]), facts]
|
122
123
|
end
|
123
124
|
|
124
125
|
version, facts = versions.select { |v, _f| strict_requirement =~ v }.max_by { |v, _f| v }
|
data/rspec-puppet-facts.gemspec
CHANGED
@@ -23,10 +23,10 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency 'rspec', '~> 3.12'
|
24
24
|
s.add_development_dependency 'yard', '~> 0.9.34'
|
25
25
|
|
26
|
-
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.
|
26
|
+
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.8.0'
|
27
27
|
|
28
28
|
s.add_runtime_dependency 'deep_merge', '~> 1.2'
|
29
29
|
s.add_runtime_dependency 'facter', '< 5'
|
30
|
-
s.add_runtime_dependency 'facterdb', '~>
|
30
|
+
s.add_runtime_dependency 'facterdb', '~> 3.1'
|
31
31
|
s.add_runtime_dependency 'puppet', '>= 7', '< 9'
|
32
32
|
end
|
data/spec/fixtures/metadata.json
CHANGED
@@ -215,7 +215,6 @@ describe RspecPuppetFacts do
|
|
215
215
|
expect(subject.keys).to contain_exactly(
|
216
216
|
'debian-11-x86_64',
|
217
217
|
'debian-12-x86_64',
|
218
|
-
'redhat-7-x86_64',
|
219
218
|
'redhat-8-x86_64',
|
220
219
|
'redhat-9-x86_64',
|
221
220
|
)
|
@@ -224,7 +223,6 @@ describe RspecPuppetFacts do
|
|
224
223
|
it 'is able to filter the received OS facts' do
|
225
224
|
allow(described_class).to receive(:spec_facts_os_filter).and_return('redhat')
|
226
225
|
expect(subject.keys).to contain_exactly(
|
227
|
-
'redhat-7-x86_64',
|
228
226
|
'redhat-8-x86_64',
|
229
227
|
'redhat-9-x86_64',
|
230
228
|
)
|
@@ -319,7 +317,7 @@ describe RspecPuppetFacts do
|
|
319
317
|
end
|
320
318
|
|
321
319
|
it 'returns a fact set for the specified release' do
|
322
|
-
expect(factsets).to
|
320
|
+
expect(factsets).to a_hash_including('redhat-9-x86_64' => hash_including({ os: hash_including({ 'release' => hash_including({ 'major' => '9' }) }) }))
|
323
321
|
end
|
324
322
|
end
|
325
323
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet-facts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 2.
|
81
|
+
version: 2.8.0
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 2.
|
88
|
+
version: 2.8.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: deep_merge
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,14 +120,14 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
123
|
+
version: '3.1'
|
124
124
|
type: :runtime
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '
|
130
|
+
version: '3.1'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: puppet
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
|
-
rubygems_version: 3.5.
|
198
|
+
rubygems_version: 3.5.11
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: Standard facts fixtures for Puppet
|