Skip to content

Fix instances method with simple_get_filter #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet/resource_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def self.instances
provider(type_definition.name)

initial_fetch = if type_definition.feature?('simple_get_filter')
my_provider.get(context, [])
my_provider.get(context, nil)
else
my_provider.get(context)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/composite_namevar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
it 'is returns the values correctly' do
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar")
expect(stdout_str.strip).to match %r{^composite_namevar}
expect(stdout_str.strip).to match %r{Looking for \[\]}
expect(stdout_str.strip).to match %r{Looking for nil}
expect(status).to eq 0
end
it 'returns the required resource correctly' do
Expand All @@ -20,7 +20,7 @@
expect(stdout_str.strip).to match %r{ensure\s*=> \'present\'}
expect(stdout_str.strip).to match %r{package\s*=> \'php\'}
expect(stdout_str.strip).to match %r{manager\s*=> \'yum\'}
expect(stdout_str.strip).to match %r{Looking for \[\]}
expect(stdout_str.strip).to match %r{Looking for nil}
expect(status.exitstatus).to eq 0
end
it 'throws error if title is not a matching title_pattern' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# Implementation for the test_simple_get_filter type using the Resource API.
class Puppet::Provider::TestSimpleGetFilter::TestSimpleGetFilter < Puppet::ResourceApi::SimpleProvider
def get(_context, names = nil)
raise Puppet::DevError, 'names parameter must be provided to TestSimpleGetFilter#get()' if names.nil?

result = if names.empty?
result = if names.nil?
# rather than fething everything from your large dataset, return a subset of the data that you are happy to show.
# This will be cached by Puppet. If a resource requested exists in the cache, then no futher calls are made to the provider.
[{
Expand Down
2 changes: 1 addition & 1 deletion spec/puppet/resource_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ def set(_context, changes) end
end

it 'passes through the an empty array to `get`' do
expect(provider).to receive(:get).with(anything, []).and_return([])
expect(provider).to receive(:get).with(anything, nil).and_return([])
type.instances
end

Expand Down