diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/util/settings.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index ea18d22bf..c8f85a072 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -17,6 +17,8 @@ class Puppet::Util::Settings attr_accessor :file attr_reader :timer + ReadOnly = [:mode, :name] + # Retrieve a config value def [](param) value(param) @@ -480,9 +482,21 @@ class Puppet::Util::Settings if setting.respond_to?(:handle) setting.handle(value) end - # Reset the name, so it's looked up again. - if param == :name - @name = nil + if ReadOnly.include? param + raise ArgumentError, + "You're attempting to set configuration parameter $#{param}, which is read-only." + end + require 'puppet/util/command_line' + command_line = Puppet::Util::CommandLine.new + legacy_to_mode = Puppet::Util::CommandLine::LegacyName.inject({}) do |hash, pair| + app, legacy = pair + command_line.require_application app + hash[legacy.to_sym] = Puppet::Application.find(app).mode.name + hash + end + if new_type = legacy_to_mode[type] + Puppet.warning "You have configuration parameter $#{param} specified in [#{type}], which is a deprecated section. I'm assuming you meant [#{new_type}]" + type = new_type end @sync.synchronize do # yay, thread-safe @values[type][param] = value @@ -501,8 +515,6 @@ class Puppet::Util::Settings return value end - private :set_value - # Set a bunch of defaults in a given section. The sections are actually pretty # pointless, but they help break things up a bit, anyway. def setdefaults(section, defs) @@ -587,7 +599,7 @@ Generated on #{Time.now}. end eachsection do |section| persection(section) do |obj| - str += obj.to_config + "\n" + str += obj.to_config + "\n" unless ReadOnly.include? obj.name end end |