From afba9158eeb78654355879ef2df83f4bb1e90372 Mon Sep 17 00:00:00 2001 From: Michael T Lombardi Date: Mon, 23 Nov 2020 20:39:53 -0600 Subject: [PATCH 1/2] (GH-74) Remove ensure from dsc base provider This commit removes the special handling for the ensure keyword from the dsc base provider to facillitate the collapse of the ensure and dsc_ensure keywords. - Relates to puppetlabs/Puppet.Dsc#74 --- .../dsc_base_provider/dsc_base_provider.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb b/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb index 29808d49..b2081bbb 100644 --- a/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb +++ b/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb @@ -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? @@ -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? @@ -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 From f0f242620e2b92aeb5b28fa67be55ad5d00042bc Mon Sep 17 00:00:00 2001 From: Michael T Lombardi Date: Mon, 23 Nov 2020 23:18:20 -0600 Subject: [PATCH 2/2] (MAINT) Fix rubocop violation --- lib/pwsh.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pwsh.rb b/lib/pwsh.rb index 21112502..7ca7ce03 100644 --- a/lib/pwsh.rb +++ b/lib/pwsh.rb @@ -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