chef-utils 18.0.161 → 18.0.169

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/Rakefile +15 -15
  4. data/chef-utils.gemspec +50 -50
  5. data/lib/chef-utils/dist.rb +154 -154
  6. data/lib/chef-utils/dsl/architecture.rb +150 -150
  7. data/lib/chef-utils/dsl/cloud.rb +155 -155
  8. data/lib/chef-utils/dsl/default_paths.rb +60 -60
  9. data/lib/chef-utils/dsl/introspection.rb +134 -134
  10. data/lib/chef-utils/dsl/os.rb +58 -58
  11. data/lib/chef-utils/dsl/path_sanity.rb +39 -39
  12. data/lib/chef-utils/dsl/platform.rb +387 -387
  13. data/lib/chef-utils/dsl/platform_family.rb +360 -360
  14. data/lib/chef-utils/dsl/platform_version.rb +41 -41
  15. data/lib/chef-utils/dsl/service.rb +112 -112
  16. data/lib/chef-utils/dsl/train_helpers.rb +87 -87
  17. data/lib/chef-utils/dsl/virtualization.rb +272 -272
  18. data/lib/chef-utils/dsl/which.rb +123 -123
  19. data/lib/chef-utils/dsl/windows.rb +86 -86
  20. data/lib/chef-utils/internal.rb +114 -114
  21. data/lib/chef-utils/mash.rb +263 -263
  22. data/lib/chef-utils/parallel_map.rb +131 -131
  23. data/lib/chef-utils/version.rb +20 -20
  24. data/lib/chef-utils/version_string.rb +160 -160
  25. data/lib/chef-utils.rb +53 -53
  26. data/spec/spec_helper.rb +100 -100
  27. data/spec/unit/dsl/architecture_spec.rb +151 -151
  28. data/spec/unit/dsl/cloud_spec.rb +93 -93
  29. data/spec/unit/dsl/dsl_spec.rb +34 -34
  30. data/spec/unit/dsl/introspection_spec.rb +201 -201
  31. data/spec/unit/dsl/os_spec.rb +175 -175
  32. data/spec/unit/dsl/path_sanity_spec.rb +86 -86
  33. data/spec/unit/dsl/platform_family_spec.rb +235 -235
  34. data/spec/unit/dsl/platform_spec.rb +252 -252
  35. data/spec/unit/dsl/service_spec.rb +117 -117
  36. data/spec/unit/dsl/virtualization_spec.rb +75 -75
  37. data/spec/unit/dsl/which_spec.rb +171 -171
  38. data/spec/unit/dsl/windows_spec.rb +84 -84
  39. data/spec/unit/mash_spec.rb +51 -51
  40. data/spec/unit/parallel_map_spec.rb +156 -156
  41. metadata +3 -3
