Sha256: b84989cd309472ee69884d5a3a7adaf5c5e8563260d89ffd99590ca583f28c0a

Contents?: true

Size: 1009 Bytes

Versions: 6

Compression:

Stored size: 1009 Bytes

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 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

6 entries across 6 versions & 1 rubygems

Version Path
knife-solo-0.4.3 lib/knife-solo/tools.rb
knife-solo-0.5.1 lib/knife-solo/tools.rb
knife-solo-0.5.0 lib/knife-solo/tools.rb
knife-solo-0.4.2 lib/knife-solo/tools.rb
knife-solo-0.4.1 lib/knife-solo/tools.rb
knife-solo-0.4.0 lib/knife-solo/tools.rb