Skip to content

Commit

Permalink
Merge pull request #136 from bastelfreak/foo
Browse files Browse the repository at this point in the history
Use structured facts to detect OS version
  • Loading branch information
bastelfreak committed Apr 22, 2022
2 parents 7e73e37 + 790eb1b commit b1b69c5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rspec-puppet-facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ def on_supported_os_implementation(opts = {})
os_facts_hash = {}
received_facts.map do |facts|
# Fix facter bug
# Todo: refactor the whole block to rely on structured facts and use legacy facts as fallback
if facts[:operatingsystem] == 'Ubuntu'
operatingsystemmajrelease = facts[:operatingsystemrelease].split('.')[0..1].join('.')
elsif facts[:operatingsystem] == 'OpenBSD'
operatingsystemmajrelease = facts[:operatingsystemrelease]
elsif facts[:operatingsystem] == 'windows' && facts[:operatingsystemrelease].start_with?('10.0.')
operatingsystemmajrelease = '2016'
elsif facts.dig(:os, 'release', 'major')
operatingsystemmajrelease = facts[:os]['release']['major']
else
if facts[:operatingsystemmajrelease].nil?
operatingsystemmajrelease = facts[:operatingsystemrelease].split('.')[0]
Expand Down

0 comments on commit b1b69c5

Please sign in to comment.