chef-utils 15.6.10 → 15.7.30
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/lib/chef-utils/dsl/architecture.rb +2 -2
- data/lib/chef-utils/dsl/introspection.rb +11 -1
- data/lib/chef-utils/dsl/platform_family.rb +19 -21
- data/lib/chef-utils/dsl/windows.rb +58 -0
- data/lib/chef-utils/version.rb +1 -1
- data/lib/chef-utils/version_string.rb +143 -0
- data/lib/chef-utils.rb +3 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/dsl/windows_spec.rb +63 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06ac46e984418a061b58f7db952a50e27569b5919c3f7dce6ffac6d45ee55fb5
|
4
|
+
data.tar.gz: 277f88617c5f70967f6a09e5c0da820d71fb8b59d69ee6ad72458ff3eb40b63c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1618de8f21fe43d920322b4b9eb6527a7948da94391bffa619e8196ed84a41c2483cb4ef3d680390256b32d3b93646ed1dbffda31fa2c7e1fd5e267763245e6e
|
7
|
+
data.tar.gz: 9cc7276e5eaecae036f9d00136a1302d31c33e309bb2f47db593168a2b7881f63495d0e8c35ee82690b2f17a870ec8ea3559fb6d074740f793545024649914b6
|
@@ -63,7 +63,7 @@ module ChefUtils
|
|
63
63
|
%w{sun4u sun4v}.include?(node["kernel"]["machine"])
|
64
64
|
end
|
65
65
|
|
66
|
-
# Determine if the current architecture is
|
66
|
+
# Determine if the current architecture is PowerPC 64bit Big Endian
|
67
67
|
#
|
68
68
|
# @return [Boolean]
|
69
69
|
#
|
@@ -71,7 +71,7 @@ module ChefUtils
|
|
71
71
|
%w{ppc64}.include?(node["kernel"]["machine"])
|
72
72
|
end
|
73
73
|
|
74
|
-
# Determine if the current architecture is
|
74
|
+
# Determine if the current architecture is PowerPC 64bit Little Endian
|
75
75
|
#
|
76
76
|
# @return [Boolean]
|
77
77
|
#
|
@@ -28,7 +28,7 @@ module ChefUtils
|
|
28
28
|
module Introspection
|
29
29
|
include TrainHelpers
|
30
30
|
|
31
|
-
#
|
31
|
+
# Determine if the node is a docker container.
|
32
32
|
#
|
33
33
|
# @param [Chef::Node] node
|
34
34
|
#
|
@@ -40,6 +40,8 @@ module ChefUtils
|
|
40
40
|
!!(node && node.read("virtualization", "systems", "docker") == "guest")
|
41
41
|
end
|
42
42
|
|
43
|
+
# Determine if the node uses the systemd init system.
|
44
|
+
#
|
43
45
|
# @param [Chef::Node] node
|
44
46
|
#
|
45
47
|
# @return [Boolean]
|
@@ -48,6 +50,8 @@ module ChefUtils
|
|
48
50
|
file_exist?("/proc/1/comm") && file_open("/proc/1/comm").gets.chomp == "systemd"
|
49
51
|
end
|
50
52
|
|
53
|
+
# Determine if the node is running in Test Kitchen.
|
54
|
+
#
|
51
55
|
# @param [Chef::Node] node
|
52
56
|
#
|
53
57
|
# @return [Boolean]
|
@@ -56,6 +60,8 @@ module ChefUtils
|
|
56
60
|
ENV.key?("TEST_KITCHEN")
|
57
61
|
end
|
58
62
|
|
63
|
+
# Determine if the node is running in a CI system that sets the CI env var.
|
64
|
+
#
|
59
65
|
# @param [Chef::Node] node
|
60
66
|
#
|
61
67
|
# @return [Boolean]
|
@@ -64,6 +70,8 @@ module ChefUtils
|
|
64
70
|
ENV.key?("CI")
|
65
71
|
end
|
66
72
|
|
73
|
+
# Determine if the a systemd service unit is present on the system.
|
74
|
+
#
|
67
75
|
# @param [String] svc_name
|
68
76
|
#
|
69
77
|
# @return [Boolean]
|
@@ -76,6 +84,8 @@ module ChefUtils
|
|
76
84
|
end
|
77
85
|
end
|
78
86
|
|
87
|
+
# Determine if the a systemd unit of any type is present on the system.
|
88
|
+
#
|
79
89
|
# @param [String] svc_name
|
80
90
|
#
|
81
91
|
# @return [Boolean]
|
@@ -22,7 +22,7 @@ module ChefUtils
|
|
22
22
|
module PlatformFamily
|
23
23
|
include Internal
|
24
24
|
|
25
|
-
# Determine if the current node is arch
|
25
|
+
# Determine if the current node is a member of the 'arch' family.
|
26
26
|
#
|
27
27
|
# @param [Chef::Node] node
|
28
28
|
#
|
@@ -34,7 +34,7 @@ module ChefUtils
|
|
34
34
|
# chef-sugar backcompat methods
|
35
35
|
alias_method :arch_linux?, :arch?
|
36
36
|
|
37
|
-
# Determine if the current node is aix
|
37
|
+
# Determine if the current node is a member of the 'aix' platform family.
|
38
38
|
#
|
39
39
|
# @param [Chef::Node] node
|
40
40
|
#
|
@@ -44,7 +44,7 @@ module ChefUtils
|
|
44
44
|
node["platform_family"] == "aix"
|
45
45
|
end
|
46
46
|
|
47
|
-
# Determine if the current node is a member of the debian family.
|
47
|
+
# Determine if the current node is a member of the 'debian' platform family (Debian, Ubuntu and derivatives).
|
48
48
|
#
|
49
49
|
# @param [Chef::Node] node
|
50
50
|
#
|
@@ -54,7 +54,7 @@ module ChefUtils
|
|
54
54
|
node["platform_family"] == "debian"
|
55
55
|
end
|
56
56
|
|
57
|
-
# Determine if the current node is a member of the fedora family.
|
57
|
+
# Determine if the current node is a member of the 'fedora' platform family (Fedora and Arist).
|
58
58
|
#
|
59
59
|
# @param [Chef::Node] node
|
60
60
|
#
|
@@ -64,7 +64,7 @@ module ChefUtils
|
|
64
64
|
node["platform_family"] == "fedora"
|
65
65
|
end
|
66
66
|
|
67
|
-
# Determine if the current node is a member of the
|
67
|
+
# Determine if the current node is a member of the 'mac_os_x' platform family.
|
68
68
|
#
|
69
69
|
# @param [Chef::Node] node
|
70
70
|
#
|
@@ -77,9 +77,7 @@ module ChefUtils
|
|
77
77
|
alias_method :mac?, :macos?
|
78
78
|
alias_method :mac_os_x?, :macos?
|
79
79
|
|
80
|
-
# Determine if the current node is a member of the rhel family (
|
81
|
-
#
|
82
|
-
# The platform_versions for these operating systems must match (rhel7 == centos7 == oracle7 == scientfic7), modulo additional packages
|
80
|
+
# Determine if the current node is a member of the 'rhel' platform family (Red Hat, CentOS, Oracle or Scientific Linux, but NOT Amazon Linux or Fedora).
|
83
81
|
#
|
84
82
|
# @param [Chef::Node] node
|
85
83
|
#
|
@@ -90,7 +88,7 @@ module ChefUtils
|
|
90
88
|
end
|
91
89
|
alias_method :el?, :rhel?
|
92
90
|
|
93
|
-
# Determine if the current node is a rhel6 compatible build (
|
91
|
+
# Determine if the current node is a rhel6 compatible build (Red Hat, CentOS, Oracle or Scientific Linux)
|
94
92
|
#
|
95
93
|
# @param [Chef::Node] node
|
96
94
|
#
|
@@ -100,7 +98,7 @@ module ChefUtils
|
|
100
98
|
node["platform_family"] == "rhel" && node["platform_version"].to_f >= 6.0 && node["platform_version"].to_f < 7.0
|
101
99
|
end
|
102
100
|
|
103
|
-
# Determine if the current node is a rhel7 compatible build (
|
101
|
+
# Determine if the current node is a rhel7 compatible build (Red Hat, CentOS, Oracle or Scientific Linux)
|
104
102
|
#
|
105
103
|
# @param [Chef::Node] node
|
106
104
|
#
|
@@ -110,7 +108,7 @@ module ChefUtils
|
|
110
108
|
node["platform_family"] == "rhel" && node["platform_version"].to_f >= 7.0 && node["platform_version"].to_f < 8.0
|
111
109
|
end
|
112
110
|
|
113
|
-
# Determine if the current node is a rhel8 compatible build (
|
111
|
+
# Determine if the current node is a rhel8 compatible build (Red Hat, CentOS, Oracle or Scientific Linux)
|
114
112
|
#
|
115
113
|
# @param [Chef::Node] node
|
116
114
|
#
|
@@ -120,7 +118,7 @@ module ChefUtils
|
|
120
118
|
node["platform_family"] == "rhel" && node["platform_version"].to_f >= 8.0 && node["platform_version"].to_f < 9.0
|
121
119
|
end
|
122
120
|
|
123
|
-
# Determine if the current node is a member of the amazon family.
|
121
|
+
# Determine if the current node is a member of the 'amazon' platform family.
|
124
122
|
#
|
125
123
|
# @param [Chef::Node] node
|
126
124
|
#
|
@@ -131,7 +129,7 @@ module ChefUtils
|
|
131
129
|
end
|
132
130
|
alias_method :amazon_linux?, :amazon?
|
133
131
|
|
134
|
-
# Determine if the current node is solaris2
|
132
|
+
# Determine if the current node is a member of the 'solaris2' platform family.
|
135
133
|
#
|
136
134
|
# @param [Chef::Node] node
|
137
135
|
#
|
@@ -143,7 +141,7 @@ module ChefUtils
|
|
143
141
|
# chef-sugar backcompat methods
|
144
142
|
alias_method :solaris?, :solaris2?
|
145
143
|
|
146
|
-
# Determine if the current node is smartos
|
144
|
+
# Determine if the current node is a member of the 'smartos' platform family.
|
147
145
|
#
|
148
146
|
# @param [Chef::Node] node
|
149
147
|
#
|
@@ -153,7 +151,7 @@ module ChefUtils
|
|
153
151
|
node["platform_family"] == "smartos"
|
154
152
|
end
|
155
153
|
|
156
|
-
# Determine if the current node is a member of the suse family.
|
154
|
+
# Determine if the current node is a member of the 'suse' platform family (openSUSE, SLES, and SLED).
|
157
155
|
#
|
158
156
|
# @param [Chef::Node] node
|
159
157
|
#
|
@@ -163,7 +161,7 @@ module ChefUtils
|
|
163
161
|
node["platform_family"] == "suse"
|
164
162
|
end
|
165
163
|
|
166
|
-
# Determine if the current node is a member of the gentoo family.
|
164
|
+
# Determine if the current node is a member of the 'gentoo' platform family.
|
167
165
|
#
|
168
166
|
# @param [Chef::Node] node
|
169
167
|
#
|
@@ -173,7 +171,7 @@ module ChefUtils
|
|
173
171
|
node["platform_family"] == "gentoo"
|
174
172
|
end
|
175
173
|
|
176
|
-
# Determine if the current node is freebsd
|
174
|
+
# Determine if the current node is a member of the 'freebsd' platform family.
|
177
175
|
#
|
178
176
|
# @param [Chef::Node] node
|
179
177
|
#
|
@@ -183,7 +181,7 @@ module ChefUtils
|
|
183
181
|
node["platform_family"] == "freebsd"
|
184
182
|
end
|
185
183
|
|
186
|
-
# Determine if the current node is openbsd
|
184
|
+
# Determine if the current node is a member of the 'openbsd' platform family.
|
187
185
|
#
|
188
186
|
# @param [Chef::Node] node
|
189
187
|
#
|
@@ -193,7 +191,7 @@ module ChefUtils
|
|
193
191
|
node["platform_family"] == "openbsd"
|
194
192
|
end
|
195
193
|
|
196
|
-
# Determine if the current node is netbsd
|
194
|
+
# Determine if the current node is a member of the 'netbsd' platform family.
|
197
195
|
#
|
198
196
|
# @param [Chef::Node] node
|
199
197
|
#
|
@@ -203,7 +201,7 @@ module ChefUtils
|
|
203
201
|
node["platform_family"] == "netbsd"
|
204
202
|
end
|
205
203
|
|
206
|
-
# Determine if the current node is dragonflybsd
|
204
|
+
# Determine if the current node is a member of the 'dragonflybsd' platform family.
|
207
205
|
#
|
208
206
|
# @param [Chef::Node] node
|
209
207
|
#
|
@@ -213,7 +211,7 @@ module ChefUtils
|
|
213
211
|
node["platform_family"] == "dragonflybsd"
|
214
212
|
end
|
215
213
|
|
216
|
-
# Determine if the current node is a member of the windows family.
|
214
|
+
# Determine if the current node is a member of the 'windows' platform family.
|
217
215
|
#
|
218
216
|
# @param [Chef::Node] node
|
219
217
|
#
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2020, 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_relative "../internal"
|
19
|
+
|
20
|
+
module ChefUtils
|
21
|
+
module DSL
|
22
|
+
module Windows
|
23
|
+
include Internal
|
24
|
+
|
25
|
+
# Determine if the current node is Windows Server Core.
|
26
|
+
#
|
27
|
+
# @param [Chef::Node] node
|
28
|
+
#
|
29
|
+
# @return [Boolean]
|
30
|
+
#
|
31
|
+
def windows_server_core?(node = __getnode)
|
32
|
+
node["kernel"]["server_core"] == true
|
33
|
+
end
|
34
|
+
|
35
|
+
# Determine if the current node is Windows Workstation
|
36
|
+
#
|
37
|
+
# @param [Chef::Node] node
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
#
|
41
|
+
def windows_workstation?(node = __getnode)
|
42
|
+
node["kernel"]["product_type"] == "Workstation"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Determine if the current node is Windows Server
|
46
|
+
#
|
47
|
+
# @param [Chef::Node] node
|
48
|
+
#
|
49
|
+
# @return [Boolean]
|
50
|
+
#
|
51
|
+
def windows_server?(node = __getnode)
|
52
|
+
node["kernel"]["product_type"] == "Server"
|
53
|
+
end
|
54
|
+
|
55
|
+
extend self
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/chef-utils/version.rb
CHANGED
@@ -0,0 +1,143 @@
|
|
1
|
+
# Copyright:: Copyright 2017, Noah Kantrowitz
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module ChefUtils
|
17
|
+
# String-like object for version strings.
|
18
|
+
#
|
19
|
+
# @since 13.2
|
20
|
+
# @api internal
|
21
|
+
class VersionString < String
|
22
|
+
# Parsed version object for the string.
|
23
|
+
# @return [Gem::Version]
|
24
|
+
attr_reader :parsed_version
|
25
|
+
|
26
|
+
# Create a new VersionString from an input String.
|
27
|
+
#
|
28
|
+
# @param val [String] Version string to parse.
|
29
|
+
def initialize(val)
|
30
|
+
super
|
31
|
+
@parsed_version = ::Gem::Version.create(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @!group Compat wrappers for String
|
35
|
+
|
36
|
+
# Compat wrapper for + to behave like a normal String.
|
37
|
+
#
|
38
|
+
# @param other [String]
|
39
|
+
# @return [String]
|
40
|
+
def +(other)
|
41
|
+
to_s + other
|
42
|
+
end
|
43
|
+
|
44
|
+
# Compat wrapper for * to behave like a normal String.
|
45
|
+
#
|
46
|
+
# @param other [Integer]
|
47
|
+
# @return [String]
|
48
|
+
def *(other)
|
49
|
+
to_s * other
|
50
|
+
end
|
51
|
+
|
52
|
+
# @!group Comparison operators
|
53
|
+
|
54
|
+
# Compare a VersionString to an object. If compared to another VersionString
|
55
|
+
# then sort like `Gem::Version`, otherwise try to treat the other object as
|
56
|
+
# a version but fall back to normal string comparison.
|
57
|
+
#
|
58
|
+
# @param other [Object]
|
59
|
+
# @return [Integer]
|
60
|
+
def <=>(other)
|
61
|
+
other_ver = case other
|
62
|
+
when VersionString
|
63
|
+
other.parsed_version
|
64
|
+
else
|
65
|
+
begin
|
66
|
+
Gem::Version.create(other.to_s)
|
67
|
+
rescue ArgumentError
|
68
|
+
# Comparing to a string that isn't a version.
|
69
|
+
return super
|
70
|
+
end
|
71
|
+
end
|
72
|
+
parsed_version <=> other_ver
|
73
|
+
end
|
74
|
+
|
75
|
+
# Compat wrapper for == based on <=>.
|
76
|
+
#
|
77
|
+
# @param other [Object]
|
78
|
+
# @return [Boolean]
|
79
|
+
def ==(other)
|
80
|
+
(self <=> other) == 0
|
81
|
+
end
|
82
|
+
|
83
|
+
# Compat wrapper for != based on <=>.
|
84
|
+
#
|
85
|
+
# @param other [Object]
|
86
|
+
# @return [Boolean]
|
87
|
+
def !=(other)
|
88
|
+
(self <=> other) != 0
|
89
|
+
end
|
90
|
+
|
91
|
+
# Compat wrapper for < based on <=>.
|
92
|
+
#
|
93
|
+
# @param other [Object]
|
94
|
+
# @return [Boolean]
|
95
|
+
def <(other)
|
96
|
+
(self <=> other) < 0
|
97
|
+
end
|
98
|
+
|
99
|
+
# Compat wrapper for <= based on <=>.
|
100
|
+
#
|
101
|
+
# @param other [Object]
|
102
|
+
# @return [Boolean]
|
103
|
+
def <=(other)
|
104
|
+
(self <=> other) < 1
|
105
|
+
end
|
106
|
+
|
107
|
+
# Compat wrapper for > based on <=>.
|
108
|
+
#
|
109
|
+
# @param other [Object]
|
110
|
+
# @return [Boolean]
|
111
|
+
def >(other)
|
112
|
+
(self <=> other) > 0
|
113
|
+
end
|
114
|
+
|
115
|
+
# Compat wrapper for >= based on <=>.
|
116
|
+
#
|
117
|
+
# @param other [Object]
|
118
|
+
# @return [Boolean]
|
119
|
+
def >=(other)
|
120
|
+
(self <=> other) > -1
|
121
|
+
end
|
122
|
+
|
123
|
+
# @!group Matching operators
|
124
|
+
|
125
|
+
# Matching operator to support checking against a requirement string.
|
126
|
+
#
|
127
|
+
# @param other [Regexp, String]
|
128
|
+
# @return [Boolean]
|
129
|
+
# @example Match against a Regexp
|
130
|
+
# ChefUtils::VersionString.new('1.0.0') =~ /^1/
|
131
|
+
# @example Match against a requirement
|
132
|
+
# ChefUtils::VersionString.new('1.0.0') =~ '~> 1.0'
|
133
|
+
def =~(other)
|
134
|
+
case other
|
135
|
+
when Regexp
|
136
|
+
super
|
137
|
+
else
|
138
|
+
Gem::Requirement.create(other) =~ parsed_version
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
data/lib/chef-utils.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright 2015-
|
2
|
+
# Copyright:: Copyright 2015-2020, 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");
|
@@ -24,6 +24,7 @@ require_relative "chef-utils/dsl/platform_family"
|
|
24
24
|
require_relative "chef-utils/dsl/service"
|
25
25
|
require_relative "chef-utils/dsl/train_helpers"
|
26
26
|
require_relative "chef-utils/dsl/which"
|
27
|
+
require_relative "chef-utils/dsl/windows"
|
27
28
|
require_relative "chef-utils/mash"
|
28
29
|
|
29
30
|
# This is the Chef Infra Client DSL, not everytihng needs to go in here
|
@@ -33,6 +34,7 @@ module ChefUtils
|
|
33
34
|
include ChefUtils::DSL::PlatformFamily
|
34
35
|
include ChefUtils::DSL::Platform
|
35
36
|
include ChefUtils::DSL::Introspection
|
37
|
+
include ChefUtils::DSL::Windows
|
36
38
|
# FIXME: include ChefUtils::DSL::Which in Chef 16.0
|
37
39
|
# FIXME: include ChefUtils::DSL::PathSanity in Chef 16.0
|
38
40
|
# FIXME: include ChefUtils::DSL::TrainHelpers in Chef 16.0
|
data/spec/spec_helper.rb
CHANGED
@@ -10,6 +10,7 @@ HELPER_MODULES = [
|
|
10
10
|
ChefUtils::DSL::PlatformFamily,
|
11
11
|
ChefUtils::DSL::Service,
|
12
12
|
ChefUtils::DSL::Which,
|
13
|
+
ChefUtils::DSL::Windows,
|
13
14
|
].freeze
|
14
15
|
|
15
16
|
ARCH_HELPERS = (ChefUtils::DSL::Architecture.methods - Module.methods).freeze
|
@@ -17,6 +18,7 @@ OS_HELPERS = (ChefUtils::DSL::OS.methods - Module.methods).freeze
|
|
17
18
|
PLATFORM_HELPERS = (ChefUtils::DSL::Platform.methods - Module.methods).freeze
|
18
19
|
PLATFORM_FAMILY_HELPERS = (ChefUtils::DSL::PlatformFamily.methods - Module.methods).freeze
|
19
20
|
INTROSPECTION_HELPERS = (ChefUtils::DSL::Introspection.methods - Module.methods).freeze
|
21
|
+
WINDOWS_HELPERS = (ChefUtils::DSL::Windows.methods - Module.methods).freeze
|
20
22
|
|
21
23
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
22
24
|
RSpec.configure do |config|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2020, 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
|
+
|
20
|
+
def windows_reports_true_for(*args)
|
21
|
+
args.each do |method|
|
22
|
+
it "reports true for #{method}" do
|
23
|
+
expect(described_class.send(method, node)).to be true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
(WINDOWS_HELPERS - args).each do |method|
|
27
|
+
it "reports false for #{method}" do
|
28
|
+
expect(described_class.send(method, node)).to be false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
RSpec.describe ChefUtils::DSL::Windows do
|
34
|
+
( HELPER_MODULES - [ described_class ] ).each do |klass|
|
35
|
+
it "does not have methods that collide with #{klass}" do
|
36
|
+
expect((klass.methods - Module.methods) & WINDOWS_HELPERS).to be_empty
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
WINDOWS_HELPERS.each do |helper|
|
41
|
+
it "has the #{helper} in the ChefUtils module" do
|
42
|
+
expect(ChefUtils).to respond_to(helper)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "on Windows Server Core" do
|
47
|
+
let(:node) { { "kernel" => { "server_core" => true } } }
|
48
|
+
|
49
|
+
windows_reports_true_for(:windows_server_core?)
|
50
|
+
end
|
51
|
+
|
52
|
+
context "on Windows Workstation" do
|
53
|
+
let(:node) { { "kernel" => { "product_type" => "Workstation" } } }
|
54
|
+
|
55
|
+
windows_reports_true_for(:windows_workstation?)
|
56
|
+
end
|
57
|
+
|
58
|
+
context "on Windows Server" do
|
59
|
+
let(:node) { { "kernel" => { "product_type" => "Server" } } }
|
60
|
+
|
61
|
+
windows_reports_true_for(:windows_server?)
|
62
|
+
end
|
63
|
+
end
|
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.
|
4
|
+
version: 15.7.30
|
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:
|
11
|
+
date: 2020-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -30,9 +30,11 @@ files:
|
|
30
30
|
- lib/chef-utils/dsl/service.rb
|
31
31
|
- lib/chef-utils/dsl/train_helpers.rb
|
32
32
|
- lib/chef-utils/dsl/which.rb
|
33
|
+
- lib/chef-utils/dsl/windows.rb
|
33
34
|
- lib/chef-utils/internal.rb
|
34
35
|
- lib/chef-utils/mash.rb
|
35
36
|
- lib/chef-utils/version.rb
|
37
|
+
- lib/chef-utils/version_string.rb
|
36
38
|
- spec/spec_helper.rb
|
37
39
|
- spec/unit/dsl/architecture_spec.rb
|
38
40
|
- spec/unit/dsl/dsl_spec.rb
|
@@ -43,6 +45,7 @@ files:
|
|
43
45
|
- spec/unit/dsl/platform_spec.rb
|
44
46
|
- spec/unit/dsl/service_spec.rb
|
45
47
|
- spec/unit/dsl/which_spec.rb
|
48
|
+
- spec/unit/dsl/windows_spec.rb
|
46
49
|
- spec/unit/mash_spec.rb
|
47
50
|
homepage: https://github.com/chef/chef/tree/master/chef-utils
|
48
51
|
licenses:
|