Skip to content

Commit

Permalink
Merge pull request #61 from michaeltlombardi/gh-74/main/remove-ensure
Browse files Browse the repository at this point in the history
(GH-74) Remove special handling for ensure in the dsc base provider
  • Loading branch information
pmcmaw authored Nov 24, 2020
2 parents fd51a41 + f0f2426 commit 909652f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
16 changes: 2 additions & 14 deletions lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,9 @@ def invoke_get_method(context, name_hash)
data[type_key] = query_props[type_key].empty? ? query_props[type_key] : []
end
end
# If a resource is found, it's present, so refill these two Puppet-only keys
# If a resource is found, it's present, so refill this Puppet-only key
data.merge!({ name: name_hash[:name] })
if ensurable?(context)
ensure_value = data.key?(:dsc_ensure) ? data[:dsc_ensure].downcase : 'present'
data.merge!({ ensure: ensure_value })
end

# TODO: Handle PSDscRunAsCredential flapping
# Resources do not return the account under which they were discovered, so re-add that
if name_hash[:dsc_psdscrunascredential].nil?
Expand Down Expand Up @@ -339,7 +336,6 @@ def should_to_resource(should, context, dsc_invoke_method)
resource[k] = context.type.definition[k]
end
should.each do |k, v|
next if k == :ensure
# PSDscRunAsCredential is considered a namevar and will always be passed, even if nil
# To prevent flapping during runs, remove it from the resource definition unless specified
next if k == :dsc_psdscrunascredential && v.nil?
Expand Down Expand Up @@ -437,14 +433,6 @@ def recursively_downcase(object)
end
end

# Checks to see whether the DSC resource being managed is defined as ensurable
#
# @param context [Object] the Puppet runtime context to operate in and send feedback to
# @return [Bool] returns true if the DSC Resource is ensurable, otherwise false.
def ensurable?(context)
context.type.attributes.keys.include?(:ensure)
end

# Parses the DSC resource type definition to retrieve the names of any attributes which are specified as mandatory for get operations
#
# @param context [Object] the Puppet runtime context to operate in and send feedback to
Expand Down
1 change: 1 addition & 0 deletions lib/pwsh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
module Pwsh
# Standard errors
class Error < StandardError; end

# Create an instance of a PowerShell host and manage execution of PowerShell code inside that host.
class Manager
attr_reader :powershell_command, :powershell_arguments
Expand Down

0 comments on commit 909652f

Please sign in to comment.