Skip to content

Commit 2628083

Browse files
committed
Switch from puppet releases to openvox releases
1 parent fdb3446 commit 2628083

File tree

6 files changed

+37
-171
lines changed

6 files changed

+37
-171
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,15 @@ When no facts are available for the specific facter/operating system combination
572572
## Maintenance
573573

574574
This gem uses information about puppet AIO component versions to build/test.
575-
They are stored at `ext/puppet_agent_facter_versions.json`. If they are outdated,
576-
the `puppet_versions:test` rake task will fail and they need to be updated.
577-
This is as easy as running: `bundle exec rake puppet_versions:update`
575+
They are stored at `ext/puppet_agent_facter_versions.json`.
576+
577+
In the past we used `bundle exec rake puppet_versions:update` to update the file and `puppet_versions:test` to validate it.
578+
This relied on information from the puppet forge.
579+
With the 6.0.0 release we're switching to openvox.
580+
The file is currently maintained by hand, because openvox doesn't offer an API yet to map agent releases to openfact releases.
581+
It got also renamed from `ext/puppet_agent_facter_versions.json` -> `ext/openvox_agent_facter_versions.json`.
582+
583+
**`ext/openvox_agent_facter_versions.json`now lists a mapping of openvox releases to openfact releases**
578584

579585
## License
580586

Rakefile

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,12 @@ end
2121
namespace :puppet_versions do
2222
desc 'updates the vendored list of puppet versions & components'
2323
task :update do
24-
require 'net/http'
25-
require 'net/https'
26-
require 'uri'
27-
require 'json'
28-
29-
uri = URI.parse('https://forgeapi.puppet.com/private/versions/puppet-agent')
30-
http = Net::HTTP.new(uri.host, uri.port)
31-
http.use_ssl = uri.scheme == 'https'
32-
33-
request = Net::HTTP::Get.new(uri.request_uri)
34-
response = http.request(request)
35-
raise unless response.is_a?(Net::HTTPSuccess)
36-
37-
data = JSON.parse(response.body).filter_map do |_, versions|
38-
if !versions['puppet'].nil? && !versions['facter'].nil?
39-
[versions['puppet'], versions['facter']]
40-
end
41-
end
42-
data.sort_by! { |puppet, _facter| Gem::Version.new(puppet) }.reverse!
43-
44-
File.write(PUPPET_VERSIONS_PATH, "#{JSON.pretty_generate(data.to_h)}\n")
24+
warn 'The rake task is disabled since the 6.0.0 Release. Please see the README.md'
4525
end
4626

4727
desc 'runs all tests and verifies vendored component list'
4828
task :test do
49-
Rake::Task['puppet_versions:update'].invoke
50-
51-
output = `git status --porcelain #{PUPPET_VERSIONS_PATH}`
52-
unless output.strip.empty?
53-
warn "#{PUPPET_VERSIONS_PATH} is out of date."
54-
warn 'Run the puppet_versions:update task to update it and commit the changes.'
55-
raise
56-
end
29+
warn 'The rake task is disabled since the 6.0.0 Release. Please see the README.md'
5730
end
5831
end
5932

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"8.23.1": "5.1.0",
3+
"8.23.0": "5.1.0",
4+
"8.22.1": "5.0.0",
5+
"8.19.2": "4.11.0",
6+
"8.19.1": "4.11.0",
7+
"8.19.0": "4.11.0",
8+
"8.18.1": "4.11.0",
9+
"8.17.0": "4.11.0",
10+
"8.16.0": "4.11.0",
11+
"8.15.0": "4.11.0",
12+
"8.14.0": "4.11.0",
13+
"8.13.0": "4.11.0",
14+
"8.12.1": "4.11.0",
15+
"8.12.0": "4.11.0",
16+
"8.11.0": "4.11.0"
17+
}

ext/puppet_agent_facter_versions.json

Lines changed: 0 additions & 133 deletions
This file was deleted.

lib/rspec-puppet-facts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def self.facter_version_to_loose_requirement_string(version)
403403
def self.facter_version_for_puppet_version(puppet_version)
404404
return Facter.version if puppet_version.nil?
405405

406-
json_path = File.expand_path(File.join(__dir__, '..', 'ext', 'puppet_agent_facter_versions.json'))
406+
json_path = File.expand_path(File.join(__dir__, '..', 'ext', 'openvox_agent_facter_versions.json'))
407407
unless File.file?(json_path) && File.readable?(json_path)
408408
warning "#{json_path} does not exist or is not readable, defaulting to Facter #{Facter.version}"
409409
return Facter.version

spec/rspec_puppet_facts_spec.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
end
2222

2323
let(:component_json_path) do
24-
File.expand_path(File.join(__dir__, '..', 'ext', 'puppet_agent_facter_versions.json'))
24+
File.expand_path(File.join(__dir__, '..', 'ext', 'openvox_agent_facter_versions.json'))
2525
end
2626

2727
let(:puppet_version) { Puppet.version }
@@ -98,18 +98,21 @@
9898
end
9999

100100
context 'when passed a known Puppet version' do
101-
let(:puppet_version) { '5.2.0' }
101+
let(:puppet_version) { '8.11.0' }
102102

103103
it 'returns the Facter version for that Puppet version' do
104-
expect(facter_version).to eq('3.9.0')
104+
expect(facter_version).to eq('4.11.0')
105105
end
106106
end
107107

108108
context 'when passed a Puppet version between two known versions' do
109-
let(:puppet_version) { '5.2.5' }
109+
# openvox 8.19.0 has facter 4.11.0
110+
# openvox 8.22.1 has openfact 5.0.0
111+
# openvox 9.18.5 doesn't exist
112+
let(:puppet_version) { '8.19.5' }
110113

111114
it 'returns the Facter version for the lower Puppet version' do
112-
expect(facter_version).to eq('3.9.0')
115+
expect(facter_version).to eq('4.11.0')
113116
end
114117
end
115118

0 commit comments

Comments
 (0)