Add support for MultiStrOpt

This replaces the provider implementation of aodh_config type so that
MultiStrOpt, which is used by several options like
 - oslo_messaging_notifications/driver
 - oslo_policy/policy_dirs
are handled correctly.

Change-Id: I3cae6998ec9a2157f507650859e030c576a3cd8c
This commit is contained in:
Takashi Kajinami 2022-02-07 00:58:13 +09:00
parent 1d954522d4
commit a7b1d30149
4 changed files with 17 additions and 8 deletions

View File

@ -1,6 +1,6 @@
Puppet::Type.type(:{{cookiecutter.project_name}}_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
:openstackconfig,
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
) do
def self.file_path

View File

@ -7,14 +7,23 @@ Puppet::Type.newtype(:{{cookiecutter.project_name}}_config) do
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
newproperty(:value, :array_matching => :all) do
desc 'The value of the setting to be defined.'
def insync?(is)
return true if @should.empty?
return false unless is.is_a? Array
return false unless is.length == @should.length
return (
is & @should == is or
is & @should.map(&:to_s) == is
)
end
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
newvalues(/^[\S ]*$/)
def is_to_s( currentvalue )
if resource.secret?

View File

@ -2,7 +2,7 @@
# these tests are a little concerning b/c they are hacking around the
# modulepath, so these tests will not catch issues that may eventually arise
# related to loading these plugins.
# I could not, for the life of me, figure out how to programatcally set the modulepath
# I could not, for the life of me, figure out how to programmatically set the modulepath
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
@ -26,7 +26,7 @@ $LOAD_PATH.push(
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:{{cookiecutter.project_name}}_config).provider(:ini_setting)
provider_class = Puppet::Type.type(:{{cookiecutter.project_name}}_config).provider(:openstackconfig)
describe provider_class do
it 'should default to the default setting when no other one is specified' do

View File

@ -29,12 +29,12 @@ describe 'Puppet::Type.type(:{{cookiecutter.project_name}}_config)' do
it 'should accept a valid value' do
@{{cookiecutter.project_name}}_config[:value] = 'bar'
expect(@{{cookiecutter.project_name}}_config[:value]).to eq('bar')
expect(@{{cookiecutter.project_name}}_config[:value]).to eq(['bar'])
end
it 'should not accept a value with whitespace' do
@{{cookiecutter.project_name}}_config[:value] = 'b ar'
expect(@{{cookiecutter.project_name}}_config[:value]).to eq('b ar')
expect(@{{cookiecutter.project_name}}_config[:value]).to eq(['b ar'])
end
it 'should accept valid ensure values' do