@@ -1,252 +1,252 @@
1
- # frozen_string_literal: true
2
- #
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
- require "fauxhai"
21
-
22
- def platform_reports_true_for(*args)
23
- args.each do |method|
24
- it "reports true for #{method} on the module given a node" do
25
- expect(described_class.send(method, node)).to be true
26
- end
27
- it "reports true for #{method} when mixed into a class with a node" do
28
- expect(thing_with_a_node.send(method, node)).to be true
29
- end
30
- it "reports true for #{method} when mixed into a class with a run_context" do
31
- expect(thing_with_a_run_context.send(method, node)).to be true
32
- end
33
- it "reports true for #{method} when mixed into a class with the dsl" do
34
- expect(thing_with_the_dsl.send(method, node)).to be true
35
- end
36
- it "reports true for #{method} on the main class give a node" do
37
- expect(ChefUtils.send(method, node)).to be true
38
- end
39
- end
40
- (PLATFORM_HELPERS - args).each do |method|
41
- it "reports false for #{method} on the module given a node" do
42
- expect(described_class.send(method, node)).to be false
43
- end
44
- it "reports false for #{method} when mixed into a class with a node" do
45
- expect(thing_with_a_node.send(method, node)).to be false
46
- end
47
- it "reports false for #{method} when mixed into a class with the dsl" do
48
- expect(thing_with_the_dsl.send(method, node)).to be false
49
- end
50
- it "reports false for #{method} on the main class give a node" do
51
- expect(ChefUtils.send(method, node)).to be false
52
- end
53
- end
54
- end
55
-
56
- RSpec.describe ChefUtils::DSL::Platform do
57
- let(:node) { Fauxhai.mock(options).data }
58
-
59
- class ThingWithANode
60
- include ChefUtils::DSL::Platform
61
- attr_accessor :node
62
-
63
- def initialize(node)
64
- @node = node
65
- end
66
- end
67
-
68
- class ThingWithARunContext
69
- include ChefUtils::DSL::Platform
70
- class RunContext
71
- attr_accessor :node
72
- end
73
- attr_accessor :run_context
74
-
75
- def initialize(node)
76
- @run_context = RunContext.new
77
- run_context.node = node
78
- end
79
- end
80
-
81
- class ThingWithTheDSL
82
- include ChefUtils
83
- attr_accessor :node
84
-
85
- def initialize(node)
86
- @node = node
87
- end
88
- end
89
-
90
- let(:thing_with_a_node) { ThingWithANode.new(node) }
91
- let(:thing_with_a_run_context) { ThingWithARunContext.new(node) }
92
- let(:thing_with_the_dsl) { ThingWithTheDSL.new(node) }
93
-
94
- ( HELPER_MODULES - [ described_class ] ).each do |klass|
95
- it "does not have methods that collide with #{klass}" do
96
- expect((klass.methods - Module.methods) & PLATFORM_HELPERS).to be_empty
97
- end
98
- end
99
-
100
- context "on ubuntu" do
101
- let(:options) { { platform: "ubuntu" } }
102
-
103
- platform_reports_true_for(:ubuntu?, :ubuntu_platform?)
104
- end
105
-
106
- context "on raspbian" do
107
- let(:options) { { platform: "raspbian" } }
108
-
109
- platform_reports_true_for(:raspbian?, :raspbian_platform?)
110
- end
111
-
112
- context "on linuxmint" do
113
- let(:options) { { platform: "linuxmint" } }
114
-
115
- platform_reports_true_for(:mint?, :linux_mint?, :linuxmint?, :linuxmint_platform?)
116
- end
117
-
118
- context "on debian" do
119
- let(:options) { { platform: "debian" } }
120
-
121
- platform_reports_true_for(:debian_platform?)
122
- end
123
-
124
- context "on aix" do
125
- let(:options) { { platform: "aix" } }
126
-
127
- platform_reports_true_for(:aix_platform?)
128
- end
129
-
130
- context "on amazon" do
131
- let(:options) { { platform: "amazon" } }
132
-
133
- platform_reports_true_for(:amazon_platform?)
134
- end
135
-
136
- context "on arch" do
137
- let(:options) { { platform: "arch" } }
138
-
139
- platform_reports_true_for(:arch_platform?)
140
- end
141
-
142
- context "on centos" do
143
- let(:options) { { platform: "centos" } }
144
-
145
- platform_reports_true_for(:centos?, :centos_platform?)
146
- end
147
-
148
- context "on centos stream w/o os_release" do
149
- let(:options) { { platform: "centos" } }
150
- let(:node) { { "platform" => "centos", "platform_version" => "8", "platform_family" => "rhel", "os" => "linux", "lsb" => { "id" => "CentOSStream" }, "os_release" => nil } }
151
-
152
- platform_reports_true_for(:centos?, :centos_platform?, :centos_stream_platform?)
153
- end
154
-
155
- context "on centos stream w/ os_release" do
156
- let(:options) { { platform: "centos" } }
157
- let(:node) { { "platform" => "centos", "platform_version" => "8", "platform_family" => "rhel", "os" => "linux", "os_release" => { "name" => "CentOS Stream" } } }
158
-
159
- platform_reports_true_for(:centos?, :centos_platform?, :centos_stream_platform?)
160
- end
161
-
162
- context "on clearos" do
163
- let(:options) { { platform: "clearos" } }
164
-
165
- platform_reports_true_for(:clearos?, :clearos_platform?)
166
- end
167
-
168
- context "on dragonfly4" do
169
- let(:options) { { platform: "dragonfly4" } }
170
-
171
- platform_reports_true_for(:dragonfly_platform?)
172
- end
173
-
174
- context "on fedora" do
175
- let(:options) { { platform: "fedora" } }
176
-
177
- platform_reports_true_for(:fedora_platform?)
178
- end
179
-
180
- context "on freebsd" do
181
- let(:options) { { platform: "freebsd" } }
182
-
183
- platform_reports_true_for(:freebsd_platform?)
184
- end
185
-
186
- context "on gentoo" do
187
- let(:options) { { platform: "gentoo" } }
188
-
189
- platform_reports_true_for(:gentoo_platform?)
190
- end
191
-
192
- context "on mac_os_x" do
193
- let(:options) { { platform: "mac_os_x" } }
194
-
195
- platform_reports_true_for(:mac_os_x_platform?, :macos_platform?)
196
- end
197
-
198
- context "on openbsd" do
199
- let(:options) { { platform: "openbsd" } }
200
-
201
- platform_reports_true_for(:openbsd_platform?)
202
- end
203
-
204
- context "on oracle" do
205
- let(:options) { { platform: "oracle" } }
206
-
207
- platform_reports_true_for(:oracle?, :oracle_linux?, :oracle_platform?)
208
- end
209
-
210
- context "on redhat" do
211
- let(:options) { { platform: "redhat" } }
212
-
213
- platform_reports_true_for(:redhat?, :redhat_enterprise_linux?, :redhat_enterprise?, :redhat_platform?)
214
- end
215
-
216
- context "on smartos" do
217
- let(:options) { { platform: "smartos" } }
218
-
219
- platform_reports_true_for(:smartos_platform?)
220
- end
221
-
222
- context "on solaris2" do
223
- let(:options) { { platform: "solaris2" } }
224
-
225
- platform_reports_true_for(:solaris2_platform?)
226
- end
227
-
228
- context "on suse" do
229
- let(:options) { { platform: "suse" } }
230
-
231
- platform_reports_true_for(:suse_platform?)
232
- end
233
-
234
- context "on windows" do
235
- let(:options) { { platform: "windows" } }
236
-
237
- platform_reports_true_for(:windows_platform?)
238
- end
239
-
240
- context "on opensuseleap" do
241
- let(:node) { { "platform" => "opensuseleap", "platform_version" => "15.1", "platform_family" => "suse", "os" => "linux" } }
242
-
243
- platform_reports_true_for(:opensuse_platform?, :opensuseleap_platform?, :opensuse?, :leap_platform?)
244
- end
245
-
246
- context "on opensuse" do
247
- let(:node) { { "platform" => "opensuse", "platform_version" => "11.0", "platform_family" => "suse", "os" => "linux" } }
248
-
249
- platform_reports_true_for(:opensuse_platform?, :opensuseleap_platform?, :opensuse?, :leap_platform?)
250
- end
251
-
252
- end
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+ require "fauxhai"
21
+
22
+ def platform_reports_true_for(*args)
23
+ args.each do |method|
24
+ it "reports true for #{method} on the module given a node" do
25
+ expect(described_class.send(method, node)).to be true
26
+ end
27
+ it "reports true for #{method} when mixed into a class with a node" do
28
+ expect(thing_with_a_node.send(method, node)).to be true
29
+ end
30
+ it "reports true for #{method} when mixed into a class with a run_context" do
31
+ expect(thing_with_a_run_context.send(method, node)).to be true
32
+ end
33
+ it "reports true for #{method} when mixed into a class with the dsl" do
34
+ expect(thing_with_the_dsl.send(method, node)).to be true
35
+ end
36
+ it "reports true for #{method} on the main class give a node" do
37
+ expect(ChefUtils.send(method, node)).to be true
38
+ end
39
+ end
40
+ (PLATFORM_HELPERS - args).each do |method|
41
+ it "reports false for #{method} on the module given a node" do
42
+ expect(described_class.send(method, node)).to be false
43
+ end
44
+ it "reports false for #{method} when mixed into a class with a node" do
45
+ expect(thing_with_a_node.send(method, node)).to be false
46
+ end
47
+ it "reports false for #{method} when mixed into a class with the dsl" do
48
+ expect(thing_with_the_dsl.send(method, node)).to be false
49
+ end
50
+ it "reports false for #{method} on the main class give a node" do
51
+ expect(ChefUtils.send(method, node)).to be false
52
+ end
53
+ end
54
+ end
55
+
56
+ RSpec.describe ChefUtils::DSL::Platform do
57
+ let(:node) { Fauxhai.mock(options).data }
58
+
59
+ class ThingWithANode
60
+ include ChefUtils::DSL::Platform
61
+ attr_accessor :node
62
+
63
+ def initialize(node)
64
+ @node = node
65
+ end
66
+ end
67
+
68
+ class ThingWithARunContext
69
+ include ChefUtils::DSL::Platform
70
+ class RunContext
71
+ attr_accessor :node
72
+ end
73
+ attr_accessor :run_context
74
+
75
+ def initialize(node)
76
+ @run_context = RunContext.new
77
+ run_context.node = node
78
+ end
79
+ end
80
+
81
+ class ThingWithTheDSL
82
+ include ChefUtils
83
+ attr_accessor :node
84
+
85
+ def initialize(node)
86
+ @node = node
87
+ end
88
+ end
89
+
90
+ let(:thing_with_a_node) { ThingWithANode.new(node) }
91
+ let(:thing_with_a_run_context) { ThingWithARunContext.new(node) }
92
+ let(:thing_with_the_dsl) { ThingWithTheDSL.new(node) }
93
+
94
+ ( HELPER_MODULES - [ described_class ] ).each do |klass|
95
+ it "does not have methods that collide with #{klass}" do
96
+ expect((klass.methods - Module.methods) & PLATFORM_HELPERS).to be_empty
97
+ end
98
+ end
99
+
100
+ context "on ubuntu" do
101
+ let(:options) { { platform: "ubuntu" } }
102
+
103
+ platform_reports_true_for(:ubuntu?, :ubuntu_platform?)
104
+ end
105
+
106
+ context "on raspbian" do
107
+ let(:options) { { platform: "raspbian" } }
108
+
109
+ platform_reports_true_for(:raspbian?, :raspbian_platform?)
110
+ end
111
+
112
+ context "on linuxmint" do
113
+ let(:options) { { platform: "linuxmint" } }
114
+
115
+ platform_reports_true_for(:mint?, :linux_mint?, :linuxmint?, :linuxmint_platform?)
116
+ end
117
+
118
+ context "on debian" do
119
+ let(:options) { { platform: "debian" } }
120
+
121
+ platform_reports_true_for(:debian_platform?)
122
+ end
123
+
124
+ context "on aix" do
125
+ let(:options) { { platform: "aix" } }
126
+
127
+ platform_reports_true_for(:aix_platform?)
128
+ end
129
+
130
+ context "on amazon" do
131
+ let(:options) { { platform: "amazon" } }
132
+
133
+ platform_reports_true_for(:amazon_platform?)
134
+ end
135
+
136
+ context "on arch" do
137
+ let(:options) { { platform: "arch" } }
138
+
139
+ platform_reports_true_for(:arch_platform?)
140
+ end
141
+
142
+ context "on centos" do
143
+ let(:options) { { platform: "centos" } }
144
+
145
+ platform_reports_true_for(:centos?, :centos_platform?)
146
+ end
147
+
148
+ context "on centos stream w/o os_release" do
149
+ let(:options) { { platform: "centos" } }
150
+ let(:node) { { "platform" => "centos", "platform_version" => "8", "platform_family" => "rhel", "os" => "linux", "lsb" => { "id" => "CentOSStream" }, "os_release" => nil } }
151
+
152
+ platform_reports_true_for(:centos?, :centos_platform?, :centos_stream_platform?)
153
+ end
154
+
155
+ context "on centos stream w/ os_release" do
156
+ let(:options) { { platform: "centos" } }
157
+ let(:node) { { "platform" => "centos", "platform_version" => "8", "platform_family" => "rhel", "os" => "linux", "os_release" => { "name" => "CentOS Stream" } } }
158
+
159
+ platform_reports_true_for(:centos?, :centos_platform?, :centos_stream_platform?)
160
+ end
161
+
162
+ context "on clearos" do
163
+ let(:options) { { platform: "clearos" } }
164
+
165
+ platform_reports_true_for(:clearos?, :clearos_platform?)
166
+ end
167
+
168
+ context "on dragonfly4" do
169
+ let(:options) { { platform: "dragonfly4" } }
170
+
171
+ platform_reports_true_for(:dragonfly_platform?)
172
+ end
173
+
174
+ context "on fedora" do
175
+ let(:options) { { platform: "fedora" } }
176
+
177
+ platform_reports_true_for(:fedora_platform?)
178
+ end
179
+
180
+ context "on freebsd" do
181
+ let(:options) { { platform: "freebsd" } }
182
+
183
+ platform_reports_true_for(:freebsd_platform?)
184
+ end
185
+
186
+ context "on gentoo" do
187
+ let(:options) { { platform: "gentoo" } }
188
+
189
+ platform_reports_true_for(:gentoo_platform?)
190
+ end
191
+
192
+ context "on mac_os_x" do
193
+ let(:options) { { platform: "mac_os_x" } }
194
+
195
+ platform_reports_true_for(:mac_os_x_platform?, :macos_platform?)
196
+ end
197
+
198
+ context "on openbsd" do
199
+ let(:options) { { platform: "openbsd" } }
200
+
201
+ platform_reports_true_for(:openbsd_platform?)
202
+ end
203
+
204
+ context "on oracle" do
205
+ let(:options) { { platform: "oracle" } }
206
+
207
+ platform_reports_true_for(:oracle?, :oracle_linux?, :oracle_platform?)
208
+ end
209
+
210
+ context "on redhat" do
211
+ let(:options) { { platform: "redhat" } }
212
+
213
+ platform_reports_true_for(:redhat?, :redhat_enterprise_linux?, :redhat_enterprise?, :redhat_platform?)
214
+ end
215
+
216
+ context "on smartos" do
217
+ let(:options) { { platform: "smartos" } }
218
+
219
+ platform_reports_true_for(:smartos_platform?)
220
+ end
221
+
222
+ context "on solaris2" do
223
+ let(:options) { { platform: "solaris2" } }
224
+
225
+ platform_reports_true_for(:solaris2_platform?)
226
+ end
227
+
228
+ context "on suse" do
229
+ let(:options) { { platform: "suse" } }
230
+
231
+ platform_reports_true_for(:suse_platform?)
232
+ end
233
+
234
+ context "on windows" do
235
+ let(:options) { { platform: "windows" } }
236
+
237
+ platform_reports_true_for(:windows_platform?)
238
+ end
239
+
240
+ context "on opensuseleap" do
241
+ let(:node) { { "platform" => "opensuseleap", "platform_version" => "15.1", "platform_family" => "suse", "os" => "linux" } }
242
+
243
+ platform_reports_true_for(:opensuse_platform?, :opensuseleap_platform?, :opensuse?, :leap_platform?)
244
+ end
245
+
246
+ context "on opensuse" do
247
+ let(:node) { { "platform" => "opensuse", "platform_version" => "11.0", "platform_family" => "suse", "os" => "linux" } }
248
+
249
+ platform_reports_true_for(:opensuse_platform?, :opensuseleap_platform?, :opensuse?, :leap_platform?)
250
+ end
251
+
252
+ end