Add support for [certificates] storage_path option

... and also add unit test coverage of the certificates class.

Change-Id: Ice02e476895408a9373741b7395f28771e7109ad
This commit is contained in:
Takashi Kajinami 2024-05-07 00:31:25 +09:00
parent 478ce9ae35
commit f542429fe9
3 changed files with 52 additions and 4 deletions

View File

@ -5,17 +5,23 @@
# === Parameters:
#
# [*cert_manager_type*]
# (optional) Certificate Manager plugin. Defaults to barbican. (string value)
# Defaults to 'barbican'
# (optional) Certificate Manager plugin.
# Defaults to $facts['os_service_default']
#
# [*storage_path*]
# (optional) Absolute path of the certificate storage directory.
# Defaults to $facts['os_service_default']
#
class magnum::certificates (
$cert_manager_type = $facts['os_service_default'],
$storage_path = $facts['os_service_default'],
) {
include magnum::deps
magnum_config { 'certificates/cert_manager_type':
value => $cert_manager_type;
magnum_config {
'certificates/cert_manager_type': value => $cert_manager_type;
'certificates/storage_path': value => $storage_path;
}
}

View File

@ -0,0 +1,4 @@
---
features:
- |
The new ``magnum::certificates::storage_path`` parameter has been added.

View File

@ -0,0 +1,38 @@
require 'spec_helper'
describe 'magnum::certificates' do
shared_examples 'magnum::certificates' do
it 'contains default values' do
is_expected.to contain_magnum_config('certificates/cert_manager_type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_magnum_config('certificates/storage_path').with_value('<SERVICE DEFAULT>')
end
context 'configure certificates with parameters' do
let :params do
{
:cert_manager_type => 'barbican',
:storage_path => '/var/lib/magnum/certificates/',
}
end
it 'contains overridden values' do
is_expected.to contain_magnum_config('certificates/cert_manager_type').with_value('barbican')
is_expected.to contain_magnum_config('certificates/storage_path').with_value('/var/lib/magnum/certificates/')
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts({}))
end
it_behaves_like 'magnum::certificates'
end
end
end