Add support for MultiStrOpt

This replaces the provider implementation of ec2api_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: If2441f4bf68b8e43a072d979a1c34a60c9c48bde
This commit is contained in:
Takashi Kajinami 2022-02-13 00:19:12 +09:00
parent a0c29e2420
commit 6cc72a4ed6
5 changed files with 23 additions and 20 deletions

View File

@ -1,15 +0,0 @@
Puppet::Type.type(:ec2api_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def self.file_path
'/etc/ec2api/ec2api.conf'
end
# added for backwards compatibility with older versions of inifile
def file_path
self.class.file_path
end
end

View File

@ -0,0 +1,10 @@
Puppet::Type.type(:ec2api_config).provide(
:openstackconfig,
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
) do
def self.file_path
'/etc/ec2api/ec2api.conf'
end
end

View File

@ -7,14 +7,22 @@ Puppet::Type.newtype(:ec2api_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
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

@ -1,5 +1,5 @@
require 'spec_helper'
provider_class = Puppet::Type.type(:ec2api_config).provider(:ini_setting)
provider_class = Puppet::Type.type(:ec2api_config).provider(:openstackconfig)
describe provider_class do
it 'should default to the default setting when no other one is specified' do

View File

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