poise 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/poise/helpers/lwrp_polyfill.rb +9 -1
- data/lib/poise/helpers/subcontext_block.rb +2 -0
- data/lib/poise/subcontext/runner.rb +2 -2
- data/lib/poise/version.rb +1 -1
- data/test/spec/helpers/lwrp_polyfill_spec.rb +18 -0
- data/test/spec/helpers/notifying_block_spec.rb +31 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07fe35f3e4e7b7f5761c1c1225a0dccd578d3a78
|
4
|
+
data.tar.gz: d0b820b837c47bedf72a1cb095e9249d4a415fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73711a21746f13d0bcbfd2042596fc2829c28a8e089608368839b632b5bf19306843fed59162764f18fa624cf84d485c8ee43522f9eb42d97bf8c7b58ecfdb91
|
7
|
+
data.tar.gz: e937e4a3c327f7be9395fd6497b0d1f2f0fc9af3094242858db89ad85cdd1afa6094e7328e0b543e6615321417a827805368582f4c274cd3023dd519dbc03c2a
|
data/CHANGELOG.md
CHANGED
@@ -62,7 +62,15 @@ module Poise
|
|
62
62
|
@default_action = name
|
63
63
|
actions(*name)
|
64
64
|
end
|
65
|
-
@default_action
|
65
|
+
if @default_action
|
66
|
+
@default_action
|
67
|
+
elsif respond_to?(:superclass) && superclass != Chef::Resource && superclass.respond_to?(:default_action) && Array(superclass.default_action) != %i{nothing}
|
68
|
+
superclass.default_action
|
69
|
+
elsif first_non_nothing = actions.find {|action| action != :nothing }
|
70
|
+
[first_non_nothing]
|
71
|
+
else
|
72
|
+
%i{nothing}
|
73
|
+
end
|
66
74
|
end
|
67
75
|
|
68
76
|
# @overload actions()
|
@@ -43,6 +43,8 @@ module Poise
|
|
43
43
|
end
|
44
44
|
# Create the subcollection.
|
45
45
|
sub_run_context.resource_collection = Poise::Subcontext::ResourceCollection.new(parent_context.resource_collection)
|
46
|
+
# Create an accessor for the parent run context.
|
47
|
+
sub_run_context.define_singleton_method(:parent_run_context) { parent_context }
|
46
48
|
|
47
49
|
# Declare sub-resources within the sub-run-context. Since they
|
48
50
|
# are declared here, they do not pollute the parent run-context.
|
@@ -36,8 +36,8 @@ module Poise
|
|
36
36
|
# ever fire because the superclass re-raises if there is an error.
|
37
37
|
return super if error
|
38
38
|
delayed_actions.each do |notification|
|
39
|
-
notifications = run_context.delayed_notifications(@resource)
|
40
|
-
if
|
39
|
+
notifications = run_context.parent_run_context.delayed_notifications(@resource)
|
40
|
+
if notifications.any? { |existing_notification| existing_notification.duplicates?(notification) }
|
41
41
|
Chef::Log.info( "#{@resource} not queuing delayed action #{notification.action} on #{notification.resource}"\
|
42
42
|
" (delayed), as it's already been queued")
|
43
43
|
else
|
data/lib/poise/version.rb
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
require 'spec_helper'
|
18
|
+
require 'chef/provider/lwrp_base'
|
19
|
+
require 'chef/resource/lwrp_base'
|
18
20
|
|
19
21
|
describe Poise::Helpers::LWRPPolyfill do
|
20
22
|
describe Poise::Helpers::LWRPPolyfill::Resource do
|
@@ -156,4 +158,20 @@ describe Poise::Helpers::LWRPPolyfill do
|
|
156
158
|
it { is_expected.to run_ruby_block('test') }
|
157
159
|
end # /describe Chef::DSL::Recipe include
|
158
160
|
end # /describe Poise::Helpers::LWRPPolyfill::Provider
|
161
|
+
|
162
|
+
context 'inside LWRPBase' do
|
163
|
+
resource(:poise_test, parent: Chef::Resource::LWRPBase, auto: false) do
|
164
|
+
include described_class
|
165
|
+
actions(:run)
|
166
|
+
end
|
167
|
+
provider(:poise_test, parent: Chef::Provider::LWRPBase, auto: false) do
|
168
|
+
include described_class
|
169
|
+
action(:run) { }
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#default_action' do
|
173
|
+
subject { resource(:poise_test).default_action }
|
174
|
+
it { is_expected.to eq %i{run} }
|
175
|
+
end # /describe #default_action
|
176
|
+
end # /context inside LWRPBase
|
159
177
|
end
|
@@ -123,4 +123,35 @@ describe Poise::Helpers::NotifyingBlock do
|
|
123
123
|
|
124
124
|
it { is_expected.to_not run_ruby_block('test') }
|
125
125
|
end # /describe regression test for picking up sibling notifications outside the subcontext for resources with matching name
|
126
|
+
|
127
|
+
describe 'delayed notifications' do
|
128
|
+
provider(:poise_test) do
|
129
|
+
include Poise::Helpers::LWRPPolyfill
|
130
|
+
include described_class
|
131
|
+
|
132
|
+
def action_run
|
133
|
+
notifying_block do
|
134
|
+
ruby_block 'one' do
|
135
|
+
action :nothing
|
136
|
+
block { node.run_state[:things] << 'one' }
|
137
|
+
end
|
138
|
+
|
139
|
+
ruby_block 'two' do
|
140
|
+
block { node.run_state[:things] << 'two' }
|
141
|
+
notifies :run, 'ruby_block[one]'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
recipe(subject: false) do
|
147
|
+
node.run_state[:things] = []
|
148
|
+
poise_test 'test'
|
149
|
+
end
|
150
|
+
subject { chef_run.node.run_state[:things] }
|
151
|
+
|
152
|
+
# The important test.
|
153
|
+
it { is_expected.to include 'one' }
|
154
|
+
# Sanity check for my harness.
|
155
|
+
it { is_expected.to include 'two' }
|
156
|
+
end # /describe delayed notifications
|
126
157
|
end
|