diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2010-05-12 18:35:01 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | b7d387e3e71f6af1b2967098b67440f8daa53e7d (patch) | |
| tree | 147958b739b57a470b98e261dccdbbe644fa3dc1 /lib/puppet | |
| parent | 342298c4f9fcb2874d4017219a472ddf37dbfc6b (diff) | |
| download | puppet-b7d387e3e71f6af1b2967098b67440f8daa53e7d.tar.gz puppet-b7d387e3e71f6af1b2967098b67440f8daa53e7d.tar.xz puppet-b7d387e3e71f6af1b2967098b67440f8daa53e7d.zip | |
Feature #2935 Puppet[:mode] and Puppet[:name] are read-only
Historically, the Puppet[:name] setting has been settable, but the
results of chaning it are poorly defined.
The switch to modes instead of executable names seems like a good time
to disable this complexity.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
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 |
