ruby-pwsh 0.6.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb +48 -13
- data/lib/pwsh/version.rb +1 -1
- data/metadata.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1fe9e2ecf92d6aee9019d08c83f4f7305b01bc71b83f9e9e5257731ff9896ae
|
4
|
+
data.tar.gz: b74e7adfde169c6e680ade91be04a587d67bf2345ded1f1ce0cd0a6b72984122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519329615ad73d4f7f07a96ea89dc9e1716aee185481e8644ae8d8f1f688fb91acf70ac53b0fe1f38533b5bf1e475e3f9f3cf6feb79a222af9c7dc5ca19af2a9
|
7
|
+
data.tar.gz: dbbbac000ca3ee3fd3f27e86592e76a9ae676e82aadc07fda35281774d835621f33880d435ae6abb70bf4e6c79f03c6396f88416c413c95a5dc77419dbdde037
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,54 @@
|
|
2
2
|
|
3
3
|
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).
|
4
4
|
|
5
|
+
## [0.7.3](https://github.com/puppetlabs/ruby-pwsh/tree/0.7.3) (2021-02-03)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.7.2...0.7.3)
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- \(MAINT\) Place nil check when assigning is\_same [\#101](https://github.com/puppetlabs/ruby-pwsh/pull/101) ([bwilcox](https://github.com/bwilcox))
|
12
|
+
|
13
|
+
## [0.7.2](https://github.com/puppetlabs/ruby-pwsh/tree/0.7.2) (2021-02-03)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.7.1...0.7.2)
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- \(GH-97\) Memoize class variables in initialize [\#98](https://github.com/puppetlabs/ruby-pwsh/pull/98) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
20
|
+
- \(MAINT\) Ensure is\_same check works for nil manifest values [\#96](https://github.com/puppetlabs/ruby-pwsh/pull/96) ([bwilcox](https://github.com/bwilcox))
|
21
|
+
|
22
|
+
## [0.7.1](https://github.com/puppetlabs/ruby-pwsh/tree/0.7.1) (2021-02-02)
|
23
|
+
|
24
|
+
[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.7.0...0.7.1)
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
|
28
|
+
- \(MAINT\) Correctly canonicalize enumerable values in dsc [\#92](https://github.com/puppetlabs/ruby-pwsh/pull/92) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
29
|
+
- \(MAINT\) Ensure vendored path check works with mix of module builds [\#91](https://github.com/puppetlabs/ruby-pwsh/pull/91) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
30
|
+
- \(GH-84\) Fix empty array parameter check [\#90](https://github.com/puppetlabs/ruby-pwsh/pull/90) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
31
|
+
- \(MAINT\) Minor fixes to CIM instance handling [\#89](https://github.com/puppetlabs/ruby-pwsh/pull/89) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
32
|
+
|
33
|
+
## [0.7.0](https://github.com/puppetlabs/ruby-pwsh/tree/0.7.0) (2021-01-20)
|
34
|
+
|
35
|
+
[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.6.3...0.7.0)
|
36
|
+
|
37
|
+
### Added
|
38
|
+
|
39
|
+
- \(GH-75\) Including module name in vendored module path [\#85](https://github.com/puppetlabs/ruby-pwsh/pull/85) ([pmcmaw](https://github.com/pmcmaw))
|
40
|
+
|
41
|
+
### Fixed
|
42
|
+
|
43
|
+
- Make root module path use puppetized module name [\#86](https://github.com/puppetlabs/ruby-pwsh/pull/86) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
44
|
+
|
45
|
+
## [0.6.3](https://github.com/puppetlabs/ruby-pwsh/tree/0.6.3) (2020-12-16)
|
46
|
+
|
47
|
+
[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.6.2...0.6.3)
|
48
|
+
|
49
|
+
### Fixed
|
50
|
+
|
51
|
+
- \(MAINT\) Add handling for when dsc\_ensure is stripped [\#78](https://github.com/puppetlabs/ruby-pwsh/pull/78) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
52
|
+
|
5
53
|
## [0.6.2](https://github.com/puppetlabs/ruby-pwsh/tree/0.6.2) (2020-12-09)
|
6
54
|
|
7
55
|
[Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.6.1...0.6.2)
|
@@ -11,9 +11,9 @@ class Puppet::Provider::DscBaseProvider
|
|
11
11
|
# - query results
|
12
12
|
# - logon failures
|
13
13
|
def initialize
|
14
|
-
@@cached_canonicalized_resource
|
15
|
-
@@cached_query_results
|
16
|
-
@@logon_failures
|
14
|
+
@@cached_canonicalized_resource ||= []
|
15
|
+
@@cached_query_results ||= []
|
16
|
+
@@logon_failures ||= []
|
17
17
|
super
|
18
18
|
end
|
19
19
|
|
@@ -61,7 +61,8 @@ class Puppet::Provider::DscBaseProvider
|
|
61
61
|
downcased_result = recursively_downcase(canonicalized)
|
62
62
|
downcased_resource = recursively_downcase(r)
|
63
63
|
downcased_result.each do |key, value|
|
64
|
-
|
64
|
+
is_same = value.is_a?(Enumerable) & !downcased_resource[key].nil? ? downcased_resource[key].sort == value.sort : downcased_resource[key] == value
|
65
|
+
canonicalized[key] = r[key] unless is_same
|
65
66
|
canonicalized.delete(key) unless downcased_resource.keys.include?(key)
|
66
67
|
end
|
67
68
|
# Cache the actually canonicalized resource separately
|
@@ -143,7 +144,8 @@ class Puppet::Provider::DscBaseProvider
|
|
143
144
|
# HACK: If the DSC Resource is ensurable but doesn't report a default value
|
144
145
|
# for ensure, we assume it to be `Present` - this is the most common pattern.
|
145
146
|
should_ensure = should[:dsc_ensure].nil? ? 'Present' : should[:dsc_ensure].to_s
|
146
|
-
|
147
|
+
# HACK: Sometimes dsc_ensure is removed???? If it's gone, pretend it's absent??
|
148
|
+
is_ensure = is[:dsc_ensure].nil? ? 'Absent' : is[:dsc_ensure].to_s
|
147
149
|
|
148
150
|
if is_ensure == 'Absent' && should_ensure == 'Present'
|
149
151
|
context.creating(name) do
|
@@ -357,17 +359,49 @@ class Puppet::Provider::DscBaseProvider
|
|
357
359
|
# Because Puppet adds all of the modules to the LOAD_PATH we can be sure that the appropriate module lives here during an apply;
|
358
360
|
# PROBLEM: This currently uses the downcased name, we need to capture the module name in the metadata I think.
|
359
361
|
# During a Puppet agent run, the code lives in the cache so we can use the file expansion to discover the correct folder.
|
360
|
-
|
362
|
+
# This handles setting the vendored_modules_path to include the puppet module name; we now add the puppet module name into the
|
363
|
+
# path to allow multiple modules to with shared dsc_resources to be installed side by side
|
364
|
+
# The old vendored_modules_path: puppet_x/dsc_resources
|
365
|
+
# The new vendored_modules_path: puppet_x/<module_name>/dsc_resources
|
366
|
+
root_module_path = $LOAD_PATH.select { |path| path.match?(%r{#{puppetize_name(resource[:dscmeta_module_name])}/lib}) }.first
|
361
367
|
resource[:vendored_modules_path] = if root_module_path.nil?
|
362
|
-
File.expand_path(Pathname.new(__FILE__).dirname + '../../../' +
|
368
|
+
File.expand_path(Pathname.new(__FILE__).dirname + '../../../' + "puppet_x/#{puppetize_name(resource[:dscmeta_module_name])}/dsc_resources") # rubocop:disable Style/StringConcatenation
|
363
369
|
else
|
364
|
-
File.expand_path("#{root_module_path}/puppet_x/dsc_resources")
|
370
|
+
File.expand_path("#{root_module_path}/puppet_x/#{puppetize_name(resource[:dscmeta_module_name])}/dsc_resources")
|
365
371
|
end
|
372
|
+
|
373
|
+
# Check for the old vendored_modules_path second - if there is a mix of modules with the old and new pathing,
|
374
|
+
# checking for this first will always work and so the more specific search will never run.
|
375
|
+
unless File.exist? resource[:vendored_modules_path]
|
376
|
+
resource[:vendored_modules_path] = if root_module_path.nil?
|
377
|
+
File.expand_path(Pathname.new(__FILE__).dirname + '../../../' + 'puppet_x/dsc_resources') # rubocop:disable Style/StringConcatenation
|
378
|
+
else
|
379
|
+
File.expand_path("#{root_module_path}/puppet_x/dsc_resources")
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
# A warning is thrown if the something went wrong and the file was not created
|
384
|
+
raise "Unable to find expected vendored DSC Resource #{resource[:vendored_modules_path]}" unless File.exist? resource[:vendored_modules_path]
|
385
|
+
|
366
386
|
resource[:attributes] = nil
|
387
|
+
|
367
388
|
context.debug("should_to_resource: #{resource.inspect}")
|
368
389
|
resource
|
369
390
|
end
|
370
391
|
|
392
|
+
# Return a String containing a puppetized name. A puppetized name is a string that only
|
393
|
+
# includes lowercase letters, digits, underscores and cannot start with a digit.
|
394
|
+
#
|
395
|
+
# @return [String] with a puppeized module name
|
396
|
+
def puppetize_name(name)
|
397
|
+
# Puppet module names must be lower case
|
398
|
+
name = name.downcase
|
399
|
+
# Puppet module names must only include lowercase letters, digits and underscores
|
400
|
+
name = name.gsub(/[^a-z0-9_]/, '_')
|
401
|
+
# Puppet module names must not start with a number so if it does, append the letter 'a' to the name. Eg: '7zip' becomes 'a7zip'
|
402
|
+
name = name.match?(/^\d/) ? "a#{name}" : name # rubocop:disable Lint/UselessAssignment
|
403
|
+
end
|
404
|
+
|
371
405
|
# Return a UUID with the dashes turned into underscores to enable the specifying of guaranteed-unique
|
372
406
|
# variables in the PowerShell script.
|
373
407
|
#
|
@@ -504,8 +538,8 @@ class Puppet::Provider::DscBaseProvider
|
|
504
538
|
'user' => property_hash[:value]['user'],
|
505
539
|
'password' => escape_quotes(property_hash[:value]['password'].unwrap)
|
506
540
|
}
|
507
|
-
instantiated_variables.merge!(variable_name => credential_hash)
|
508
541
|
credentials_block << format_pscredential(variable_name, credential_hash)
|
542
|
+
instantiated_variables.merge!(variable_name => credential_hash)
|
509
543
|
end
|
510
544
|
credentials_block.join("\n")
|
511
545
|
credentials_block == [] ? '' : credentials_block
|
@@ -532,6 +566,7 @@ class Puppet::Provider::DscBaseProvider
|
|
532
566
|
cim_instances_block = []
|
533
567
|
resource[:parameters].each do |_property_name, property_hash|
|
534
568
|
next unless property_hash[:mof_is_embedded]
|
569
|
+
next if property_hash[:mof_type] == 'PSCredential' # Credentials are handled separately
|
535
570
|
|
536
571
|
# strip dsc_ from the beginning of the property name declaration
|
537
572
|
# name = property_name.to_s.gsub(/^dsc_/, '').to_sym
|
@@ -542,10 +577,10 @@ class Puppet::Provider::DscBaseProvider
|
|
542
577
|
unless cim_instance_hashes.count.zero?
|
543
578
|
cim_instance_hashes.each do |instance|
|
544
579
|
variable_name = random_variable_name
|
545
|
-
instantiated_variables.merge!(variable_name => instance)
|
546
580
|
class_name = instance['cim_instance_type']
|
547
581
|
properties = instance.reject { |k, _v| k == 'cim_instance_type' }
|
548
582
|
cim_instances_block << format_ciminstance(variable_name, class_name, properties)
|
583
|
+
instantiated_variables.merge!(variable_name => instance)
|
549
584
|
end
|
550
585
|
end
|
551
586
|
# We have to handle arrays of CIM instances slightly differently
|
@@ -553,14 +588,14 @@ class Puppet::Provider::DscBaseProvider
|
|
553
588
|
class_name = property_hash[:mof_type].gsub('[]', '')
|
554
589
|
property_hash[:value].each do |hash|
|
555
590
|
variable_name = random_variable_name
|
556
|
-
instantiated_variables.merge!(variable_name => hash)
|
557
591
|
cim_instances_block << format_ciminstance(variable_name, class_name, hash)
|
592
|
+
instantiated_variables.merge!(variable_name => hash)
|
558
593
|
end
|
559
594
|
else
|
560
595
|
variable_name = random_variable_name
|
561
|
-
instantiated_variables.merge!(variable_name => property_hash[:value])
|
562
596
|
class_name = property_hash[:mof_type]
|
563
597
|
cim_instances_block << format_ciminstance(variable_name, class_name, property_hash[:value])
|
598
|
+
instantiated_variables.merge!(variable_name => property_hash[:value])
|
564
599
|
end
|
565
600
|
end
|
566
601
|
cim_instances_block == [] ? '' : cim_instances_block.join("\n")
|
@@ -643,7 +678,7 @@ class Puppet::Provider::DscBaseProvider
|
|
643
678
|
params_block = params_block.gsub("'[DateTime]", "[DateTime]'")
|
644
679
|
# HACK: Handle intentionally empty arrays - need to strongly type them because
|
645
680
|
# CIM instances do not do a consistent job of casting an empty array properly.
|
646
|
-
empty_array_parameters = resource[:parameters].select { |_k, v| v[:value].empty? }
|
681
|
+
empty_array_parameters = resource[:parameters].select { |_k, v| v[:value].is_a?(Array) && v[:value].empty? }
|
647
682
|
empty_array_parameters.each do |name, properties|
|
648
683
|
param_block_name = name.to_s.gsub(/^dsc_/, '')
|
649
684
|
params_block = params_block.gsub("#{param_block_name} = @()", "#{param_block_name} = [#{properties[:mof_type]}]@()")
|
data/lib/pwsh/version.rb
CHANGED
data/metadata.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-pwsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: PowerShell code manager for ruby.
|
14
14
|
email:
|