Skip to content

Commit f3712da

Browse files
authored
Merge pull request #5047 from joshcooper/ticket/master/PUP-3182-catalog-download
(PUP-3182) Call Indirection#save with the correct arguments
2 parents cdf9df8 + 8ab50eb commit f3712da

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

lib/puppet/face/catalog.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123

124124
Puppet::Resource::Catalog.indirection.terminus_class = :yaml
125125
Puppet::Face[:catalog, "0.0.1"].save(catalog)
126-
Puppet.notice "Saved catalog for #{Puppet[:certname]} to yaml"
126+
Puppet.notice "Saved catalog for #{Puppet[:certname]} to #{Puppet::Resource::Catalog.indirection.terminus.path(Puppet[:certname])}"
127127
nil
128128
end
129129
end

lib/puppet/indirector/face.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ def self.terminus_classes(indirection)
3939

4040
def call_indirection_method(method, key, options)
4141
begin
42-
result = indirection.__send__(method, key, options)
42+
if method == :save
43+
# key is really the instance to save
44+
result = indirection.__send__(method, key, nil, options)
45+
else
46+
result = indirection.__send__(method, key, options)
47+
end
4348
rescue => detail
4449
message = "Could not call '#{method}' on '#{indirection_name}': #{detail}"
4550
Puppet.log_exception(detail, message)

spec/unit/indirector/face_spec.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,24 @@
4040
end
4141

4242
[:find, :search, :save, :destroy].each do |method|
43+
def params(method, options)
44+
if method == :save
45+
[nil, options]
46+
else
47+
[options]
48+
end
49+
end
50+
4351
it "should define a '#{method}' action" do
4452
expect(Puppet::Indirector::Face).to be_action(method)
4553
end
4654

4755
it "should call the indirection method with options when the '#{method}' action is invoked" do
48-
subject.indirection.expects(method).with(:test, {})
56+
subject.indirection.expects(method).with(:test, *params(method, {}))
4957
subject.send(method, :test)
5058
end
5159
it "should forward passed options" do
52-
subject.indirection.expects(method).with(:test, {'one'=>'1'})
60+
subject.indirection.expects(method).with(:test, *params(method, {'one'=>'1'}))
5361
subject.send(method, :test, :extra => {'one'=>'1'})
5462
end
5563
end

0 commit comments

Comments
 (0)