Module: KnifeSolo::Tools

Included in:
Chef::Knife::SoloCook
Defined in:
lib/knife-solo/tools.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config_value(config, key, default = nil) ⇒ Object

Chef 10 compatible way of getting correct precedence for command line and configuration file options. Adds correct handling of ‘false` values to the original example in docs.opscode.com/breaking_changes_chef_11.html#knife-configuration-parameter-changes



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/knife-solo/tools.rb', line 23

def self.config_value(config, key, default = nil)
  key = key.to_sym
  if !config[key].nil?
    config[key]
  elsif !Chef::Config[:knife][key].nil?
    # when Chef 10 support is dropped, this branch can be removed
    # as Chef 11 automatically merges the values to the `config` hash
    Chef::Config[:knife][key]
  else
    default
  end
end

.cygwin_client?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/knife-solo/tools.rb', line 11

def self.cygwin_client?
  RbConfig::CONFIG['host_os'] =~ /cygwin/
end

Instance Method Details

#config_value(key, default = nil) ⇒ Object



15
16
17
# File 'lib/knife-solo/tools.rb', line 15

def config_value(key, default = nil)
  Tools.config_value(config, key, default)
end

#system!(*command) ⇒ Object



3
4
5
# File 'lib/knife-solo/tools.rb', line 3

def system!(*command)
  raise "Failed to launch command #{command}" unless system(*command)
end

#windows_client?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/knife-solo/tools.rb', line 7

def windows_client?
  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
end