summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-08 17:07:35 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-08 17:07:35 +0000
commit3489bd85669dd06ad0ec06430556aaeb4ba14e5d (patch)
tree64e2262d42c4ef5de4e9ecb818bfebe44c9fe134
parentb36f9c9a53bb568c7f72a81dfb75cee9f16e66d1 (diff)
downloadpuppet-3489bd85669dd06ad0ec06430556aaeb4ba14e5d.tar.gz
puppet-3489bd85669dd06ad0ec06430556aaeb4ba14e5d.tar.xz
puppet-3489bd85669dd06ad0ec06430556aaeb4ba14e5d.zip
One last try at getting the config and mode stuff working. The tests were passing because "mode" is a valid config option in the tests, but not in the real configuration. So, now the Config class correctly only tries to set the meta params if they are valid options, otherwise they get skipped.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2272 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/util/config.rb10
-rwxr-xr-xtest/util/config.rb32
2 files changed, 36 insertions, 6 deletions
diff --git a/lib/puppet/util/config.rb b/lib/puppet/util/config.rb
index afec4c943..7731fdc5b 100644
--- a/lib/puppet/util/config.rb
+++ b/lib/puppet/util/config.rb
@@ -301,13 +301,11 @@ class Puppet::Util::Config
end
values[section][var.to_s] = value
- # Do some annoying skullduggery here. This is so that
- # the group can be set in the config file. The problem
- # is that we're using the word 'group' twice, which is
- # confusing.
- if var == :group and section == Puppet[:name] and @config.include?(:group)
- @config[:group].value = value
+ # If the parameter is valid, then set it.
+ if section == Puppet[:name] and @config.include?(var)
+ @config[var].value = value
end
+ next
end
# Don't override set parameters, since the file is parsed
diff --git a/test/util/config.rb b/test/util/config.rb
index 58f74f5c9..742b15b7b 100755
--- a/test/util/config.rb
+++ b/test/util/config.rb
@@ -1026,6 +1026,38 @@ inttest = 27
check.call("750", 0750)
end
+
+ def test_only_set_metas_when_valid
+ file = tempfile
+ config = tempfile
+ @config.setdefaults(Puppet[:name], :ssldir => {
+ :mode => 0644,
+ :group => "yayness",
+ :desc => "yay",
+ :default => "/some/file"})
+
+ File.open(config, "w") { |f| f.puts "[#{Puppet[:name]}]
+ mode = 750
+ group = foo
+ ssldir = #{file}
+ "}
+
+ assert_nothing_raised do
+ @config.parse(config)
+ end
+
+ assert_raise(ArgumentError) do
+ @config[:mode]
+ end
+ assert_raise(ArgumentError) do
+ @config[:group]
+ end
+
+ # Now make them valid params
+ @config.setdefaults(Puppet[:name], :group => ["blah", "yay"])
+ @config.setdefaults(Puppet[:name], :mode => ["755", "yay"])
+
+ end
end
# $Id$