chef-utils 15.7.32 → 15.11.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright 2010-2019, Chef Software Inc.
1
+ # Copyright:: Copyright (c) Chef Software Inc.
2
2
  # License:: Apache License, Version 2.0
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,5 +15,5 @@
15
15
 
16
16
  module ChefUtils
17
17
  CHEFUTILS_ROOT = File.expand_path("../..", __FILE__)
18
- VERSION = "15.7.32".freeze
18
+ VERSION = "15.11.8".freeze
19
19
  end
@@ -139,5 +139,11 @@ module ChefUtils
139
139
  end
140
140
  end
141
141
 
142
+ # Back-compat API for chef-sugar. The other APIs are preferable.
143
+ #
144
+ # @api private
145
+ def satisfies?(*constraints)
146
+ Gem::Requirement.new(*constraints).satisfied_by?(@parsed_version)
147
+ end
142
148
  end
143
149
  end
@@ -3,21 +3,25 @@ require "chef-utils"
3
3
  # FIXME: dynamically generate this for accuracy
4
4
  HELPER_MODULES = [
5
5
  ChefUtils::DSL::Architecture,
6
+ ChefUtils::DSL::Cloud,
6
7
  ChefUtils::DSL::Introspection,
7
8
  ChefUtils::DSL::OS,
8
9
  ChefUtils::DSL::PathSanity,
9
10
  ChefUtils::DSL::Platform,
10
11
  ChefUtils::DSL::PlatformFamily,
11
12
  ChefUtils::DSL::Service,
13
+ ChefUtils::DSL::Virtualization,
12
14
  ChefUtils::DSL::Which,
13
15
  ChefUtils::DSL::Windows,
14
16
  ].freeze
15
17
 
16
18
  ARCH_HELPERS = (ChefUtils::DSL::Architecture.methods - Module.methods).freeze
19
+ CLOUD_HELPERS = (ChefUtils::DSL::Cloud.methods - Module.methods).freeze
20
+ INTROSPECTION_HELPERS = (ChefUtils::DSL::Introspection.methods - Module.methods).freeze
17
21
  OS_HELPERS = (ChefUtils::DSL::OS.methods - Module.methods).freeze
18
- PLATFORM_HELPERS = (ChefUtils::DSL::Platform.methods - Module.methods).freeze
19
22
  PLATFORM_FAMILY_HELPERS = (ChefUtils::DSL::PlatformFamily.methods - Module.methods).freeze
20
- INTROSPECTION_HELPERS = (ChefUtils::DSL::Introspection.methods - Module.methods).freeze
23
+ PLATFORM_HELPERS = (ChefUtils::DSL::Platform.methods - Module.methods).freeze
24
+ VIRTUALIZATION_HELPERS = (ChefUtils::DSL::Virtualization.methods - Module.methods).freeze
21
25
  WINDOWS_HELPERS = (ChefUtils::DSL::Windows.methods - Module.methods).freeze
22
26
 
23
27
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -84,17 +84,17 @@ RSpec.describe ChefUtils::DSL::Architecture do
84
84
  context "on aarch64" do
85
85
  let(:arch) { "aarch64" }
86
86
 
87
- arch_reports_true_for(:_64_bit?)
87
+ arch_reports_true_for(:_64_bit?, :arm?)
88
88
  end
89
89
  context "on arch64" do
90
90
  let(:arch) { "arch64" }
91
91
 
92
- arch_reports_true_for(:_64_bit?)
92
+ arch_reports_true_for(:_64_bit?, :arm?)
93
93
  end
94
94
  context "on arm64" do
95
95
  let(:arch) { "arm64" }
96
96
 
97
- arch_reports_true_for(:_64_bit?)
97
+ arch_reports_true_for(:_64_bit?, :arm?)
98
98
  end
99
99
  context "on sun4v" do
100
100
  let(:arch) { "sun4v" }
@@ -129,8 +129,19 @@ RSpec.describe ChefUtils::DSL::Architecture do
129
129
  context "on armhf" do
130
130
  let(:arch) { "armhf" }
131
131
 
