diff --git a/lib/puppet/provider/zaqar_config/ini_setting.rb b/lib/puppet/provider/zaqar_config/openstackconfig.rb similarity index 54% rename from lib/puppet/provider/zaqar_config/ini_setting.rb rename to lib/puppet/provider/zaqar_config/openstackconfig.rb index e92e4ab..88215ca 100644 --- a/lib/puppet/provider/zaqar_config/ini_setting.rb +++ b/lib/puppet/provider/zaqar_config/openstackconfig.rb @@ -1,6 +1,6 @@ Puppet::Type.type(:zaqar_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/zaqar_config.rb b/lib/puppet/type/zaqar_config.rb index 45bc392..48e145a 100644 --- a/lib/puppet/type/zaqar_config.rb +++ b/lib/puppet/type/zaqar_config.rb @@ -7,14 +7,22 @@ Puppet::Type.newtype(:zaqar_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/zaqar_config/ini_setting_spec.rb b/spec/unit/provider/zaqar_config/openstackconfig_spec.rb similarity index 96% rename from spec/unit/provider/zaqar_config/ini_setting_spec.rb rename to spec/unit/provider/zaqar_config/openstackconfig_spec.rb index 65d4e4a..9d9723d 100644 --- a/spec/unit/provider/zaqar_config/ini_setting_spec.rb +++ b/spec/unit/provider/zaqar_config/openstackconfig_spec.rb @@ -26,7 +26,7 @@ $LOAD_PATH.push( ) require 'spec_helper' -provider_class = Puppet::Type.type(:zaqar_config).provider(:ini_setting) +provider_class = Puppet::Type.type(:zaqar_config).provider(:openstackconfig) describe provider_class do it 'should default to the default setting when no other one is specified' do diff --git a/spec/unit/type/zaqar_config_spec.rb b/spec/unit/type/zaqar_config_spec.rb index 9978e36..03a70be 100644 --- a/spec/unit/type/zaqar_config_spec.rb +++ b/spec/unit/type/zaqar_config_spec.rb @@ -29,12 +29,12 @@ describe 'Puppet::Type.type(:zaqar_config)' do it 'should accept a valid value' do @zaqar_config[:value] = 'bar' - expect(@zaqar_config[:value]).to eq('bar') + expect(@zaqar_config[:value]).to eq(['bar']) end it 'should not accept a value with whitespace' do @zaqar_config[:value] = 'b ar' - expect(@zaqar_config[:value]).to eq('b ar') + expect(@zaqar_config[:value]).to eq(['b ar']) end it 'should accept valid ensure values' do