We need to be able to do compatibility testing, and this allows us to do so.
Signed-off-by: Luke Kanies <[email protected]> --- lib/puppet/parser/compiler.rb | 4 ++++ lib/puppet/resource/catalog.rb | 3 +++ spec/unit/parser/compiler.rb | 9 +++++++++ spec/unit/resource/catalog.rb | 12 ++++++++++++ 4 files changed, 28 insertions(+), 0 deletions(-) diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 2eb9438..521bf1c 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -422,6 +422,10 @@ class Puppet::Parser::Compiler node.parameters.each do |param, value| @topscope.setvar(param, value) end + + # These might be nil. + catalog.client_version = node.parameters["clientversion"] + catalog.server_version = node.parameters["serverversion"] end # Return an array of all of the unevaluated resources. These will be definitions, diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 6ccfe73..561be82 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -46,6 +46,9 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # whether it is written back out again. attr_accessor :from_cache + # Some metadata to help us compile and generally respond to the current state. + attr_accessor :client_version, :server_version + # Add classes to our class list. def add_class(*classes) classes.each do |klass| diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb index ad6f351..41f03f2 100755 --- a/spec/unit/parser/compiler.rb +++ b/spec/unit/parser/compiler.rb @@ -131,6 +131,15 @@ describe Puppet::Parser::Compiler do @compiler.topscope.lookupvar("c").should == "d" end + it "should set the client and server versions on the catalog" do + params = {"clientversion" => "2", "serverversion" => "3"} + @node.stubs(:parameters).returns(params) + compile_stub(:set_node_parameters) + @compiler.compile + @compiler.catalog.client_version.should == "2" + @compiler.catalog.server_version.should == "3" + end + it "should evaluate any existing classes named in the node" do classes = %w{one two three four} main = stub 'main' diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb index af399aa..1fbe3a9 100755 --- a/spec/unit/resource/catalog.rb +++ b/spec/unit/resource/catalog.rb @@ -35,6 +35,18 @@ describe Puppet::Resource::Catalog, "when compiling" do @catalog.write_class_file end + it "should have a client_version attribute" do + @catalog = Puppet::Resource::Catalog.new("host") + @catalog.client_version = 5 + @catalog.client_version.should == 5 + end + + it "should have a server_version attribute" do + @catalog = Puppet::Resource::Catalog.new("host") + @catalog.server_version = 5 + @catalog.server_version.should == 5 + end + describe "when compiling" do it "should accept tags" do config = Puppet::Resource::Catalog.new("mynode") -- 1.6.1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