132
- arch_reports_true_for(:armhf?, :_32_bit?)
132
+ arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
133
+ end
134
+ context "on armv6l" do
135
+ let(:arch) { "armv6l" }
136
+
137
+ arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
138
+ end
139
+ context "on armv7l" do
140
+ let(:arch) { "armv7l" }
141
+
142
+ arch_reports_true_for(:armhf?, :_32_bit?, :arm?)
133
143
  end
144
+
134
145
  context "on s390" do
135
146
  let(:arch) { "s390" }
136
147
 
@@ -0,0 +1,88 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "fauxhai"
20
+
21
+ def cloud_reports_true_for(*args, node:)
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
+ (CLOUD_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::Cloud do
35
+ ( HELPER_MODULES - [ described_class ] ).each do |klass|
36
+ it "does not have methods that collide with #{klass}" do
37
+ expect((klass.methods - Module.methods) & CLOUD_HELPERS).to be_empty
38
+ end
39
+ end
40
+
41
+ CLOUD_HELPERS.each do |helper|
42
+ it "has the #{helper} in the ChefUtils module" do
43
+ expect(ChefUtils).to respond_to(helper)
44
+ end
45
+ end
46
+
47
+ context "on ec2" do
48
+ cloud_reports_true_for(:cloud?, :ec2?, node: { "ec2" => {}, "cloud" => {} })
49
+ end
50
+
51
+ context "on gce" do
52
+ cloud_reports_true_for(:cloud?, :gce?, node: { "gce" => {}, "cloud" => {} })
53
+ end
54
+
55
+ context "on rackspace" do
56
+ cloud_reports_true_for(:cloud?, :rackspace?, node: { "rackspace" => {}, "cloud" => {} })
57
+ end
58
+
59
+ context "on eucalyptus" do
60
+ cloud_reports_true_for(:cloud?, :eucalyptus?, :euca?, node: { "eucalyptus" => {}, "cloud" => {} })
61
+ end
62
+
63
+ context "on linode" do
64
+ cloud_reports_true_for(:cloud?, :linode?, node: { "linode" => {}, "cloud" => {} })
65
+ end
66
+
67
+ context "on openstack" do
68
+ cloud_reports_true_for(:cloud?, :openstack?, node: { "openstack" => {}, "cloud" => {} })
69
+ end
70
+
71
+ context "on azure" do
72
+ cloud_reports_true_for(:cloud?, :azure?, node: { "azure" => {}, "cloud" => {} })
73
+ end
74
+
75
+ context "on digital_ocean" do
76
+ cloud_reports_true_for(:cloud?, :digital_ocean?, :digitalocean?, node: { "digital_ocean" => {}, "cloud" => {} })
77
+ end
78
+
79
+ context "on softlayer" do
80
+ cloud_reports_true_for(:cloud?, :softlayer?, node: { "softlayer" => {}, "cloud" => {} })
81
+ end
82
+
83
+ context "on virtualbox" do
84
+ it "does not return true for cloud?" do
85
+ expect(described_class.cloud?({ "virtualbox" => {}, "cloud" => nil })).to be false
86
+ end
87
+ end
88
+ end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -165,4 +165,23 @@ RSpec.describe ChefUtils::DSL::Introspection do
165
165
  end
166
166
  end
167
167
  end
168
+
169
+ context "#include_recipe?" do
170
+ it "is true when the recipe has been seen by the node" do
171
+ expect(node).to receive(:recipe?).with("myrecipe").and_return(true)
172
+ expect(ChefUtils.include_recipe?("myrecipe", node)).to be true
173
+ end
174
+ it "is false when the recipe has not been seen by the node" do
175
+ expect(node).to receive(:recipe?).with("myrecipe").and_return(false)
176
+ expect(ChefUtils.include_recipe?("myrecipe", node)).to be false
177
+ end
178
+ it "the alias is true when the recipe has been seen by the node" do
179
+ expect(node).to receive(:recipe?).with("myrecipe").and_return(true)
180
+ expect(ChefUtils.includes_recipe?("myrecipe", node)).to be true
181
+ end
182
+ it "the alias is false when the recipe has not been seen by the node" do
183
+ expect(node).to receive(:recipe?).with("myrecipe").and_return(false)
184
+ expect(ChefUtils.includes_recipe?("myrecipe", node)).to be false
185
+ end
186
+ end
168
187
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -0,0 +1,74 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "fauxhai"
20
+
21
+ def virtualization_reports_true_for(*args, node:)
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
+ (VIRTUALIZATION_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::Virtualization do
35
+ ( HELPER_MODULES - [ described_class ] ).each do |klass|
36
+ it "does not have methods that collide with #{klass}" do
37
+ expect((klass.methods - Module.methods) & VIRTUALIZATION_HELPERS).to be_empty
38
+ end
39
+ end
40
+
41
+ VIRTUALIZATION_HELPERS.each do |helper|
42
+ it "has the #{helper} in the ChefUtils module" do
43
+ expect(ChefUtils).to respond_to(helper)
44
+ end
45
+ end
46
+
47
+ context "on kvm" do
48
+ virtualization_reports_true_for(:guest?, :virtual?, :kvm?, node: { "virtualization" => { "system" => "kvm", "role" => "guest" } })
49
+ virtualization_reports_true_for(:hypervisor?, :physical?, :kvm_host?, node: { "virtualization" => { "system" => "kvm", "role" => "host" } })
50
+ end
51
+ context "on lxc" do
52
+ virtualization_reports_true_for(:guest?, :virtual?, :lxc?, node: { "virtualization" => { "system" => "lxc", "role" => "guest" } })
53
+ virtualization_reports_true_for(:hypervisor?, :physical?, :lxc_host?, node: { "virtualization" => { "system" => "lxc", "role" => "host" } })
54
+ end
55
+ context "on parallels" do
56
+ virtualization_reports_true_for(:guest?, :virtual?, :parallels?, node: { "virtualization" => { "system" => "parallels", "role" => "guest" } })
57
+ virtualization_reports_true_for(:hypervisor?, :physical?, :parallels_host?, node: { "virtualization" => { "system" => "parallels", "role" => "host" } })
58
+ end
59
+ context "on virtualbox" do
60
+ virtualization_reports_true_for(:guest?, :virtual?, :virtualbox?, :vbox?, node: { "virtualization" => { "system" => "vbox", "role" => "guest" } })
61
+ virtualization_reports_true_for(:hypervisor?, :physical?, :vbox_host?, node: { "virtualization" => { "system" => "vbox", "role" => "host" } })
62
+ end
63
+ context "on vmware" do
64
+ virtualization_reports_true_for(:guest?, :virtual?, :vmware?, node: { "virtualization" => { "system" => "vmware", "role" => "guest" } })
65
+ virtualization_reports_true_for(:hypervisor?, :physical?, :vmware_host?, node: { "virtualization" => { "system" => "vmware", "role" => "host" } })
66
+ end
67
+ context "on openvz" do
68
+ virtualization_reports_true_for(:guest?, :virtual?, :openvz?, node: { "virtualization" => { "system" => "openvz", "role" => "guest" } })
69
+ virtualization_reports_true_for(:hypervisor?, :physical?, :openvz_host?, node: { "virtualization" => { "system" => "openvz", "role" => "host" } })
70
+ end
71
+ context "on metal which is not a virt host" do
72
+ virtualization_reports_true_for(:physical?, node: {} )
73
+ end
74
+ end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018-2019, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2020, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,13 +17,15 @@
17
17
 
18
18
  require "spec_helper"
19
19
 
20
+ WINDOWS_BOOL_HELPERS = %i{windows_server_core? windows_server? windows_workstation?}.freeze
21
+
20
22
  def windows_reports_true_for(*args)
21
23
  args.each do |method|
22
24
  it "reports true for #{method}" do
23
25
  expect(described_class.send(method, node)).to be true
24
26
  end
25
27
  end
26
- (WINDOWS_HELPERS - args).each do |method|
28
+ (WINDOWS_BOOL_HELPERS - args).each do |method|
27
29
  it "reports false for #{method}" do
28
30
  expect(described_class.send(method, node)).to be false
29
31
  end
@@ -43,21 +45,39 @@ RSpec.describe ChefUtils::DSL::Windows do
43
45
  end
44
46
  end
45
47
 
46
- context "on Windows Server Core" do
47
- let(:node) { { "kernel" => { "server_core" => true } } }
48
+ context "windows boolean helpers" do
49
+ context "on Windows Server Core" do
50
+ let(:node) { { "kernel" => { "server_core" => true } } }
48
51
 
49
- windows_reports_true_for(:windows_server_core?)
50
- end
52
+ windows_reports_true_for(:windows_server_core?)
53
+ end
54
+
55
+ context "on Windows Workstation" do
56
+ let(:node) { { "kernel" => { "product_type" => "Workstation" } } }
57
+
58
+ windows_reports_true_for(:windows_workstation?)
59
+ end
51
60
 
52
- context "on Windows Workstation" do
53
- let(:node) { { "kernel" => { "product_type" => "Workstation" } } }
61
+ context "on Windows Server" do
62
+ let(:node) { { "kernel" => { "product_type" => "Server" } } }
54
63
 
55
- windows_reports_true_for(:windows_workstation?)
64
+ windows_reports_true_for(:windows_server?)
65
+ end
56
66
  end
57
67
 
58
- context "on Windows Server" do
59
- let(:node) { { "kernel" => { "product_type" => "Server" } } }
68
+ context "#windows_nt_version on Windows Server 2012 R2" do
69
+ let(:node) { { "os_version" => "6.3.9600" } }
70
+ it "it returns a ChefUtils::VersionString object with 6.3.9600" do
71
+ expect(described_class.send(:windows_nt_version, node)).to eq "6.3.9600"
72
+ expect(described_class.send(:windows_nt_version, node)).to be_a_kind_of ChefUtils::VersionString
73
+ end
74
+ end
60
75
 
61
- windows_reports_true_for(:windows_server?)
76
+ context "#powershell_version on Windows Server 2012 R2" do
77
+ let(:node) { { "languages" => { "powershell" => { "version" => "4.0" } } } }
78
+ it "it returns a ChefUtils::VersionString object with 4.0" do
79
+ expect(described_class.send(:powershell_version, node)).to eq "4.0"
80
+ expect(described_class.send(:powershell_version, node)).to be_a_kind_of ChefUtils::VersionString
81
+ end
62
82
  end
63
83
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Matthew Kent (<mkent@magoazul.com>)
3
- # Copyright:: Copyright 2011-2016, Chef Software Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.7.32
4
+ version: 15.11.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-05-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -22,13 +22,16 @@ files:
22
22
  - chef-utils.gemspec
23
23
  - lib/chef-utils.rb
24
24
  - lib/chef-utils/dsl/architecture.rb
25
+ - lib/chef-utils/dsl/cloud.rb
25
26
  - lib/chef-utils/dsl/introspection.rb
26
27
  - lib/chef-utils/dsl/os.rb
27
28
  - lib/chef-utils/dsl/path_sanity.rb
28
29
  - lib/chef-utils/dsl/platform.rb
29
30
  - lib/chef-utils/dsl/platform_family.rb
31
+ - lib/chef-utils/dsl/platform_version.rb
30
32
  - lib/chef-utils/dsl/service.rb
31
33
  - lib/chef-utils/dsl/train_helpers.rb
34
+ - lib/chef-utils/dsl/virtualization.rb
32
35
  - lib/chef-utils/dsl/which.rb
33
36
  - lib/chef-utils/dsl/windows.rb
34
37
  - lib/chef-utils/internal.rb
@@ -37,6 +40,7 @@ files:
37
40
  - lib/chef-utils/version_string.rb
38
41
  - spec/spec_helper.rb
39
42
  - spec/unit/dsl/architecture_spec.rb
43
+ - spec/unit/dsl/cloud_spec.rb
40
44
  - spec/unit/dsl/dsl_spec.rb
41
45
  - spec/unit/dsl/introspection_spec.rb
42
46
  - spec/unit/dsl/os_spec.rb
@@ -44,6 +48,7 @@ files:
44
48
  - spec/unit/dsl/platform_family_spec.rb
45
49
  - spec/unit/dsl/platform_spec.rb
46
50
  - spec/unit/dsl/service_spec.rb
51
+ - spec/unit/dsl/virtualization_spec.rb
47
52
  - spec/unit/dsl/which_spec.rb
48
53
  - spec/unit/dsl/windows_spec.rb
49
54
  - spec/unit/mash_spec.rb