Enforce boolean values

Usage of truthy strings were deprecated a while ago[1]. Let's enforce
boolean values to simplify the logic.

[1] 171b6d172d

Change-Id: Ic907c99d6a956a9a168200cf61a4b211fe582d07
This commit is contained in:
Takashi Kajinami 2023-03-17 14:56:03 +09:00
parent 080edaea9e
commit 537fc7c64d
4 changed files with 15 additions and 56 deletions

View File

@ -201,9 +201,9 @@ class qdr(
validate_legacy(String, 'validate_re', $listener_port, ['\d+'])
}
$listener_auth_peer_bool = qdr::fixTruthy($listener_auth_peer)
$listener_require_encrypt_bool = qdr::fixTruthy($listener_require_encrypt)
$listener_require_ssl_bool = qdr::fixTruthy($listener_require_ssl)
validate_legacy(Boolean, 'validate_bool', $listener_auth_peer)
validate_legacy(Boolean, 'validate_bool', $listener_require_encrypt)
validate_legacy(Boolean, 'validate_bool', $listener_require_ssl)
# TODO (ansmith) - manage repo via openstack-extras
# if $facts['os']['name'] == 'Ubuntu' {
@ -223,18 +223,3 @@ class qdr(
-> Class['qdr::service']
}
function qdr::fixTruthy($truthyvar) >> Boolean {
if $truthyvar.is_a(String) {
validate_legacy(Enum['yes', 'no'], 'validate_re', $truthyvar, ['^(yes$|no$)'])
warning('Usage of yes/no has been deprecated. Use boolean instead')
if $truthyvar == 'yes' {
return true
} elsif $truthyvar == 'no' {
return false
}
} else {
validate_legacy(Boolean, 'validate_bool', $truthyvar)
return $truthyvar
}
}

View File

@ -0,0 +1,9 @@
---
upgrade:
- |
The following parameters no longer accept string values(`yes` and `no`) and
requires boolean values.
- ``qdr::listener_auth_peer``
- ``qdr::listener_require_encrypt``
- ``qdr::listener_require_ssl``

View File

@ -129,41 +129,6 @@ describe 'qdr' do
should contain_file('qdrouterd.conf').with_content(/keyFile: \/etc\/qpid-dispatch\/ssl\/puppet_qdr.pem/)
end
end
context 'with qdr ssl enabled using backwards compatible truthy string' do
let :params do
{
:listener_require_ssl => 'yes',
:listener_ssl_cert_db => '/etc/ssl/certs/ca-bundle.crt',
:listener_ssl_cert_file => '/etc/pki/ca-trust/source/anchors/puppet_qdr.pem',
:listener_ssl_key_file => '/etc/qpid-dispatch/ssl/puppet_qdr.pem',
}
end
it do
should contain_file('qdrouterd.conf').with_content(/sslProfile {/)
should contain_file('qdrouterd.conf').with_content(/certDb: \/etc\/ssl\/certs\/ca-bundle.crt/)
should contain_file('qdrouterd.conf').with_content(/certFile: \/etc\/pki\/ca-trust\/source\/anchors\/puppet_qdr.pem/)
should contain_file('qdrouterd.conf').with_content(/keyFile: \/etc\/qpid-dispatch\/ssl\/puppet_qdr.pem/)
end
end
context 'with qdr ssl disabled using backwards compatible truthy string' do
let :params do
{
:listener_require_ssl => 'no',
:listener_ssl_cert_file => 'SHOULDNOTSHOWUP',
}
end
it do
should contain_file('qdrouterd.conf').without_content(/SHOULDNOTSHOWUP/)
end
end
end
on_supported_os({

View File

@ -29,7 +29,7 @@ router {
saslConfigName: <%= @router_sasl_name %>
}
<%- if @listener_require_ssl_bool -%>
<%- if @listener_require_ssl -%>
sslProfile {
name: <%= @router_id %>
certDb: <%= @listener_ssl_cert_db %>
@ -50,10 +50,10 @@ sslProfile {
listener {
host: <%= @listener_addr %>
port: <%= @listener_port %>
<%- if @listener_require_ssl_bool -%>
<%- if @listener_require_ssl -%>
sslProfile: <%= @router_id %>
<%- end -%>
authenticatePeer: <%= @listener_auth_peer_bool %>
authenticatePeer: <%= @listener_auth_peer %>
saslMechanisms: <%= @listener_sasl_mech %>
}