class Chef::Knife

Public Instance Methods

config() click to toggle source
# File lib/chef/knife/stencil_monkey_patch.rb, line 56
def config
  return Chef::Config[:knife]
end
merge_configs() click to toggle source
# File lib/chef/knife/stencil_monkey_patch.rb, line 26
def merge_configs
  # Apply config file settings on top of mixlib-cli defaults
  combined_config = default_config.merge(config_file_settings)
  # Apply user-supplied options on top of the above combination
  combined_config = combined_config.merge(config)
  # replace the config hash from mixlib-cli with our own.
  # Need to use the mutate-in-place #replace method instead of assigning to
  # the instance variable because other code may have a reference to the
  # original config hash object.
  config.replace(combined_config)

  # If the stencil plugin has been invoked, parse some additional configuration
  # from the stencils.
  if invoked_as_stencil?
    new_config = config
    stencil_collection = Knife::StencilCollection.new

    stencil_collection.for_name(locate_config_value(:chef_node_name)).each do |stencil|
      new_config.merge!(stencil.options)
    end

    config.replace(new_config)
    combined_config = config
    config.each_pair do |k,v|
      Chef::Config[:knife][k.to_sym] = v
    end
  end

end