chef-utils 16.10.17 → 17.10.19

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.
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 -46
  5. data/lib/chef-utils/dist.rb +151 -98
  6. data/lib/chef-utils/dsl/architecture.rb +150 -150
  7. data/lib/chef-utils/dsl/cloud.rb +155 -144
  8. data/lib/chef-utils/dsl/default_paths.rb +60 -60
  9. data/lib/chef-utils/dsl/introspection.rb +134 -123
  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 -372
  13. data/lib/chef-utils/dsl/platform_family.rb +355 -344
  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 -250
  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 -240
  22. data/lib/chef-utils/parallel_map.rb +131 -0
  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 -89
  29. data/spec/unit/dsl/dsl_spec.rb +34 -34
  30. data/spec/unit/dsl/introspection_spec.rb +201 -189
  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 -223
  34. data/spec/unit/dsl/platform_spec.rb +252 -238
  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 -0
  41. metadata +26 -10
@@ -1,151 +1,151 @@
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
-
21
- def arch_reports_true_for(*args)
22
- args.each do |method|
23
- it "reports true for #{method}" do
24
- expect(described_class.send(method, node)).to be true
25
- end
26
- end
27
- (ARCH_HELPERS - args).each do |method|
28
- it "reports false for #{method}" do
29
- expect(described_class.send(method, node)).to be false
30
- end
31
- end
32
- end
33
-
34
- RSpec.describe ChefUtils::DSL::Architecture do
35
- let(:node) { { "kernel" => { "machine" => arch } } }
36
-
37
- ( HELPER_MODULES - [ described_class ] ).each do |klass|
38
- it "does not have methods that collide with #{klass}" do
39
- expect((klass.methods - Module.methods) & ARCH_HELPERS).to be_empty
40
- end
41
- end
42
-
43
- ARCH_HELPERS.each do |helper|
44
- it "has the #{helper} in the ChefUtils module" do
45
- expect(ChefUtils).to respond_to(helper)
46
- end
47
- end
48
-
49
- context "on x86_64" do
50
- let(:arch) { "x86_64" }
51
-
52
- arch_reports_true_for(:intel?, :_64_bit?)
53
- end
54
-
55
- context "on amd64" do
56
- let(:arch) { "amd64" }
57
-
58
- arch_reports_true_for(:intel?, :_64_bit?)
59
- end
60
- context "on ppc64" do
61
- let(:arch) { "ppc64" }
62
-
63
- arch_reports_true_for(:ppc64?, :_64_bit?)
64
- end
65
- context "on ppc64le" do
66
- let(:arch) { "ppc64le" }
67
-
68
- arch_reports_true_for(:ppc64le?, :_64_bit?)
69
- end
70
- context "on s390x" do
71
- let(:arch) { "s390x" }
72
-
73
- arch_reports_true_for(:s390x?, :_64_bit?)
74
- end
75
- context "on ia64" do
76
- let(:arch) { "ia64" }
77
-
78
- arch_reports_true_for(:_64_bit?)
79
- end
80
- context "on sparc64" do
81
- let(:arch) { "sparc64" }
82
-
83
- arch_reports_true_for(:_64_bit?)
84
- end
85
- context "on aarch64" do
86
- let(:arch) { "aarch64" }
87
-
88
- arch_reports_true_for(:_64_bit?, :arm?)
89
- end
90
- context "on arch64" do
91
- let(:arch) { "arch64" }
92
-
93
- arch_reports_true_for(:_64_bit?, :arm?)
94
- end
95
- context "on arm64" do
96
- let(:arch) { "arm64" }
97
-
98
- arch_reports_true_for(:_64_bit?, :arm?)
99
- end
100
- context "on sun4v" do
101
- let(:arch) { "sun4v" }
102
-
103
- arch_reports_true_for(:sparc?, :_64_bit?)
104
- end
105
- context "on sun4u" do
106
- let(:arch) { "sun4u" }
107
-
108
- arch_reports_true_for(:sparc?, :_64_bit?)
109
- end
110
- context "on i86pc" do
111
- let(:arch) { "i86pc" }
112
-
113
- arch_reports_true_for(:i386?, :intel?, :_32_bit?)
114
- end
115
- context "on i386" do
116
- let(:arch) { "i386" }
117
-
118
- arch_reports_true_for(:i386?, :intel?, :_32_bit?)
119
- end
120
- context "on i686" do
121
- let(:arch) { "i686" }
122
-
123
- arch_reports_true_for(:i386?, :intel?, :_32_bit?)
124
- end
125
- context "on powerpc" do
126
- let(:arch) { "powerpc" }
127
-
128
- arch_reports_true_for(:powerpc?, :_32_bit?)
129
- end
130
- context "on armhf" do
131
- let(:arch) { "armhf" }
132
-
133
- arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
134
- end
135
- context "on armv6l" do
136
- let(:arch) { "armv6l" }
137
-
138
- arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
139
- end
140
- context "on armv7l" do
141
- let(:arch) { "armv7l" }
142
-
143
- arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
144
- end
145
-
146
- context "on s390" do
147
- let(:arch) { "s390" }
148
-
149
- arch_reports_true_for(:s390?, :_32_bit?)
150
- end
151
- 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
+
21
+ def arch_reports_true_for(*args)
22
+ args.each do |method|
23
+ it "reports true for #{method}" do
24
+ expect(described_class.send(method, node)).to be true
25
+ end
26
+ end
27
+ (ARCH_HELPERS - args).each do |method|
28
+ it "reports false for #{method}" do
29
+ expect(described_class.send(method, node)).to be false
30
+ end
31
+ end
32
+ end
33
+
34
+ RSpec.describe ChefUtils::DSL::Architecture do
35
+ let(:node) { { "kernel" => { "machine" => arch } } }
36
+
37
+ ( HELPER_MODULES - [ described_class ] ).each do |klass|
38
+ it "does not have methods that collide with #{klass}" do
39
+ expect((klass.methods - Module.methods) & ARCH_HELPERS).to be_empty
40
+ end
41
+ end
42
+
43
+ ARCH_HELPERS.each do |helper|
44
+ it "has the #{helper} in the ChefUtils module" do
45
+ expect(ChefUtils).to respond_to(helper)
46
+ end
47
+ end
48
+
49
+ context "on x86_64" do
50
+ let(:arch) { "x86_64" }
51
+
52
+ arch_reports_true_for(:intel?, :_64_bit?)
53
+ end
54
+
55
+ context "on amd64" do
56
+ let(:arch) { "amd64" }
57
+
58
+ arch_reports_true_for(:intel?, :_64_bit?)
59
+ end
60
+ context "on ppc64" do
61
+ let(:arch) { "ppc64" }
62
+
63
+ arch_reports_true_for(:ppc64?, :_64_bit?)
64
+ end
65
+ context "on ppc64le" do
66
+ let(:arch) { "ppc64le" }
67
+
68
+ arch_reports_true_for(:ppc64le?, :_64_bit?)
69
+ end
70
+ context "on s390x" do
71
+ let(:arch) { "s390x" }
72
+
73
+ arch_reports_true_for(:s390x?, :_64_bit?)
74
+ end
75
+ context "on ia64" do
76
+ let(:arch) { "ia64" }
77
+
78
+ arch_reports_true_for(:_64_bit?)
79
+ end
80
+ context "on sparc64" do
81
+ let(:arch) { "sparc64" }
82
+
83
+ arch_reports_true_for(:_64_bit?)
84
+ end
85
+ context "on aarch64" do
86
+ let(:arch) { "aarch64" }
87
+
88
+ arch_reports_true_for(:_64_bit?, :arm?)
89
+ end
90
+ context "on arch64" do
91
+ let(:arch) { "arch64" }
92
+
93
+ arch_reports_true_for(:_64_bit?, :arm?)
94
+ end
95
+ context "on arm64" do
96
+ let(:arch) { "arm64" }
97
+
98
+ arch_reports_true_for(:_64_bit?, :arm?)
99
+ end
100
+ context "on sun4v" do
101
+ let(:arch) { "sun4v" }
102
+
103
+ arch_reports_true_for(:sparc?, :_64_bit?)
104
+ end
105
+ context "on sun4u" do
106
+ let(:arch) { "sun4u" }
107
+
108
+ arch_reports_true_for(:sparc?, :_64_bit?)
109
+ end
110
+ context "on i86pc" do
111
+ let(:arch) { "i86pc" }
112
+
113
+ arch_reports_true_for(:i386?, :intel?, :_32_bit?)
114
+ end
115
+ context "on i386" do
116
+ let(:arch) { "i386" }
117
+
118
+ arch_reports_true_for(:i386?, :intel?, :_32_bit?)
119
+ end
120
+ context "on i686" do
121
+ let(:arch) { "i686" }
122
+
123
+ arch_reports_true_for(:i386?, :intel?, :_32_bit?)
124
+ end
125
+ context "on powerpc" do
126
+ let(:arch) { "powerpc" }
127
+
128
+ arch_reports_true_for(:powerpc?, :_32_bit?)
129
+ end
130
+ context "on armhf" do
131
+ let(:arch) { "armhf" }
132
+
133
+ arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
134
+ end
135
+ context "on armv6l" do
136
+ let(:arch) { "armv6l" }
137
+
138
+ arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
139
+ end
140
+ context "on armv7l" do
141
+ let(:arch) { "armv7l" }
142
+
143
+ arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
144
+ end
145
+
146
+ context "on s390" do
147
+ let(:arch) { "s390" }
148
+
149
+ arch_reports_true_for(:s390?, :_32_bit?)
150
+ end
151
+ end
@@ -1,89 +1,93 @@
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 cloud_reports_true_for(*args, node:)
23
- args.each do |method|
24
- it "reports true for #{method}" do
25
- expect(described_class.send(method, node)).to be true
26
- end
27
- end
28
- (CLOUD_HELPERS - args).each do |method|
29
- it "reports false for #{method}" do
30
- expect(described_class.send(method, node)).to be false
31
- end
32
- end
33
- end
34
-
35
- RSpec.describe ChefUtils::DSL::Cloud do
36
- ( HELPER_MODULES - [ described_class ] ).each do |klass|
37
- it "does not have methods that collide with #{klass}" do
38
- expect((klass.methods - Module.methods) & CLOUD_HELPERS).to be_empty
39
- end
40
- end
41
-
42
- CLOUD_HELPERS.each do |helper|
43
- it "has the #{helper} in the ChefUtils module" do
44
- expect(ChefUtils).to respond_to(helper)
45
- end
46
- end
47
-
48
- context "on ec2" do
49
- cloud_reports_true_for(:cloud?, :ec2?, node: { "ec2" => {}, "cloud" => {} })
50
- end
51
-
52
- context "on gce" do
53
- cloud_reports_true_for(:cloud?, :gce?, node: { "gce" => {}, "cloud" => {} })
54
- end
55
-
56
- context "on rackspace" do
57
- cloud_reports_true_for(:cloud?, :rackspace?, node: { "rackspace" => {}, "cloud" => {} })
58
- end
59
-
60
- context "on eucalyptus" do
61
- cloud_reports_true_for(:cloud?, :eucalyptus?, :euca?, node: { "eucalyptus" => {}, "cloud" => {} })
62
- end
63
-
64
- context "on linode" do
65
- cloud_reports_true_for(:cloud?, :linode?, node: { "linode" => {}, "cloud" => {} })
66
- end
67
-
68
- context "on openstack" do
69
- cloud_reports_true_for(:cloud?, :openstack?, node: { "openstack" => {}, "cloud" => {} })
70
- end
71
-
72
- context "on azure" do
73
- cloud_reports_true_for(:cloud?, :azure?, node: { "azure" => {}, "cloud" => {} })
74
- end
75
-
76
- context "on digital_ocean" do
77
- cloud_reports_true_for(:cloud?, :digital_ocean?, :digitalocean?, node: { "digital_ocean" => {}, "cloud" => {} })
78
- end
79
-
80
- context "on softlayer" do
81
- cloud_reports_true_for(:cloud?, :softlayer?, node: { "softlayer" => {}, "cloud" => {} })
82
- end
83
-
84
- context "on virtualbox" do
85
- it "does not return true for cloud?" do
86
- expect(described_class.cloud?({ "virtualbox" => {}, "cloud" => nil })).to be false
87
- end
88
- end
89
- 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 cloud_reports_true_for(*args, node:)
23
+ args.each do |method|
24
+ it "reports true for #{method}" do
25
+ expect(described_class.send(method, node)).to be true
26
+ end
27
+ end
28
+ (CLOUD_HELPERS - args).each do |method|
29
+ it "reports false for #{method}" do
30
+ expect(described_class.send(method, node)).to be false
31
+ end
32
+ end
33
+ end
34
+
35
+ RSpec.describe ChefUtils::DSL::Cloud do
36
+ ( HELPER_MODULES - [ described_class ] ).each do |klass|
37
+ it "does not have methods that collide with #{klass}" do
38
+ expect((klass.methods - Module.methods) & CLOUD_HELPERS).to be_empty
39
+ end
40
+ end
41
+
42
+ CLOUD_HELPERS.each do |helper|
43
+ it "has the #{helper} in the ChefUtils module" do
44
+ expect(ChefUtils).to respond_to(helper)
45
+ end
46
+ end
47
+
48
+ context "on alibaba" do
49
+ cloud_reports_true_for(:cloud?, :alibaba?, node: { "alibaba" => {}, "cloud" => {} })
50
+ end
51
+
52
+ context "on ec2" do
53
+ cloud_reports_true_for(:cloud?, :ec2?, node: { "ec2" => {}, "cloud" => {} })
54
+ end
55
+
56
+ context "on gce" do
57
+ cloud_reports_true_for(:cloud?, :gce?, node: { "gce" => {}, "cloud" => {} })
58
+ end
59
+
60
+ context "on rackspace" do
61
+ cloud_reports_true_for(:cloud?, :rackspace?, node: { "rackspace" => {}, "cloud" => {} })
62
+ end
63
+
64
+ context "on eucalyptus" do
65
+ cloud_reports_true_for(:cloud?, :eucalyptus?, :euca?, node: { "eucalyptus" => {}, "cloud" => {} })
66
+ end
67
+
68
+ context "on linode" do
69
+ cloud_reports_true_for(:cloud?, :linode?, node: { "linode" => {}, "cloud" => {} })
70
+ end
71
+
72
+ context "on openstack" do
73
+ cloud_reports_true_for(:cloud?, :openstack?, node: { "openstack" => {}, "cloud" => {} })
74
+ end
75
+
76
+ context "on azure" do
77
+ cloud_reports_true_for(:cloud?, :azure?, node: { "azure" => {}, "cloud" => {} })
78
+ end
79
+
80
+ context "on digital_ocean" do
81
+ cloud_reports_true_for(:cloud?, :digital_ocean?, :digitalocean?, node: { "digital_ocean" => {}, "cloud" => {} })
82
+ end
83
+
84
+ context "on softlayer" do
85
+ cloud_reports_true_for(:cloud?, :softlayer?, node: { "softlayer" => {}, "cloud" => {} })
86
+ end
87
+
88
+ context "on virtualbox" do
89
+ it "does not return true for cloud?" do
90
+ expect(described_class.cloud?({ "virtualbox" => {}, "cloud" => nil })).to be false
91
+ end
92
+ end
93
+ end
@@ -1,34 +1,34 @@
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
-
21
- RSpec.describe ChefUtils do
22
- class ThingWithDSL
23
- extend ChefUtils
24
- end
25
-
26
- (OS_HELPERS + ARCH_HELPERS + PLATFORM_HELPERS + PLATFORM_FAMILY_HELPERS + INTROSPECTION_HELPERS).each do |helper|
27
- it "has the #{helper} in the ChefUtils module" do
28
- expect(ThingWithDSL).to respond_to(helper)
29
- end
30
- it "has the #{helper} class method in the ChefUtils module" do
31
- expect(ChefUtils).to respond_to(helper)
32
- end
33
- end
34
- 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
+
21
+ RSpec.describe ChefUtils do
22
+ class ThingWithDSL
23
+ extend ChefUtils
24
+ end
25
+
26
+ (OS_HELPERS + ARCH_HELPERS + PLATFORM_HELPERS + PLATFORM_FAMILY_HELPERS + INTROSPECTION_HELPERS).each do |helper|
27
+ it "has the #{helper} in the ChefUtils module" do
28
+ expect(ThingWithDSL).to respond_to(helper)
29
+ end
30
+ it "has the #{helper} class method in the ChefUtils module" do
31
+ expect(ChefUtils).to respond_to(helper)
32
+ end
33
+ end
34
+ end