File tree Expand file tree Collapse file tree
itchef/cookbooks/fb_helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919# Reference: Chef platform_family values
2020# https://docs.chef.io/infra_language/checking_platforms/#platform_family-values
2121
22- class ChefUtilsProxy
23- include ChefUtils
24-
25- def initialize ( node )
26- @node = node
27- end
28-
29- def __getnode ( _skip_global = false )
30- @node
31- end
32- end
33-
3422class Chef
3523 # Our extensions of the node object
3624 class Node
3725
38- # A way to explicitly call a ChefUtils function instead of a
39- # fb_helpers function to aid in migration
40- def chefutils
41- # rubocop:disable Naming/MemoizedInstanceVariableName
42- @_fb_helpers_chefutils_proxy ||= ChefUtilsProxy . new ( self )
43- # rubocop:enable Naming/MemoizedInstanceVariableName
44- end
45-
4626 def linux?
4727 return @_fb_helpers_linux unless @_fb_helpers_linux . nil?
4828 @_fb_helpers_linux = self [ 'os' ] == 'linux'
Original file line number Diff line number Diff line change 315315 end
316316 end
317317
318- context 'Chef::Node.chefutils' do
319- it 'returns true for debian? when platform_family is debian' do
320- node . automatic [ 'platform' ] = 'debian'
321- node . automatic [ 'platform_family' ] = 'debian'
322- expect ( node . chefutils . debian? ) . to be ( true )
323- end
324-
325- it 'returns false for debian? when platform_family is not debian' do
326- node . automatic [ 'platform' ] = 'centos'
327- node . automatic [ 'platform_family' ] = 'rhel'
328- expect ( node . chefutils . debian? ) . to be ( false )
329- end
330-
331- it 'differs from node.debian? for ubuntu (platform_family=debian, platform=ubuntu)' do
332- node . automatic [ 'platform' ] = 'ubuntu'
333- node . automatic [ 'platform_family' ] = 'debian'
334- # fb_helpers checks platform == 'debian', so ubuntu is false
335- expect ( node . debian? ) . to be ( false )
336- # ChefUtils checks platform_family == 'debian', so ubuntu is true
337- expect ( node . chefutils . debian? ) . to be ( true )
338- end
339-
340- it 'returns true for rhel? when platform_family is rhel' do
341- node . automatic [ 'platform' ] = 'centos'
342- node . automatic [ 'platform_family' ] = 'rhel'
343- expect ( node . chefutils . rhel? ) . to be ( true )
344- end
345- end
346-
347318 context 'Chef::Node.disruptable?' do
348319 it 'is not disruptable by default' do
349320 expect ( node . disruptable? ) . to be ( false )
You can’t perform that action at this time.
0 commit comments