 e6e8c9d836
			
		
	
	e6e8c9d836
	
	
	
		
			
			With the creation of the new openstack_config provider, some processing
that was done in swift_config has been centralized in
openstack_config.
Impacted methods are :
  * section
  * setting
  * separator
Also, this commit adds the fact that, when passing a specific string
(ensure_absent_val) the provider will behave as if ensure => absent was
specified. '<SERVICE DEFAULT>' is the default value for
ensure_absent_val.
The use case is the following :
swift_config { 'DEFAULT/foo' : value => 'bar' } # will work as usual
swift_config { 'DEFAULT/foo' : value => '<SERVICE DEFAULT>' } # will mean absent
That means that all the current :
if $myvar {
  swift_config { 'DEFAULT/foo' : value => $myvar }
} else {
  swift_config { 'DEFAULT/foo' : ensure => absent }
}
can be removed in favor of :
swift_config { 'DEFAULT/foo' : value => $myvar }
If for any reason '<SERVICE DEFAULT>' turns out to be a valid value for
a specific parameter. One could by pass that doing the following :
swift_config { 'DEFAULT/foo' : value => '<SERVICE DEFAULT>',
ensure_absent_val => 'foo' }
Change-Id: I9281d2cae81f9799327f7f6e04498d6bc723f233
Depends-On: I0eeebde3aac2662cc7e69bfad7f8d2481463a218
		
	
		
			
				
	
	
		
			73 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| $LOAD_PATH.push(
 | |
|   File.join(
 | |
|     File.dirname(__FILE__),
 | |
|     '..',
 | |
|     '..',
 | |
|     '..',
 | |
|     'fixtures',
 | |
|     'modules',
 | |
|     'inifile',
 | |
|     'lib')
 | |
| )
 | |
| $LOAD_PATH.push(
 | |
|   File.join(
 | |
|     File.dirname(__FILE__),
 | |
|     '..',
 | |
|     '..',
 | |
|     '..',
 | |
|     'fixtures',
 | |
|     'modules',
 | |
|     'openstacklib',
 | |
|     'lib')
 | |
| )
 | |
| 
 | |
| require 'spec_helper'
 | |
| 
 | |
| provider_class = Puppet::Type.type(:swift_container_config).provider(:ini_setting)
 | |
| 
 | |
| describe provider_class do
 | |
| 
 | |
|   it 'should default to the default setting when no other one is specified' do
 | |
|     resource = Puppet::Type::Swift_container_config.new(
 | |
|       {
 | |
|         :name => 'DEFAULT/foo',
 | |
|         :value => 'bar'
 | |
|       }
 | |
|     )
 | |
|     provider = provider_class.new(resource)
 | |
|     expect(provider.section).to eq('DEFAULT')
 | |
|     expect(provider.setting).to eq('foo')
 | |
|   end
 | |
| 
 | |
|   it 'should allow setting to be set explicitly' do
 | |
|     resource = Puppet::Type::Swift_container_config.new(
 | |
|       {
 | |
|         :name => 'dude/foo',
 | |
|         :value => 'bar'
 | |
|       }
 | |
|     )
 | |
|     provider = provider_class.new(resource)
 | |
|     expect(provider.section).to eq('dude')
 | |
|     expect(provider.setting).to eq('foo')
 | |
|   end
 | |
| 
 | |
|   it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
 | |
|     resource = Puppet::Type::Swift_container_config.new(
 | |
|       {:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
 | |
|     )
 | |
|     provider = provider_class.new(resource)
 | |
|     provider.exists?
 | |
|     expect(resource[:ensure]).to eq :absent
 | |
|   end
 | |
| 
 | |
|   it 'should ensure absent when value matches ensure_absent_val' do
 | |
|     resource = Puppet::Type::Swift_container_config.new(
 | |
|       {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
 | |
|     )
 | |
|     provider = provider_class.new(resource)
 | |
|     provider.exists?
 | |
|     expect(resource[:ensure]).to eq :absent
 | |
|   end
 | |
| 
 | |
| end
 |