diff --git a/lib/puppet/provider/designate_config/ini_setting.rb b/lib/puppet/provider/designate_config/openstackconfig.rb similarity index 57% rename from lib/puppet/provider/designate_config/ini_setting.rb rename to lib/puppet/provider/designate_config/openstackconfig.rb index 53c0d4e3..3d2023c5 100644 --- a/lib/puppet/provider/designate_config/ini_setting.rb +++ b/lib/puppet/provider/designate_config/openstackconfig.rb @@ -1,6 +1,6 @@ Puppet::Type.type(:designate_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 diff --git a/lib/puppet/type/designate_config.rb b/lib/puppet/type/designate_config.rb index 0b86eef0..420d7a30 100644 --- a/lib/puppet/type/designate_config.rb +++ b/lib/puppet/type/designate_config.rb @@ -7,14 +7,22 @@ Puppet::Type.newtype(:designate_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? diff --git a/spec/unit/provider/designate_config/ini_setting_spec.rb b/spec/unit/provider/designate_config/openstackconfig_spec.rb similarity index 85% rename from spec/unit/provider/designate_config/ini_setting_spec.rb rename to spec/unit/provider/designate_config/openstackconfig_spec.rb index fb83d3a0..b0eb1917 100644 --- a/spec/unit/provider/designate_config/ini_setting_spec.rb +++ b/spec/unit/provider/designate_config/openstackconfig_spec.rb @@ -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,12 +26,12 @@ $LOAD_PATH.push( 'lib') ) require 'spec_helper' -provider_class = Puppet::Type.type(:designate_config).provider(:ini_setting) +provider_class = Puppet::Type.type(:designate_config).provider(:openstackconfig) describe provider_class do it 'should default to the default setting when no other one is specified' do resource = Puppet::Type::Designate_config.new( - {:name => 'DEFAULT/foo', :value => 'plop'} + {:name => 'DEFAULT/foo', :value => 'bar'} ) provider = provider_class.new(resource) expect(provider.section).to eq('DEFAULT') @@ -40,11 +40,11 @@ describe provider_class do it 'should allow setting to be set explicitly' do resource = Puppet::Type::Designate_config.new( - {:name => 'boo/zoo', :value => 'plop'} + {:name => 'dude/foo', :value => 'bar'} ) provider = provider_class.new(resource) - expect(provider.section).to eq('boo') - expect(provider.setting).to eq('zoo') + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') end it 'should ensure absent when is specified as a value' do @@ -64,4 +64,5 @@ describe provider_class do provider.exists? expect(resource[:ensure]).to eq :absent end + end diff --git a/spec/unit/type/designate_config_spec.rb b/spec/unit/type/designate_config_spec.rb index ebc6ea21..7e9eb4de 100644 --- a/spec/unit/type/designate_config_spec.rb +++ b/spec/unit/type/designate_config_spec.rb @@ -30,12 +30,12 @@ describe 'Puppet::Type.type(:designate_config)' do it 'should accept a valid value' do @designate_config[:value] = 'bar' - expect(@designate_config[:value]).to eq('bar') + expect(@designate_config[:value]).to eq(['bar']) end it 'should not accept a value with whitespace' do @designate_config[:value] = 'b ar' - expect(@designate_config[:value]).to eq('b ar') + expect(@designate_config[:value]).to eq(['b ar']) end it 'should accept valid ensure values' do