Skip to content

Commit 7cc60b8

Browse files
committed
FacterDB: Switch to stringified facts
1 parent 959c7cf commit 7cc60b8

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

.sync.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
enabled_lint_checks:
44
- parameter_documentation
55
- parameter_types
6+
spec/spec_helper.rb:
7+
facterdb_string_keys: true

spec/classes/letsencrypt_spec.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
describe 'with defaults' do
1818
it { is_expected.to compile }
1919

20-
epel = facts[:osfamily] == 'RedHat' && facts[:operatingsystem] != 'Fedora'
21-
20+
epel = facts['os']['family'] == 'RedHat' && facts['os']['name'] != 'Fedora'
2221
it 'contains the correct resources' do
2322
is_expected.to contain_class('letsencrypt::install').
2423
with(configure_epel: epel).
@@ -33,7 +32,7 @@
3332
cron_monthday: ['*'])
3433
is_expected.to contain_cron('letsencrypt-renew').with_ensure('absent')
3534

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

53-
if facts[:osfamily] == 'RedHat'
52+
if facts['os']['family'] == 'RedHat'
5453
if epel
5554
is_expected.to contain_class('epel').that_comes_before('Package[letsencrypt]')
5655
else
@@ -60,20 +59,20 @@
6059
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
6160
is_expected.to contain_package('letsencrypt').with(name: 'certbot').with_ensure('installed')
6261
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
63-
elsif facts[:osfamily] == 'Debian'
62+
elsif facts['os']['family'] == 'Debian'
6463
is_expected.to contain_class('letsencrypt::install').with(package_name: 'certbot')
6564
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
66-
elsif facts[:operatingsystem] == 'Gentoo'
65+
elsif facts['os']['name'] == 'Gentoo'
6766
is_expected.to contain_class('letsencrypt::install').with(package_name: 'app-crypt/certbot')
6867
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
6968
is_expected.to contain_package('letsencrypt').with(name: 'app-crypt/certbot').with_ensure('installed')
7069
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
71-
elsif facts[:operatingsystem] == 'OpenBSD'
70+
elsif facts['os']['name'] == 'OpenBSD'
7271
is_expected.to contain_class('letsencrypt::install').with(package_name: 'certbot')
7372
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
7473
is_expected.to contain_package('letsencrypt').with(name: 'certbot').with_ensure('installed')
7574
is_expected.to contain_file('/etc/letsencrypt').with(ensure: 'directory')
76-
elsif facts[:operatingsystem] == 'FreeBSD'
75+
elsif facts['os']['name'] == 'FreeBSD'
7776
is_expected.to contain_class('letsencrypt::install').with(package_name: 'py311-certbot')
7877
is_expected.to contain_class('letsencrypt').with(package_command: 'certbot')
7978
is_expected.to contain_package('letsencrypt').with(name: 'py311-certbot').with_ensure('installed')
@@ -100,7 +99,7 @@
10099
describe 'with custom config' do
101100
let(:additional_params) { { config: { 'foo' => 'bar' } } }
102101

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

238237
it { is_expected.to compile.with_all_deps }
239238

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

256-
case facts[:operatingsystem]
255+
case facts['os']['name']
257256
when 'FreeBSD'
258257
it { is_expected.not_to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini email [email protected]') }
259258
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini register-unsafely-without-email true') }

spec/classes/plugin/dns_cloudflare_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class { 'letsencrypt':
1515
PUPPET
1616
end
1717
let(:package_name) do
18-
if %w[Debian RedHat].include?(facts[:os]['family'])
18+
if %w[Debian RedHat].include?(facts['os']['family'])
1919
'python3-certbot-dns-cloudflare'
20-
elsif %w[FreeBSD].include?(facts[:os]['family'])
20+
elsif %w[FreeBSD].include?(facts['os']['family'])
2121
'py311-certbot-dns-cloudflare'
2222
end
2323
end

spec/classes/plugin/dns_rfc2136_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class { 'letsencrypt':
1515
PUPPET
1616
end
1717
let(:package_name) do
18-
case facts[:os]['family']
18+
case facts['os']['family']
1919
when 'FreeBSD'
2020
'py311-certbot-dns-rfc2136'
2121
when 'OpenBSD'
@@ -39,7 +39,7 @@ class { 'letsencrypt':
3939
end
4040

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

4444
it do
4545
if package_name.empty?

spec/classes/plugin/dns_route53_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class { 'letsencrypt':
1515
PUPPET
1616
end
1717
let(:package_name) do
18-
case facts[:os]['family']
18+
case facts['os']['family']
1919
when 'FreeBSD'
2020
'py311-certbot-dns-route53'
2121
when 'OpenBSD'

spec/defines/letsencrypt_certonly_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
let(:pre_condition) { "class { letsencrypt: email => '[email protected]', package_command => 'letsencrypt' }" }
1313

1414
# FreeBSD uses a different filesystem path
15-
pathprefix = facts[:kernel] == 'FreeBSD' ? '/usr/local' : ''
15+
pathprefix = facts['kernel'] == 'FreeBSD' ? '/usr/local' : ''
1616

1717
context 'with a single domain' do
1818
let(:title) { 'foo.example.com' }
@@ -32,7 +32,7 @@
3232
with_content(%r{#!/bin/sh})
3333
end
3434

35-
if facts[:osfamily] == 'FreeBSD'
35+
if facts['os']['family'] == 'FreeBSD'
3636
it { is_expected.to contain_file('/usr/local/etc/letsencrypt') }
3737
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini email [email protected]') }
3838
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini server https://acme-v02.api.letsencrypt.org/directory') }
@@ -497,7 +497,7 @@ class { 'letsencrypt::plugin::dns_cloudflare':
497497
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_unless(['test ! -f /usr/local/sbin/letsencrypt-domain-validation', '/usr/local/sbin/letsencrypt-domain-validation /foo/bar/baz/live/foo.example.com/cert.pem \'foo.example.com\'']) }
498498
end
499499

500-
context 'on FreeBSD', if: facts[:os]['name'] == 'FreeBSD' do
500+
context 'on FreeBSD', if: facts['os']['name'] == 'FreeBSD' do
501501
let(:title) { 'foo.example.com' }
502502
let(:pre_condition) { "class { letsencrypt: email => '[email protected]'}" }
503503

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
require 'voxpupuli/test/spec_helper'
1111

1212
RSpec.configure do |c|
13-
c.facterdb_string_keys = false
13+
c.facterdb_string_keys = true
1414
end
1515

1616
add_mocked_facts!

0 commit comments

Comments
 (0)