From a503ac22c307c6732471598a6c666519854b41fa Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 4 May 2020 15:11:01 +0900 Subject: [PATCH] Use anchor to require necessary packages ... so that correct packages are required without re-defining them in resource implementations. Change-Id: I536d77e157d96211e317297cefd321d6a7d6a98f --- lib/puppet/type/murano_cfapi_config.rb | 4 ++-- lib/puppet/type/murano_cfapi_paste_ini_config.rb | 4 ++-- lib/puppet/type/murano_config.rb | 4 ++-- lib/puppet/type/murano_paste_ini_config.rb | 5 +++-- spec/unit/type/murano_cfapi_config_spec.rb | 7 ++++--- spec/unit/type/murano_cfapi_paste_ini_config_spec.rb | 7 ++++--- spec/unit/type/murano_config_spec.rb | 7 ++++--- spec/unit/type/murano_paste_ini_config_spec.rb | 7 ++++--- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/puppet/type/murano_cfapi_config.rb b/lib/puppet/type/murano_cfapi_config.rb index 22475c8..793b523 100644 --- a/lib/puppet/type/murano_cfapi_config.rb +++ b/lib/puppet/type/murano_cfapi_config.rb @@ -45,7 +45,7 @@ Puppet::Type.newtype(:murano_cfapi_config) do defaultto('') end - autorequire(:package) do - 'murano-common' + autorequire(:anchor) do + ['murano::install::end'] end end diff --git a/lib/puppet/type/murano_cfapi_paste_ini_config.rb b/lib/puppet/type/murano_cfapi_paste_ini_config.rb index 7ae2f6b..6c3397f 100644 --- a/lib/puppet/type/murano_cfapi_paste_ini_config.rb +++ b/lib/puppet/type/murano_cfapi_paste_ini_config.rb @@ -45,7 +45,7 @@ Puppet::Type.newtype(:murano_cfapi_paste_ini_config) do defaultto('') end - autorequire(:package) do - 'murano-common' + autorequire(:anchor) do + ['murano::install::end'] end end diff --git a/lib/puppet/type/murano_config.rb b/lib/puppet/type/murano_config.rb index 8f4f0d5..aa2bef5 100644 --- a/lib/puppet/type/murano_config.rb +++ b/lib/puppet/type/murano_config.rb @@ -45,7 +45,7 @@ Puppet::Type.newtype(:murano_config) do defaultto('') end - autorequire(:package) do - 'murano-common' + autorequire(:anchor) do + ['murano::install::end'] end end diff --git a/lib/puppet/type/murano_paste_ini_config.rb b/lib/puppet/type/murano_paste_ini_config.rb index 4cf3ea1..b3f11bd 100644 --- a/lib/puppet/type/murano_paste_ini_config.rb +++ b/lib/puppet/type/murano_paste_ini_config.rb @@ -45,7 +45,8 @@ Puppet::Type.newtype(:murano_paste_ini_config) do defaultto('') end - autorequire(:package) do - 'murano-common' + autorequire(:anchor) do + ['murano::install::end'] end + end diff --git a/spec/unit/type/murano_cfapi_config_spec.rb b/spec/unit/type/murano_cfapi_config_spec.rb index f146efc..64e0857 100644 --- a/spec/unit/type/murano_cfapi_config_spec.rb +++ b/spec/unit/type/murano_cfapi_config_spec.rb @@ -1,5 +1,6 @@ require 'puppet' require 'puppet/type/murano_cfapi_config' + describe 'Puppet::Type.type(:murano_cfapi_config)' do before :each do @murano_cfapi_config = Puppet::Type.type(:murano_cfapi_config).new(:name => 'DEFAULT/foo', :value => 'bar') @@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_cfapi_config)' do it 'should autorequire the package that install the file' do catalog = Puppet::Resource::Catalog.new - package = Puppet::Type.type(:package).new(:name => 'murano-common') - catalog.add_resource package, @murano_cfapi_config + anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end') + catalog.add_resource anchor, @murano_cfapi_config dependency = @murano_cfapi_config.autorequire expect(dependency.size).to eq(1) expect(dependency[0].target).to eq(@murano_cfapi_config) - expect(dependency[0].source).to eq(package) + expect(dependency[0].source).to eq(anchor) end end diff --git a/spec/unit/type/murano_cfapi_paste_ini_config_spec.rb b/spec/unit/type/murano_cfapi_paste_ini_config_spec.rb index fc59c4c..f997525 100644 --- a/spec/unit/type/murano_cfapi_paste_ini_config_spec.rb +++ b/spec/unit/type/murano_cfapi_paste_ini_config_spec.rb @@ -1,5 +1,6 @@ require 'puppet' require 'puppet/type/murano_cfapi_paste_ini_config' + describe 'Puppet::Type.type(:murano_cfapi_paste_ini_config)' do before :each do @murano_cfapi_paste_ini_config = Puppet::Type.type(:murano_cfapi_paste_ini_config).new(:name => 'DEFAULT/foo', :value => 'bar') @@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_cfapi_paste_ini_config)' do it 'should autorequire the package that install the file' do catalog = Puppet::Resource::Catalog.new - package = Puppet::Type.type(:package).new(:name => 'murano-common') - catalog.add_resource package, @murano_cfapi_paste_ini_config + anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end') + catalog.add_resource anchor, @murano_cfapi_paste_ini_config dependency = @murano_cfapi_paste_ini_config.autorequire expect(dependency.size).to eq(1) expect(dependency[0].target).to eq(@murano_cfapi_paste_ini_config) - expect(dependency[0].source).to eq(package) + expect(dependency[0].source).to eq(anchor) end end diff --git a/spec/unit/type/murano_config_spec.rb b/spec/unit/type/murano_config_spec.rb index dc08e46..ba4abe3 100644 --- a/spec/unit/type/murano_config_spec.rb +++ b/spec/unit/type/murano_config_spec.rb @@ -1,5 +1,6 @@ require 'puppet' require 'puppet/type/murano_config' + describe 'Puppet::Type.type(:murano_config)' do before :each do @murano_config = Puppet::Type.type(:murano_config).new(:name => 'DEFAULT/foo', :value => 'bar') @@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_config)' do it 'should autorequire the package that install the file' do catalog = Puppet::Resource::Catalog.new - package = Puppet::Type.type(:package).new(:name => 'murano-common') - catalog.add_resource package, @murano_config + anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end') + catalog.add_resource anchor, @murano_config dependency = @murano_config.autorequire expect(dependency.size).to eq(1) expect(dependency[0].target).to eq(@murano_config) - expect(dependency[0].source).to eq(package) + expect(dependency[0].source).to eq(anchor) end end diff --git a/spec/unit/type/murano_paste_ini_config_spec.rb b/spec/unit/type/murano_paste_ini_config_spec.rb index 817e30a..d8f4daf 100644 --- a/spec/unit/type/murano_paste_ini_config_spec.rb +++ b/spec/unit/type/murano_paste_ini_config_spec.rb @@ -1,5 +1,6 @@ require 'puppet' require 'puppet/type/murano_paste_ini_config' + describe 'Puppet::Type.type(:murano_paste_ini_config)' do before :each do @murano_paste_ini_config = Puppet::Type.type(:murano_paste_ini_config).new(:name => 'DEFAULT/foo', :value => 'bar') @@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_paste_ini_config)' do it 'should autorequire the package that install the file' do catalog = Puppet::Resource::Catalog.new - package = Puppet::Type.type(:package).new(:name => 'murano-common') - catalog.add_resource package, @murano_paste_ini_config + anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end') + catalog.add_resource anchor, @murano_paste_ini_config dependency = @murano_paste_ini_config.autorequire expect(dependency.size).to eq(1) expect(dependency[0].target).to eq(@murano_paste_ini_config) - expect(dependency[0].source).to eq(package) + expect(dependency[0].source).to eq(anchor) end end