Skip to content

Commit

Permalink
Merge pull request #843 from kelseyhightower/ticket/3.0rc/14900_data_…
Browse files Browse the repository at this point in the history
…bindings_does_not_support_hiera_puppet_backend

Ticket/3.0rc/14900 data bindings does not support hiera puppet backend
  • Loading branch information
zaphod42 committed Jun 11, 2012
2 parents e89aa3e + c770c22 commit 82bef19
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 1 addition & 2 deletions lib/puppet/indirector/hiera.rb
Expand Up @@ -9,8 +9,7 @@ def initialize(*args)
end

def find(request)
facts = Puppet::Node::Facts.indirection.find(request.options[:host]).values
hiera.lookup(request.key, nil, facts, nil, nil)
hiera.lookup(request.key, nil, request.options[:scope], nil, nil)
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/resource.rb
Expand Up @@ -317,7 +317,7 @@ def set_default_parameters(scope)
if resource_type.type == :hostclass
namespaced_param = "#{resource_type.name}::#{param}"
external_value = Puppet::DataBinding.indirection.find(
namespaced_param, :host => scope.host)
namespaced_param, :scope => scope)
end

if external_value.nil?
Expand Down
4 changes: 0 additions & 4 deletions spec/unit/indirector/hiera_spec.rb
Expand Up @@ -119,10 +119,6 @@ module Testing; end
end

describe "the behavior of the find method", :if => Puppet.features.hiera? do
before do
Puppet::Node::Facts.indirection.expects(:find).with('foo').
returns(facter_obj)
end

let(:data_binder) { @hiera_class.new }

Expand Down
10 changes: 5 additions & 5 deletions spec/unit/resource_spec.rb
Expand Up @@ -322,26 +322,26 @@

it "should query the data_binding terminus using a namespaced key" do
Puppet::DataBinding.indirection.expects(:find).with(
'apache::port', :host => 'foo')
'apache::port', :scope => @scope)
resource.set_default_parameters(@scope)
end

it "should query the data_binding terminus using the host attribute from the scope" do
it "should query the data_binding terminus using the scope object" do
Puppet::DataBinding.indirection.expects(:find).with(
'apache::port', :host => 'foo')
'apache::port', :scope => @scope)
resource.set_default_parameters(@scope)
end

it "should use the value from the data_binding terminus" do
Puppet::DataBinding.indirection.expects(:find).with(
'apache::port', :host => 'foo').returns('443')
'apache::port', :scope => @scope).returns('443')
resource.set_default_parameters(@scope).should == [:port]
resource[:port].should == '443'
end

it "should use the default value if the data_binding terminus returns nil" do
Puppet::DataBinding.indirection.expects(:find).with(
'apache::port', :host => 'foo').returns(nil)
'apache::port', :scope => @scope).returns(nil)
resource.set_default_parameters(@scope).should == [:port]
resource[:port].should == '80'
end
Expand Down

0 comments on commit 82bef19

Please sign in to comment.