[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:33:52 UTC 2010


The following commit has been merged in the upstream branch:
commit 6d5566a715c0b757480b1d321d5801b795470552
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Wed May 12 18:31:52 2010 -0700

    Feature #2935 settings are in Mode sections instead of executable names
    
    A process's settings are now determined by Puppet::Mode rather than by
    the executable name.
    
    Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>

diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 1a21265..4d5acbe 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -79,8 +79,6 @@ class Puppet::Util::Settings
         end
 
         @cache.clear
-
-        @name = nil
     end
 
     # This is mostly just used for testing.
@@ -198,9 +196,6 @@ class Puppet::Util::Settings
         # And keep a per-environment cache
         @cache = Hash.new { |hash, key| hash[key] = {} }
 
-        # A central concept of a name.
-        @name = nil
-
         # The list of sections we've used.
         @used = []
     end
@@ -287,24 +282,9 @@ class Puppet::Util::Settings
         end
     end
 
-    # Figure out our name.
-    def name
-        unless @name
-            unless @config[:name]
-                return nil
-            end
-            searchpath.each do |source|
-                next if source == :name
-                @sync.synchronize do
-                    @name = @values[source][:name]
-                end
-                break if @name
-            end
-            unless @name
-                @name = convert(@config[:name].default).intern
-            end
-        end
-        @name
+    # Figure out the section name for the mode.
+    def mode
+        convert(@config[:mode].default).intern if @config[:mode]
     end
 
     # Return all of the parameters associated with a given section.
@@ -457,9 +437,9 @@ class Puppet::Util::Settings
     # The order in which to search for values.
     def searchpath(environment = nil)
         if environment
-            [:cli, :memory, environment, :name, :main]
+            [:cli, :memory, environment, :mode, :main]
         else
-            [:cli, :memory, :name, :main]
+            [:cli, :memory, :mode, :main]
         end
     end
 
@@ -602,8 +582,8 @@ Generated on #{Time.now}.
 }.gsub(/^/, "# ")
 
         # Add a section heading that matches our name.
-        if @config.include?(:name)
-            str += "[%s]\n" % self[:name]
+        if @config.include?(:mode)
+            str += "[%s]\n" % self[:mode]
         end
         eachsection do |section|
             persection(section) do |obj|
@@ -828,7 +808,7 @@ Generated on #{Time.now}.
     def each_source(environment)
         searchpath(environment).each do |source|
             # Modify the source as necessary.
-            source = self.name if source == :name
+            source = self.mode if source == :mode
             yield source
         end
     end
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb
index 1b5440a..3eba6dd 100755
--- a/spec/unit/util/settings.rb
+++ b/spec/unit/util/settings.rb
@@ -246,11 +246,9 @@ describe Puppet::Util::Settings do
             @settings.value(:one, "env2").should == "twoval"
         end
 
-        it "should have a name determined by the 'name' parameter" do
-            @settings.setdefaults(:whatever, :name => ["something", "yayness"])
-            @settings.name.should == :something
-            @settings[:name] = :other
-            @settings.name.should == :other
+        it "should have a mode determined by the 'mode' parameter" do
+            @settings.setdefaults(:whatever, :mode => ["something", "yayness"])
+            @settings.mode.should == :something
         end
     end
 
@@ -260,7 +258,7 @@ describe Puppet::Util::Settings do
             @settings.setdefaults :section,
                 :config => ["/my/file", "a"],
                 :one => ["ONE", "a"],
-                :name => ["myname", "w"]
+                :mode => ["mymode", "w"]
             FileTest.stubs(:exist?).returns true
         end
 
@@ -283,12 +281,12 @@ describe Puppet::Util::Settings do
             @settings[:one].should == "clival"
         end
 
-        it "should return values set in the executable-specific section before values set in the main section" do
-            text = "[main]\none = mainval\n[myname]\none = nameval\n"
+        it "should return values set in the mode-specific section before values set in the main section" do
+            text = "[main]\none = mainval\n[mymode]\none = modeval\n"
             @settings.stubs(:read_file).returns(text)
             @settings.parse
 
-            @settings[:one].should == "nameval"
+            @settings[:one].should == "modeval"
         end
 
         it "should not return values outside of its search path" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list