rackspace-cookbooks / chef-sugar-rackspace

Chef Sugar Extensions useful if you use Rackspace as a provider
MIT License
1 stars 2 forks source link

Added support for determining rackconnect version #12

Closed jarosser06 closed 9 years ago

martinb3 commented 9 years ago

One final thought -- this could be super short if you had rackconnected? return a truthy value instead of a true/false; it could return the version of RC.

Something like:

def rackconnected?(node)
  return
    node['rackspace'] &&
    node['rackspace']['rackconnect'] &&
    node['rackspace']['rackconnect']['enabled'] &&
    node['rackspace']['rackconnect']['version']
end

def rackconnect_v3?(node)
  return rackconnected?(node) == 3
end

def rackconnect_v2?(node)
  return rackconnected?(node) == 2
end
jarosser06 commented 9 years ago

node['rackspace'] && node['rackspace']['rackconnect'] etc will return nil instead of false

martinb3 commented 9 years ago

node['rackspace'] && node['rackspace']['rackconnect'] etc will return nil instead of false

FWIW, nil is still falsey in comparisons, so that's okay:

$ irb
irb(main):001:0> !!nil
=> false
irb(main):002:0> nil && true
=> nil
irb(main):003:0> nil || true
=> true