Fixing #1408 - --loadclasses works again.

The problem was that the mechanism I was using for
passing the node to the compiler was conflicting with
the Indirector::Request's method of handling node
authentication.

Signed-off-by: Luke Kanies <luke@madstop.com>
This commit is contained in:
Luke Kanies 2008-07-09 17:41:21 -07:00 коммит произвёл James Turnbull
Родитель 605d760dd7
Коммит 80436550a1
4 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -207,7 +207,7 @@ end
begin
# Compile our catalog
catalog = Puppet::Node::Catalog.find(node.name, :node => node)
catalog = Puppet::Node::Catalog.find(node.name, :use_node => node)
# Translate it to a RAL catalog
catalog = catalog.to_ral

Просмотреть файл

@ -14,7 +14,7 @@ class Puppet::Node::Catalog::Compiler < Puppet::Indirector::Code
# Compile a node's catalog.
def find(request)
unless node = request.options[:node] || find_node(request.key)
unless node = request.options[:use_node] || find_node(request.key)
raise ArgumentError, "Could not find node '%s'; cannot compile" % request.key
end

Просмотреть файл

@ -40,5 +40,15 @@ describe Puppet::Node::Catalog do
Puppet::Node::Catalog.find("me").should be_nil
end
it "should pass provided node information directly to the terminus" do
terminus = mock 'terminus'
Puppet::Node::Catalog.indirection.stubs(:terminus).returns terminus
node = mock 'node'
terminus.expects(:find).with { |request| request.options[:use_node] == node }
Puppet::Node::Catalog.find("me", :use_node => node)
end
end
end

Просмотреть файл

@ -114,13 +114,12 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do
@node = Puppet::Node.new @name
@node.stubs(:merge)
@request = stub 'request', :key => @name, :options => {}
Puppet::Node.stubs(:find).with(@name).returns(@node)
end
it "should directly use provided nodes" do
Puppet::Node.expects(:find).never
@compiler.interpreter.expects(:compile).with(@node)
@request.stubs(:options).returns(:node => @node)
@compiler.expects(:compile).with(@node)
@request.stubs(:options).returns(:use_node => @node)
@compiler.find(@request)
end
@ -130,12 +129,14 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do
end
it "should pass the found node to the interpreter for compiling" do
Puppet::Node.expects(:find).with(@name).returns(@node)
config = mock 'config'
@compiler.interpreter.expects(:compile).with(@node)
@compiler.find(@request)
end
it "should return the results of compiling as the catalog" do
Puppet::Node.stubs(:find).returns(@node)
config = mock 'config'
result = mock 'result'
@ -144,6 +145,7 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do
end
it "should benchmark the compile process" do
Puppet::Node.stubs(:find).returns(@node)
@compiler.stubs(:networked?).returns(true)
@compiler.expects(:benchmark).with do |level, message|
level == :notice and message =~ /^Compiled catalog/