Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing boolean #131

Merged
merged 4 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org' # rubocop:disable Style/FetchEnvVar
source ENV.fetch('GEM_SOURCE', 'https://rubygems.org')

puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['~> 5.0.0']
puppetversion = ENV.key?('PUPPET_VERSION') ? ENV.fetch('PUPPET_VERSION') : ['~> 5.0.0']
gem 'facter', '>= 1.7.0'
gem 'metadata-json-lint', '< 2.0.0'
gem 'puppet', puppetversion
Expand Down
4 changes: 2 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# powerdns::config
define powerdns::config(
String $setting = $title,
Variant[String, Integer] $value = '',
Variant[String, Integer, Boolean] $value = '',
Enum['present', 'absent'] $ensure = 'present',
Enum['authoritative', 'recursor'] $type = 'authoritative'
) {
Expand All @@ -14,7 +14,7 @@
'local-ipv6'
]
unless $ensure == 'absent' or ($setting in $empty_value_allowed) {
assert_type(Variant[String[1], Integer], $value) |$_expected, $_actual| {
assert_type(Variant[String[1], Integer, Boolean], $value) |$_expected, $_actual| {
fail("Value for ${setting} can't be empty.")
}
}
Expand Down
17 changes: 17 additions & 0 deletions spec/defines/powerdns_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

override_facts = {
root_home: '/root'
}
Expand Down Expand Up @@ -131,6 +133,21 @@
expect { subject.call }.to raise_error(/expects a match for Enum\['authoritative', 'recursor'\], got/)
end
end

context 'powerdns::config with boolean' do
let(:params) do
{
setting: 'webserver',
value: true,
type: 'recursor'
}
end

it {
is_expected.to contain_file_line(format('powerdns-config-webserver-%<config>s',
config: recursor_config)).with_line('webserver=true')
}
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Configure all nodes in nodeset
c.before :suite do
hosts.each do |host|
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no' # rubocop:disable Style/FetchEnvVar
run_puppet_install_helper unless ENV.fetch('BEAKER_provision') == 'no'

# Install rsync
install_package(host, 'rsync')
Expand Down