Sha256: 75430e81abf027e29ea90c5866de703b0683af720758c47abdd785a1dc40fc44

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

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

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

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

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

    # 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
    # http://docs.opscode.com/breaking_changes_chef_11.html#knife-configuration-parameter-changes
    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

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
knife-solo-0.7.0 lib/knife-solo/tools.rb
knife-solo-0.7.0.pre3 lib/knife-solo/tools.rb
knife-solo-0.7.0.pre2 lib/knife-solo/tools.rb
knife-solo-0.7.0.pre lib/knife-solo/tools.rb
knife-solo-0.6.0 lib/knife-solo/tools.rb