Skip to content
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file.The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [0.6.0](https://github.com/puppetlabs/ruby-pwsh/tree/0.6.0) (2020-11-24)

[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.5.1...0.6.0)

### Added

- \(GH-81\) Handle parameters in the dsc base provider [\#62](https://github.com/puppetlabs/ruby-pwsh/pull/62) ([michaeltlombardi](https://github.com/michaeltlombardi))
- \(GH-74\) Remove special handling for ensure in the dsc base provider [\#61](https://github.com/puppetlabs/ruby-pwsh/pull/61) ([michaeltlombardi](https://github.com/michaeltlombardi))
- \(GH-59\) Refactor away from Simple Provider [\#60](https://github.com/puppetlabs/ruby-pwsh/pull/60) ([michaeltlombardi](https://github.com/michaeltlombardi))

### Fixed

- \(GH-57\) Handle datetimes in dsc [\#58](https://github.com/puppetlabs/ruby-pwsh/pull/58) ([michaeltlombardi](https://github.com/michaeltlombardi))
- \(GH-55\) Handle intentionally empty arrays [\#56](https://github.com/puppetlabs/ruby-pwsh/pull/56) ([michaeltlombardi](https://github.com/michaeltlombardi))

## [0.5.1](https://github.com/puppetlabs/ruby-pwsh/tree/0.5.1) (2020-09-25)

[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.5.0...0.5.1)
Expand Down
11 changes: 10 additions & 1 deletion lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def set(context, changes)
end

# for compatibility sake, we use dsc_ensure instead of ensure, so context.type.ensurable? does not work
if !context.type.attributes.key?(:dsc_ensure)
if context.type.attributes.key?(:dsc_ensure)
is = create_absent(:name, name) if is.nil?
should = create_absent(:name, name) if should.nil?

Expand Down Expand Up @@ -280,6 +280,15 @@ def invoke_get_method(context, name_hash)
# If a resource is found, it's present, so refill this Puppet-only key
data.merge!({ name: name_hash[:name] })

# Have to check for this to avoid a weird canonicalization warning
# The Resource API calls canonicalize against the current state which
# will lead to dsc_ensure being set to absent in the name_hash even if
# it was set to present in the manifest
name_hash_has_nil_keys = name_hash.select { |_k, v| v.nil? }.count.positive?
# We want to throw away all of the empty keys if and only if the manifest
# declaration is for an absent resource and the resource is actually absent
data.reject! { |_k, v| v.nil? } if data[:dsc_ensure] == 'Absent' && name_hash[:dsc_ensure] == 'Absent' && !name_hash_has_nil_keys

# Cache the query to prevent a second lookup
@@cached_query_results << data.dup if fetch_cached_hashes(@@cached_query_results, [data]).empty?
context.debug("Returned to Puppet as #{data}")
Expand Down
2 changes: 1 addition & 1 deletion lib/pwsh/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module Pwsh
# The version of the ruby-pwsh gem
VERSION = '0.5.1'
VERSION = '0.6.0'
end
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-pwshlib",
"version": "0.5.1",
"version": "0.6.0",
"author": "puppetlabs",
"summary": "Provide library code for interoperating with PowerShell.",
"license": "MIT",
Expand Down