Skip to content

Commit

Permalink
FacterDB: Switch to stringified facts
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Sep 9, 2024
1 parent c5b8766 commit 4bf4e47
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
enabled_lint_checks:
- parameter_documentation
- parameter_types
spec/spec_helper.rb:
facterdb_string_keys: true
21 changes: 10 additions & 11 deletions spec/classes/letsencrypt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
describe 'with defaults' do
it { is_expected.to compile }

epel = facts[:osfamily] == 'RedHat' && facts[:operatingsystem] != 'Fedora'

epel = facts['os']['family'] == 'RedHat' && facts['os']['name'] != 'Fedora'
it 'contains the correct resources' do
is_expected.to contain_class('letsencrypt::install').
with(configure_epel: epel).
Expand All @@ -33,7 +32,7 @@
cron_monthday: ['*'])
is_expected.to contain_cron('letsencrypt-renew').with_ensure('absent')

if facts[:osfamily] == 'FreeBSD'
if facts['os']['family'] == 'FreeBSD'
is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini email [email protected]')
is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini server https://acme-v02.api.letsencrypt.org/directory')
is_expected.to contain_file('letsencrypt-renewal-hooks-puppet').
Expand All @@ -50,7 +49,7 @@
is_expected.to contain_file('letsencrypt-renewal-hooks-puppet').with_path('/etc/letsencrypt/renewal-hooks-puppet')
end

if facts[:osfamily] == 'RedHat'
if facts['os']['family'] == 'RedHat'
if epel
is_expected.to contain_class('epel').that_comes_before('Package[letsencrypt]')
else
Expand All @@ -60,20 +59,20 @@
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
is_expected.to contain_package('letsencrypt').with(name: 'certbot').with_ensure('installed')
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
elsif facts[:osfamily] == 'Debian'
elsif facts['os']['family'] == 'Debian'
is_expected.to contain_class('letsencrypt::install').with(package_name: 'certbot')
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
elsif facts[:operatingsystem] == 'Gentoo'
elsif facts['os']['name'] == 'Gentoo'
is_expected.to contain_class('letsencrypt::install').with(package_name: 'app-crypt/certbot')
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
is_expected.to contain_package('letsencrypt').with(name: 'app-crypt/certbot').with_ensure('installed')
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
elsif facts[:operatingsystem] == 'OpenBSD'
elsif facts['os']['name' == 'OpenBSD'
is_expected.to contain_class('letsencrypt::install').with(package_name: 'certbot')

Check failure on line 71 in spec/classes/letsencrypt_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Lint/Syntax: unexpected token tIDENTIFIER (Using Ruby 2.6 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
is_expected.to contain_package('letsencrypt').with(name: 'certbot').with_ensure('installed')
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
elsif facts[:operatingsystem] == 'FreeBSD'
elsif facts['os']['name' == 'FreeBSD'
is_expected.to contain_class('letsencrypt::install').with(package_name: 'py39-certbot')

Check failure on line 76 in spec/classes/letsencrypt_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Lint/Syntax: unexpected token tIDENTIFIER (Using Ruby 2.6 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
is_expected.to contain_package('letsencrypt').with(name: 'py39-certbot').with_ensure('installed')
Expand All @@ -100,7 +99,7 @@
describe 'with custom config' do
let(:additional_params) { { config: { 'foo' => 'bar' } } }

case facts[:operatingsystem]
case facts['os']['name']
when 'FreeBSD'
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini foo bar') }
else
Expand Down Expand Up @@ -237,7 +236,7 @@

it { is_expected.to compile.with_all_deps }

case facts[:operatingsystem]
case facts['os']['name']
when 'FreeBSD'
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini email [email protected]') }
else
Expand All @@ -253,7 +252,7 @@
context 'with unsafe_registration set to true' do
let(:params) { { unsafe_registration: true } }

case facts[:operatingsystem]
case facts['os']['name']
when 'FreeBSD'
it { is_expected.not_to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini email [email protected]') }
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini register-unsafely-without-email true') }
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/plugin/dns_cloudflare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class { 'letsencrypt':
PUPPET
end
let(:package_name) do
if %w[Debian RedHat].include?(facts[:os]['family'])
if %w[Debian RedHat].include?(facts['os']['family'])
'python3-certbot-dns-cloudflare'
elsif %w[FreeBSD].include?(facts[:os]['family'])
elsif %w[FreeBSD].include?(facts['os']['family'])
'py39-certbot-dns-cloudflare'
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/plugin/dns_rfc2136_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class { 'letsencrypt':
PUPPET
end
let(:package_name) do
case facts[:os]['family']
case facts['os']['family']
when 'FreeBSD'
'py39-certbot-dns-rfc2136'
when 'OpenBSD'
Expand All @@ -39,7 +39,7 @@ class { 'letsencrypt':
end

# FreeBSD uses a different filesystem path
let(:pathprefix) { facts[:kernel] == 'FreeBSD' ? '/usr/local' : '' }
let(:pathprefix) { facts['kernel'] == 'FreeBSD' ? '/usr/local' : '' }

it do
if package_name.empty?
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require 'voxpupuli/test/spec_helper'

RSpec.configure do |c|
c.facterdb_string_keys = false
c.facterdb_string_keys = true
end

add_mocked_facts!
Expand Down

0 comments on commit 4bf4e47

Please sign in to comment.