ruby-pwsh 0.11.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5fc05fdc86cf9f85687a67df245cacc1e5d6a15a69c2edfa00c357d66ecc13
|
4
|
+
data.tar.gz: d9c78f4421482617d5c8388245603fa024bf22cfbd3024d894b047b1ebfc330f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b8b0a2ce494bb3344e84d3db3c657054c4ecbc46d998f9b605b3d7a1bbf886adb03624134bce5eb6b50ece05c486f3e6aab4b74c5cc876b3b3c23dd5242eb0b
|
7
|
+
data.tar.gz: 211ccd9d067fdfb5a3aa0ea618edc6fcba49883344791a6a0688c5292b3eb8a8a3e666432471e0255bfa89fc213535474f3fd1de15f1d5c3369c12dd9df7cf9f
|
data/README.md
CHANGED
@@ -70,58 +70,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
70
70
|
|
71
71
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). -->
|
72
72
|
|
73
|
-
## Releasing the Gem and Puppet Module
|
74
|
-
|
75
|
-
Steps to release an update to the gem and module include:
|
76
|
-
|
77
|
-
1. From main, checkout a new working branch for the release prep (where xyz is the appropriate version, sans periods):
|
78
|
-
```bash
|
79
|
-
git checkout -b maint-release_prep_xyz
|
80
|
-
```
|
81
|
-
|
82
|
-
2. Update the version in `lib/pwsh/version.rb` and `metadata.json` to the appropriate version for the new release.
|
83
|
-
|
84
|
-
3. Run the changelog update task (make sure to verify the changelog, correctly tagging PRs as needed):
|
85
|
-
```bash
|
86
|
-
bundle exec rake changelog
|
87
|
-
```
|
88
|
-
|
89
|
-
4. Commit your changes with a short, sensible commit message, like:
|
90
|
-
```bash
|
91
|
-
git add lib/pwsh/version.rb
|
92
|
-
git add metadata.json
|
93
|
-
git add CHANGELOG.md
|
94
|
-
git commit -m '(MAINT) Prep for x.y.z release'
|
95
|
-
```
|
96
|
-
|
97
|
-
5. Push your changes and submit a pull request for review _against main:
|
98
|
-
```bash
|
99
|
-
git push -u origin maint_release_prep_xyz
|
100
|
-
```
|
101
|
-
|
102
|
-
6. Ensure tests pass and the code is merged to `main`.
|
103
|
-
|
104
|
-
7. Once the release_prep PR has been merged, checkout main and pull down the latests changes.
|
105
|
-
```bash
|
106
|
-
git checkout main
|
107
|
-
git pull
|
108
|
-
```
|
109
|
-
|
110
|
-
8. Assuming that the release_prep merge commit is at the HEAD of main we can simply create and push a tag as follows (replacing xyz with the appropriate version).
|
111
|
-
```bash
|
112
|
-
git tag -a xyx -m "Release xyz"
|
113
|
-
git push --follow-tags
|
114
|
-
```
|
115
|
-
|
116
|
-
9. Execute the publish workflow. This will:
|
117
|
-
- Create a GitHub release
|
118
|
-
- Build and publish the Gem
|
119
|
-
- Build and publish the Puppet module
|
120
|
-
|
121
|
-
10. Finally check that the expected versions are present on rubygems.org and the Forge.
|
122
|
-
|
123
|
-
## Known Issues
|
124
|
-
|
125
73
|
## Supported Operating Systems
|
126
74
|
|
127
75
|
The following platforms are supported:
|
@@ -6,27 +6,25 @@ require 'pathname'
|
|
6
6
|
require 'json'
|
7
7
|
|
8
8
|
class Puppet::Provider::DscBaseProvider
|
9
|
-
# Initializes the provider, preparing the
|
9
|
+
# Initializes the provider, preparing the instance variables which cache:
|
10
10
|
# - the canonicalized resources across calls
|
11
11
|
# - query results
|
12
12
|
# - logon failures
|
13
13
|
def initialize
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
@cached_canonicalized_resource = []
|
15
|
+
@cached_query_results = []
|
16
|
+
@cached_test_results = []
|
17
|
+
@logon_failures = []
|
18
18
|
super
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
@@cached_test_results
|
23
|
-
end
|
21
|
+
attr_reader :cached_test_results
|
24
22
|
|
25
23
|
# Look through a cache to retrieve the hashes specified, if they have been cached.
|
26
24
|
# Does so by seeing if each of the specified hashes is a subset of any of the hashes
|
27
25
|
# in the cache, so {foo: 1, bar: 2} would return if {foo: 1} was the search hash.
|
28
26
|
#
|
29
|
-
# @param cache [Array] the
|
27
|
+
# @param cache [Array] the instance variable containing cached hashes to search through
|
30
28
|
# @param hashes [Array] the list of hashes to search the cache for
|
31
29
|
# @return [Array] an array containing the matching hashes for the search condition, if any
|
32
30
|
def fetch_cached_hashes(cache, hashes)
|
@@ -52,14 +50,14 @@ class Puppet::Provider::DscBaseProvider
|
|
52
50
|
# During RSAPI refresh runs mandatory parameters are stripped and not available;
|
53
51
|
# Instead of checking again and failing, search the cache for a namevar match.
|
54
52
|
namevarized_r = r.select { |k, _v| namevar_attributes(context).include?(k) }
|
55
|
-
cached_result = fetch_cached_hashes(
|
53
|
+
cached_result = fetch_cached_hashes(@cached_canonicalized_resource, [namevarized_r]).first
|
56
54
|
if cached_result.nil?
|
57
55
|
# If the resource is meant to be absent, skip canonicalization and rely on the manifest
|
58
56
|
# value; there's no reason to compare system state to desired state for casing if the
|
59
57
|
# resource is being removed.
|
60
58
|
if r[:dsc_ensure] == 'absent'
|
61
59
|
canonicalized = r.dup
|
62
|
-
|
60
|
+
@cached_canonicalized_resource << r.dup
|
63
61
|
else
|
64
62
|
canonicalized = invoke_get_method(context, r)
|
65
63
|
# If the resource could not be found or was returned as absent, skip case munging and
|
@@ -67,7 +65,7 @@ class Puppet::Provider::DscBaseProvider
|
|
67
65
|
# rubocop:disable Metrics/BlockNesting
|
68
66
|
if canonicalized.nil? || canonicalized[:dsc_ensure] == 'absent'
|
69
67
|
canonicalized = r.dup
|
70
|
-
|
68
|
+
@cached_canonicalized_resource << r.dup
|
71
69
|
else
|
72
70
|
parameters = r.select { |name, _properties| parameter_attributes(context).include?(name) }
|
73
71
|
canonicalized.merge!(parameters)
|
@@ -91,7 +89,7 @@ class Puppet::Provider::DscBaseProvider
|
|
91
89
|
canonicalized.delete(key) unless downcased_resource.key?(key)
|
92
90
|
end
|
93
91
|
# Cache the actually canonicalized resource separately
|
94
|
-
|
92
|
+
@cached_canonicalized_resource << canonicalized.dup
|
95
93
|
end
|
96
94
|
# rubocop:enable Metrics/BlockNesting
|
97
95
|
end
|
@@ -123,13 +121,13 @@ class Puppet::Provider::DscBaseProvider
|
|
123
121
|
context.debug('Collecting data from the DSC Resource')
|
124
122
|
|
125
123
|
# If the resource has already been queried, do not bother querying for it again
|
126
|
-
cached_results = fetch_cached_hashes(
|
124
|
+
cached_results = fetch_cached_hashes(@cached_query_results, names)
|
127
125
|
return cached_results unless cached_results.empty?
|
128
126
|
|
129
|
-
if
|
127
|
+
if @cached_canonicalized_resource.empty?
|
130
128
|
mandatory_properties = {}
|
131
129
|
else
|
132
|
-
canonicalized_resource =
|
130
|
+
canonicalized_resource = @cached_canonicalized_resource[0].dup
|
133
131
|
mandatory_properties = canonicalized_resource.select do |attribute, _value|
|
134
132
|
(mandatory_get_attributes(context) - namevar_attributes(context)).include?(attribute)
|
135
133
|
end
|
@@ -266,9 +264,9 @@ class Puppet::Provider::DscBaseProvider
|
|
266
264
|
if error.include?('Logon failure: the user has not been granted the requested logon type at this computer')
|
267
265
|
logon_error = "PSDscRunAsCredential account specified (#{name_hash[:dsc_psdscrunascredential]['user']}) does not have appropriate logon rights; are they an administrator?"
|
268
266
|
name_hash[:name].nil? ? context.err(logon_error) : context.err(name_hash[:name], logon_error)
|
269
|
-
|
267
|
+
@logon_failures << name_hash[:dsc_psdscrunascredential].dup
|
270
268
|
# This is a hack to handle the query cache to prevent a second lookup
|
271
|
-
|
269
|
+
@cached_query_results << name_hash # if fetch_cached_hashes(@cached_query_results, [data]).empty?
|
272
270
|
else
|
273
271
|
context.err(error)
|
274
272
|
end
|
@@ -292,7 +290,7 @@ class Puppet::Provider::DscBaseProvider
|
|
292
290
|
def insync?(context, name, _property_name, _is_hash, should_hash)
|
293
291
|
return nil if should_hash[:validation_mode] != 'resource'
|
294
292
|
|
295
|
-
prior_result = fetch_cached_hashes(
|
293
|
+
prior_result = fetch_cached_hashes(@cached_test_results, [name])
|
296
294
|
prior_result.empty? ? invoke_test_method(context, name, should_hash) : prior_result.first[:in_desired_state]
|
297
295
|
end
|
298
296
|
|
@@ -361,7 +359,7 @@ class Puppet::Provider::DscBaseProvider
|
|
361
359
|
data = recursively_sort(data)
|
362
360
|
|
363
361
|
# Cache the query to prevent a second lookup
|
364
|
-
|
362
|
+
@cached_query_results << data.dup if fetch_cached_hashes(@cached_query_results, [data]).empty?
|
365
363
|
context.debug("Returned to Puppet as #{data}")
|
366
364
|
data
|
367
365
|
end
|
@@ -400,7 +398,7 @@ class Puppet::Provider::DscBaseProvider
|
|
400
398
|
return nil if data.nil?
|
401
399
|
|
402
400
|
in_desired_state = data['indesiredstate']
|
403
|
-
|
401
|
+
@cached_test_results << name.merge({ in_desired_state: in_desired_state })
|
404
402
|
|
405
403
|
return in_desired_state if in_desired_state
|
406
404
|
|
@@ -451,7 +449,7 @@ class Puppet::Provider::DscBaseProvider
|
|
451
449
|
# path to allow multiple modules to with shared dsc_resources to be installed side by side
|
452
450
|
# The old vendored_modules_path: puppet_x/dsc_resources
|
453
451
|
# The new vendored_modules_path: puppet_x/<module_name>/dsc_resources
|
454
|
-
root_module_path = load_path.
|
452
|
+
root_module_path = load_path.grep(%r{#{puppetize_name(module_name)}/lib}).first
|
455
453
|
vendored_path = if root_module_path.nil?
|
456
454
|
File.expand_path(Pathname.new(__FILE__).dirname + '../../../' + "puppet_x/#{puppetize_name(module_name)}/dsc_resources") # rubocop:disable Style/StringConcatenation
|
457
455
|
else
|
@@ -509,12 +507,12 @@ class Puppet::Provider::DscBaseProvider
|
|
509
507
|
#
|
510
508
|
# @return [Hash] containing all instantiated variables and the properties that they define
|
511
509
|
def instantiated_variables
|
512
|
-
|
510
|
+
@instantiated_variables ||= {}
|
513
511
|
end
|
514
512
|
|
515
513
|
# Clear the instantiated variables hash to be ready for the next run
|
516
514
|
def clear_instantiated_variables!
|
517
|
-
|
515
|
+
@instantiated_variables = {}
|
518
516
|
end
|
519
517
|
|
520
518
|
# Return true if the specified credential hash has already failed to execute a DSC resource due to
|
@@ -523,7 +521,7 @@ class Puppet::Provider::DscBaseProvider
|
|
523
521
|
# @param [Hash] a credential hash with a user and password keys where the password is a sensitive string
|
524
522
|
# @return [Bool] true if the credential_hash has already failed logon, false otherwise
|
525
523
|
def logon_failed_already?(credential_hash)
|
526
|
-
|
524
|
+
@logon_failures.any? do |failure_hash|
|
527
525
|
failure_hash['user'] == credential_hash['user'] && failure_hash['password'].unwrap == credential_hash['password'].unwrap
|
528
526
|
end
|
529
527
|
end
|
data/lib/pwsh/version.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
require 'puppet/resource_api'
|
5
4
|
require 'puppet/type'
|
6
5
|
require 'puppet/provider/dsc_base_provider/dsc_base_provider'
|
7
6
|
require 'json'
|
@@ -16,40 +15,40 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
16
15
|
|
17
16
|
# Reset the caches after each run
|
18
17
|
after do
|
19
|
-
described_class.
|
20
|
-
described_class.
|
21
|
-
described_class.
|
22
|
-
described_class.
|
18
|
+
described_class.instance_variable_set(:@cached_canonicalized_resource, [])
|
19
|
+
described_class.instance_variable_set(:@cached_query_results, [])
|
20
|
+
described_class.instance_variable_set(:@cached_test_results, [])
|
21
|
+
described_class.instance_variable_set(:@logon_failures, [])
|
23
22
|
end
|
24
23
|
|
25
24
|
describe '.initialize' do
|
26
25
|
before do
|
27
|
-
# Need to initialize the provider to load the
|
26
|
+
# Need to initialize the provider to load the instance variables
|
28
27
|
provider
|
29
28
|
end
|
30
29
|
|
31
|
-
it 'initializes the cached_canonicalized_resource
|
32
|
-
expect(described_class.
|
30
|
+
it 'initializes the cached_canonicalized_resource instance variable' do
|
31
|
+
expect(described_class.instance_variable_get(:@cached_canonicalized_resource)).to eq([])
|
33
32
|
end
|
34
33
|
|
35
|
-
it 'initializes the cached_query_results
|
36
|
-
expect(described_class.
|
34
|
+
it 'initializes the cached_query_results instance variable' do
|
35
|
+
expect(described_class.instance_variable_get(:@cached_query_results)).to eq([])
|
37
36
|
end
|
38
37
|
|
39
|
-
it 'initializes the cached_test_results
|
40
|
-
expect(described_class.
|
38
|
+
it 'initializes the cached_test_results instance variable' do
|
39
|
+
expect(described_class.instance_variable_get(:@cached_test_results)).to eq([])
|
41
40
|
end
|
42
41
|
|
43
|
-
it 'initializes the logon_failures
|
44
|
-
expect(described_class.
|
42
|
+
it 'initializes the logon_failures instance variable' do
|
43
|
+
expect(described_class.instance_variable_get(:@logon_failures)).to eq([])
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
47
|
describe '.cached_test_results' do
|
49
48
|
let(:cache_value) { %w[foo bar] }
|
50
49
|
|
51
|
-
it 'returns the value of the
|
52
|
-
described_class.
|
50
|
+
it 'returns the value of the @cached_test_results instance variable' do
|
51
|
+
described_class.instance_variable_set(:@cached_test_results, cache_value)
|
53
52
|
expect(provider.cached_test_results).to eq(cache_value)
|
54
53
|
end
|
55
54
|
end
|
@@ -238,11 +237,11 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
238
237
|
|
239
238
|
describe '.get' do
|
240
239
|
after do
|
241
|
-
described_class.
|
240
|
+
described_class.instance_variable_set(:@cached_canonicalized_resource, [])
|
242
241
|
end
|
243
242
|
|
244
243
|
it 'checks the cached results, returning if one exists for the specified names' do
|
245
|
-
described_class.
|
244
|
+
described_class.instance_variable_set(:@cached_canonicalized_resource, [])
|
246
245
|
allow(context).to receive(:debug)
|
247
246
|
expect(provider).to receive(:fetch_cached_hashes).with([], [{ name: 'foo' }]).and_return([{ name: 'foo', property: 'bar' }])
|
248
247
|
expect(provider).not_to receive(:invoke_get_method)
|
@@ -250,7 +249,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
250
249
|
end
|
251
250
|
|
252
251
|
it 'adds mandatory properties to the name hash when calling invoke_get_method' do
|
253
|
-
described_class.
|
252
|
+
described_class.instance_variable_set(:@cached_canonicalized_resource, [{ name: 'foo', property: 'bar', dsc_some_parameter: 'baz' }])
|
254
253
|
allow(context).to receive(:debug)
|
255
254
|
expect(provider).to receive(:fetch_cached_hashes).with([], [{ name: 'foo' }]).and_return([])
|
256
255
|
expect(provider).to receive(:namevar_attributes).and_return([:name]).exactly(3).times
|
@@ -531,7 +530,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
531
530
|
end
|
532
531
|
|
533
532
|
after do
|
534
|
-
described_class.
|
533
|
+
described_class.instance_variable_set(:@cached_query_results, nil)
|
535
534
|
end
|
536
535
|
|
537
536
|
context 'when the invocation script returns data without errors' do
|
@@ -558,7 +557,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
558
557
|
|
559
558
|
it 'caches the result' do
|
560
559
|
expect { result }.not_to raise_error
|
561
|
-
expect(described_class.
|
560
|
+
expect(described_class.instance_variable_get(:@cached_query_results)).to eq([result])
|
562
561
|
end
|
563
562
|
|
564
563
|
it 'removes unrelated properties from the result' do
|
@@ -720,7 +719,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
720
719
|
end
|
721
720
|
|
722
721
|
after do
|
723
|
-
described_class.
|
722
|
+
described_class.instance_variable_set(:@logon_failures, [])
|
724
723
|
end
|
725
724
|
|
726
725
|
it 'errors specifically for a logon failure and returns nil' do
|
@@ -729,12 +728,12 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
729
728
|
|
730
729
|
it 'caches the logon failure' do
|
731
730
|
expect { result }.not_to raise_error
|
732
|
-
expect(described_class.
|
731
|
+
expect(described_class.instance_variable_get(:@logon_failures)).to eq([credential_hash])
|
733
732
|
end
|
734
733
|
|
735
734
|
it 'caches the query results' do
|
736
735
|
expect { result }.not_to raise_error
|
737
|
-
expect(described_class.
|
736
|
+
expect(described_class.instance_variable_get(:@cached_query_results)).to eq([name_hash])
|
738
737
|
end
|
739
738
|
end
|
740
739
|
|
@@ -982,11 +981,11 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
982
981
|
end
|
983
982
|
|
984
983
|
describe '.invoke_test_method' do
|
985
|
-
subject(:result) { provider.invoke_test_method(context, name,
|
984
|
+
subject(:result) { provider.invoke_test_method(context, name, expect(subject).to) }
|
986
985
|
|
987
986
|
let(:name) { { name: 'foo', dsc_name: 'bar' } }
|
988
|
-
let(:
|
989
|
-
let(:test_properties) {
|
987
|
+
let(:should) { name.merge(dsc_ensure: 'present') }
|
988
|
+
let(:test_properties) { expect(subject).to.reject { |k, _v| k == :name } }
|
990
989
|
let(:invoke_dsc_resource_data) { nil }
|
991
990
|
|
992
991
|
before do
|
@@ -996,7 +995,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
996
995
|
end
|
997
996
|
|
998
997
|
after do
|
999
|
-
described_class.
|
998
|
+
described_class.instance_variable_set(:@cached_test_results, [])
|
1000
999
|
end
|
1001
1000
|
|
1002
1001
|
context 'when something went wrong calling Invoke-DscResource' do
|
@@ -1044,28 +1043,28 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
1044
1043
|
|
1045
1044
|
describe '.instantiated_variables' do
|
1046
1045
|
after do
|
1047
|
-
described_class.
|
1046
|
+
described_class.instance_variable_set(:@instantiated_variables, [])
|
1048
1047
|
end
|
1049
1048
|
|
1050
|
-
it 'sets the instantiated_variables
|
1049
|
+
it 'sets the instantiated_variables instance variable to {} if not initialized' do
|
1051
1050
|
expect(provider.instantiated_variables).to eq({})
|
1052
1051
|
end
|
1053
1052
|
|
1054
|
-
it 'returns the instantiated_variables
|
1055
|
-
described_class.
|
1053
|
+
it 'returns the instantiated_variables instance variable if already initialized' do
|
1054
|
+
described_class.instance_variable_set(:@instantiated_variables, { foo: 'bar' })
|
1056
1055
|
expect(provider.instantiated_variables).to eq({ foo: 'bar' })
|
1057
1056
|
end
|
1058
1057
|
end
|
1059
1058
|
|
1060
1059
|
describe '.clear_instantiated_variables!' do
|
1061
1060
|
after do
|
1062
|
-
described_class.
|
1061
|
+
described_class.instance_variable_set(:@instantiated_variables, [])
|
1063
1062
|
end
|
1064
1063
|
|
1065
|
-
it 'sets the instantiated_variables
|
1066
|
-
described_class.
|
1064
|
+
it 'sets the instantiated_variables instance variable to {}' do
|
1065
|
+
described_class.instance_variable_set(:@instantiated_variables, { foo: 'bar' })
|
1067
1066
|
expect { provider.clear_instantiated_variables! }.not_to raise_error
|
1068
|
-
expect(described_class.
|
1067
|
+
expect(described_class.instance_variable_get(:@instantiated_variables)).to eq({})
|
1069
1068
|
end
|
1070
1069
|
end
|
1071
1070
|
|
@@ -1088,16 +1087,16 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
1088
1087
|
end
|
1089
1088
|
|
1090
1089
|
after do
|
1091
|
-
described_class.
|
1090
|
+
described_class.instance_variable_set(:@logon_failures, [])
|
1092
1091
|
end
|
1093
1092
|
|
1094
1093
|
it 'returns false if there have been no failed logons with the username/password combination' do
|
1095
|
-
described_class.
|
1094
|
+
described_class.instance_variable_set(:@logon_failures, [bad_credential_hash])
|
1096
1095
|
expect(provider.logon_failed_already?(good_credential_hash)).to be(false)
|
1097
1096
|
end
|
1098
1097
|
|
1099
|
-
it 'returns true if the username/password specified are found in the logon_failures
|
1100
|
-
described_class.
|
1098
|
+
it 'returns true if the username/password specified are found in the logon_failures instance variable' do
|
1099
|
+
described_class.instance_variable_set(:@logon_failures, [good_credential_hash, bad_credential_hash])
|
1101
1100
|
expect(provider.logon_failed_already?(bad_credential_hash)).to be(true)
|
1102
1101
|
end
|
1103
1102
|
end
|
@@ -1511,7 +1510,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
1511
1510
|
end
|
1512
1511
|
|
1513
1512
|
after do
|
1514
|
-
described_class.
|
1513
|
+
described_class.instance_variable_set(:@instantiated_variables, [])
|
1515
1514
|
end
|
1516
1515
|
|
1517
1516
|
it 'writes the ruby representation of the credentials as the value of a key named for the new variable into the instantiated_variables cache' do
|
@@ -1544,7 +1543,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
1544
1543
|
subject(:result) { provider.prepare_cim_instances(test_resource) }
|
1545
1544
|
|
1546
1545
|
after do
|
1547
|
-
described_class.
|
1546
|
+
described_class.instance_variable_set(:@instantiated_variables, [])
|
1548
1547
|
end
|
1549
1548
|
|
1550
1549
|
context 'when a cim instance is passed without nested cim instances' do
|
@@ -1653,7 +1652,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
1653
1652
|
|
1654
1653
|
describe '.format_ciminstance' do
|
1655
1654
|
after do
|
1656
|
-
described_class.
|
1655
|
+
described_class.instance_variable_set(:@instantiated_variables, [])
|
1657
1656
|
end
|
1658
1657
|
|
1659
1658
|
it 'defines and returns a new cim instance as a PowerShell variable, passing the class name and property hash' do
|
@@ -1669,7 +1668,7 @@ RSpec.describe Puppet::Provider::DscBaseProvider do
|
|
1669
1668
|
end
|
1670
1669
|
|
1671
1670
|
it 'interpolates variables in the case of a cim instance containing a nested instance' do
|
1672
|
-
described_class.
|
1671
|
+
described_class.instance_variable_set(:@instantiated_variables, { 'SomeVariable' => { 'bar' => 'ope' } })
|
1673
1672
|
property_hash = { 'foo' => { 'bar' => 'ope' } }
|
1674
1673
|
expect(provider.format_ciminstance('foo', 'SomeClass', property_hash)).to match(/@\{'foo' = \$SomeVariable\}/)
|
1675
1674
|
end
|
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: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: PowerShell code manager for ruby.
|
14
14
|
email:
|