[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:34:50 UTC 2010
The following commit has been merged in the upstream branch:
commit 738802e1a56312c468e99a43c0ffd64dd47c4382
Author: Luke Kanies <luke at puppetlabs.com>
Date: Wed May 19 23:44:30 2010 -0700
Fixing #2337 - Adding 'freeze_main' setting
This disables adding any code to 'main' except
in site.pp, so if you have code outside of a node,
class, or define it will throw an exception.
Signed-off-by: Luke Kanies <luke at puppetlabs.com>
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 9de73f5..f2e498d 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -169,7 +169,10 @@ module Puppet
return code, the entire Puppet run will fail."],
:postrun_command => ["", "A command to run after every agent run. If this command returns a non-zero
return code, the entire Puppet run will be considered to have failed, even though it might have
- performed work during the normal run."]
+ performed work during the normal run."],
+ :freeze_main => [false, "Freezes the 'main' class, disallowing any code to be added to it. This
+ essentially means that you can't have any code outside of a node, class, or definition other
+ than in the site manifest."]
)
hostname = Facter["hostname"].value
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index e13b183..e60f879 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -106,6 +106,7 @@ class Puppet::Resource::Type
def merge(other)
fail "#{name} is not a class; cannot add code to it" unless type == :hostclass
fail "#{other.name} is not a class; cannot add code from it" unless other.type == :hostclass
+ fail "Cannot have code outside of a class/node/define because 'freeze_main' is enabled" if name == "" and Puppet.settings[:freeze_main]
if parent and other.parent and parent != other.parent
fail "Cannot merge classes with different parent classes (#{name} => #{parent} vs. #{other.name} => #{other.parent})"
diff --git a/spec/unit/resource/type.rb b/spec/unit/resource/type.rb
index 3d0e824..514e694 100755
--- a/spec/unit/resource/type.rb
+++ b/spec/unit/resource/type.rb
@@ -586,6 +586,14 @@ describe Puppet::Resource::Type do
lambda { code.hostclass("b").merge(code.hostclass("d")) }.should raise_error(Puppet::Error)
end
+ it "should fail if it's named 'main' and 'freeze_main' is enabled" do
+ Puppet.settings[:freeze_main] = true
+ code = Puppet::Resource::TypeCollection.new("env")
+ code.add Puppet::Resource::Type.new(:hostclass, "")
+ other = Puppet::Resource::Type.new(:hostclass, "")
+ lambda { code.hostclass("").merge(other) }.should raise_error(Puppet::Error)
+ end
+
it "should copy the other class's parent if it has not parent" do
dest = Puppet::Resource::Type.new(:hostclass, "bar")
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list