summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-15 22:25:54 -0600
committerLuke Kanies <luke@madstop.com>2007-09-15 22:25:54 -0600
commitb3c8cdb67d9a423a1d14764f1e58f677d7ef8d41 (patch)
tree8659134d1de95e0db60aa297e1dde8fcac5b9c82
parentf17f19dae941b17a56c1fc83ed3a89712b98c427 (diff)
downloadpuppet-b3c8cdb67d9a423a1d14764f1e58f677d7ef8d41.tar.gz
puppet-b3c8cdb67d9a423a1d14764f1e58f677d7ef8d41.tar.xz
puppet-b3c8cdb67d9a423a1d14764f1e58f677d7ef8d41.zip
Configurations now set a "configuration" instance variable in resources that are inside a configuration, so the resources can interact with the configuration to get things like relationships.
-rw-r--r--lib/puppet/node/configuration.rb1
-rw-r--r--lib/puppet/type.rb4
-rwxr-xr-xspec/unit/node/configuration.rb15
3 files changed, 15 insertions, 5 deletions
diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb
index 8cb6ed1f9..9cd23926e 100644
--- a/lib/puppet/node/configuration.rb
+++ b/lib/puppet/node/configuration.rb
@@ -47,6 +47,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
else
@resource_table[ref] = resource
end
+ resource.configuration = self
add_vertex!(resource)
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index b4b6e3b18..03f571d4a 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -44,7 +44,9 @@ class Type
# that it is clear whether it operates on all attributes (thus has 'attr' in
# the method name, or whether it operates on a specific type of attributes.
attr_accessor :file, :line
- attr_reader :parent
+
+ # The configuration that this resource is stored in.
+ attr_accessor :configuration
attr_writer :title
attr_writer :noop
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb
index 3c30d9b3e..071afc041 100755
--- a/spec/unit/node/configuration.rb
+++ b/spec/unit/node/configuration.rb
@@ -137,9 +137,9 @@ end
describe Puppet::Node::Configuration, " when functioning as a resource container" do
before do
@config = Puppet::Node::Configuration.new("host")
- @one = stub 'resource1', :ref => "Me[you]"
- @two = stub 'resource2', :ref => "Me[him]"
- @dupe = stub 'resource3', :ref => "Me[you]"
+ @one = stub 'resource1', :ref => "Me[you]", :configuration= => nil
+ @two = stub 'resource2', :ref => "Me[him]", :configuration= => nil
+ @dupe = stub 'resource3', :ref => "Me[you]", :configuration= => nil
end
it "should make all vertices available by resource reference" do
@@ -182,6 +182,11 @@ describe Puppet::Node::Configuration, " when functioning as a resource container
conf.add_resource @two
end
end
+
+ it "should inform the resource that it is the resource's configuration" do
+ @one.expects(:configuration=).with(@config)
+ @config.add_resource @one
+ end
end
module ApplyingConfigurations
@@ -223,7 +228,9 @@ describe Puppet::Node::Configuration, " when applying" do
end
it "should yield the transaction if a block is provided" do
- pending "the code works but is not tested"
+ @config.apply do |trans|
+ trans.should equal(@transaction)
+ end
end
it "should default to not being a host configuration" do