Skip to content

Commit

Permalink
Merge pull request #24 from DavidS/fix-simpleprovider-lookup
Browse files Browse the repository at this point in the history
SimpleProvider: fix `is`-lookup and docs
  • Loading branch information
DavidS authored Feb 21, 2018
2 parents b069db2 + b5ffe28 commit 3a1aeb0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/puppet/resource_api/simple_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module Puppet::ResourceApi
# This class provides a default implementation for set(), when your resource does not benefit from batching.
# Instead of processing changes yourself, the `create`, `update`, and `delete` functions, are called for you,
# with proper logging already set up.
# Note that your type needs to use `ensure` in the conventional way to signal presence and absence of resources.
# Note that your type needs to use `name` as its namevar, and `ensure` in the conventional way to signal presence
# and absence of resources.
class SimpleProvider
def set(context, changes)
changes.each do |name, change|
is = change.key?(:is) ? change[:is] : (get(context) || []).find { |key| key[:id] == name }
is = change.key?(:is) ? change[:is] : (get(context) || []).find { |r| r[:name] == name }
should = change[:should]

is = { name: name, ensure: 'absent' } if is.nil?
Expand Down

0 comments on commit 3a1aeb0

Please sign in to comment.