Browse Source

Use anchor to require necessary packages

... so that correct packages are required without re-defining them in
resource implementations.

Change-Id: Ib1348b6a65dbcd985212ddda7c28c4e4e88f675f
changes/31/725131/1
Takashi Kajinami 1 year ago
parent
commit
8c66365065
  1. 4
      lib/puppet/type/octavia_config.rb
  2. 4
      lib/puppet/type/octavia_ovn_provider_config.rb
  3. 8
      spec/unit/type/octavia_config_spec.rb
  4. 6
      spec/unit/type/octavia_ovn_provider_config_spec.rb

4
lib/puppet/type/octavia_config.rb

@ -46,8 +46,8 @@ Puppet::Type.newtype(:octavia_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'octavia'
autorequire(:anchor) do
['octavia::install::end']
end
end

4
lib/puppet/type/octavia_ovn_provider_config.rb

@ -46,8 +46,8 @@ Puppet::Type.newtype(:octavia_ovn_provider_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'octavia'
autorequire(:anchor) do
['octavia::install::end']
end
end

8
spec/unit/type/octavia_config_spec.rb

@ -50,14 +50,14 @@ describe 'Puppet::Type.type(:octavia_config)' do
}.to raise_error(Puppet::Error, /Invalid value/)
end
it 'should autorequire the package that install the file' do
it 'should autorequire the anchor that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'octavia')
catalog.add_resource package, @octavia_config
anchor = Puppet::Type.type(:anchor).new(:name => 'octavia::install::end')
catalog.add_resource anchor, @octavia_config
dependency = @octavia_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@octavia_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end

6
spec/unit/type/octavia_ovn_provider_config_spec.rb

@ -52,12 +52,12 @@ describe 'Puppet::Type.type(:octavia_ovn_provider_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'octavia')
catalog.add_resource package, @octavia_ovn_provider_config
anchor = Puppet::Type.type(:anchor).new(:name => 'octavia::install::end')
catalog.add_resource anchor, @octavia_ovn_provider_config
dependency = @octavia_ovn_provider_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@octavia_ovn_provider_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end

Loading…
Cancel
Save