Browse Source

Use anchor to require necessary packages

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

Change-Id: I3d1d4438094bf964ce8933c6c4371a67c45c678c
changes/80/725180/1
Takashi Kajinami 1 year ago
parent
commit
1ed72b472b
2 changed files with 6 additions and 5 deletions
  1. +2
    -2
      lib/puppet/type/tacker_config.rb
  2. +4
    -3
      spec/unit/type/tacker_config_spec.rb

+ 2
- 2
lib/puppet/type/tacker_config.rb View File

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

+ 4
- 3
spec/unit/type/tacker_config_spec.rb View File

@ -1,5 +1,6 @@
require 'puppet'
require 'puppet/type/tacker_config'
describe 'Puppet::Type.type(:tacker_config)' do
before :each do
@tacker_config = Puppet::Type.type(:tacker_config).new(:name => 'DEFAULT/foo', :value => 'bar')
@ -52,12 +53,12 @@ describe 'Puppet::Type.type(:tacker_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'tacker')
catalog.add_resource package, @tacker_config
anchor = Puppet::Type.type(:anchor).new(:name => 'tacker::install::end')
catalog.add_resource anchor, @tacker_config
dependency = @tacker_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@tacker_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end


Loading…
Cancel
Save