It was previously in the parser, but the parser is only created
if the fileserver.conf exists, so the default mounts weren't
made if the file didn't exist.

This is a bit less encapsulation, but not much.

Signed-off-by: Luke Kanies <[email protected]>
---
 lib/puppet/file_serving/configuration.rb        |    9 +++++++++
 lib/puppet/file_serving/configuration/parser.rb |    8 --------
 spec/unit/file_serving/configuration.rb         |   15 +++++++++++++++
 spec/unit/file_serving/configuration/parser.rb  |   12 ------------
 4 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/lib/puppet/file_serving/configuration.rb 
b/lib/puppet/file_serving/configuration.rb
index 608924c..6092c24 100644
--- a/lib/puppet/file_serving/configuration.rb
+++ b/lib/puppet/file_serving/configuration.rb
@@ -94,6 +94,11 @@ class Puppet::FileServing::Configuration
 
     private
 
+    def mk_default_mounts
+        @mounts["modules"] ||= Mount::Modules.new("modules")
+        @mounts["plugins"] ||= Mount::Plugins.new("plugins")
+    end
+
     # Read the configuration file.
     def readconfig(check = true)
         config = Puppet[:fileserverconfig]
@@ -114,5 +119,9 @@ class Puppet::FileServing::Configuration
             puts detail.backtrace if Puppet[:trace]
             Puppet.err "Error parsing fileserver configuration: %s; using old 
configuration" % detail
         end
+
+    ensure
+        # Make sure we've got our plugins and modules.
+        mk_default_mounts
     end
 end
diff --git a/lib/puppet/file_serving/configuration/parser.rb 
b/lib/puppet/file_serving/configuration/parser.rb
index c86e00a..50368fd 100644
--- a/lib/puppet/file_serving/configuration/parser.rb
+++ b/lib/puppet/file_serving/configuration/parser.rb
@@ -46,8 +46,6 @@ class Puppet::FileServing::Configuration::Parser < 
Puppet::Util::LoadedFile
             }
         }
 
-        mk_default_mounts
-
         validate()
 
         return @mounts
@@ -83,12 +81,6 @@ class Puppet::FileServing::Configuration::Parser < 
Puppet::Util::LoadedFile
         }
     end
 
-    def mk_default_mounts
-        ["plugins", "modules"].each do |name|
-            newmount(name) unless @mounts[name]
-        end
-    end
-
     # Create a new mount.
     def newmount(name)
         if @mounts.include?(name)
diff --git a/spec/unit/file_serving/configuration.rb 
b/spec/unit/file_serving/configuration.rb
index e62423c..6f5dc11 100755
--- a/spec/unit/file_serving/configuration.rb
+++ b/spec/unit/file_serving/configuration.rb
@@ -94,6 +94,21 @@ describe Puppet::FileServing::Configuration do
             config.send(:readconfig, false)
             config.mounted?("one").should be_true
         end
+
+        it "should add modules and plugins mounts even if the file does not 
exist" do
+            FileTest.expects(:exists?).returns false # the file doesn't exist
+            config = Puppet::FileServing::Configuration.create
+            config.mounted?("modules").should be_true
+            config.mounted?("plugins").should be_true
+        end
+
+        it "should add modules and plugins mounts even if they are not 
returned by the parser" do
+            @parser.expects(:parse).returns("one" => mock("mount"))
+            FileTest.expects(:exists?).returns true # the file doesn't exist
+            config = Puppet::FileServing::Configuration.create
+            config.mounted?("modules").should be_true
+            config.mounted?("plugins").should be_true
+        end
     end
 
     describe "when finding the specified mount" do
diff --git a/spec/unit/file_serving/configuration/parser.rb 
b/spec/unit/file_serving/configuration/parser.rb
index 389e583..6faf81b 100755
--- a/spec/unit/file_serving/configuration/parser.rb
+++ b/spec/unit/file_serving/configuration/parser.rb
@@ -32,10 +32,6 @@ describe Puppet::FileServing::Configuration::Parser do
     describe Puppet::FileServing::Configuration::Parser, " when parsing" do
         include FSConfigurationParserTesting
 
-        before do
-            @parser.stubs(:add_modules_mount)
-        end
-
         it "should allow comments" do
             @filehandle.expects(:each).yields("# this is a comment\n")
             proc { @parser.parse }.should_not raise_error
@@ -68,14 +64,6 @@ describe Puppet::FileServing::Configuration::Parser do
             result["two"].should equal(mount2)
         end
 
-        it "should add plugins and modules mounts if they do not exist" do
-            mock_file_content "[one]\npath /foo"
-
-            result = @parser.parse
-            result["plugins"].should_not be_nil
-            result["modules"].should_not be_nil
-        end
-
         it "should only allow mount names that are alphanumeric plus dashes" do
             mock_file_content "[a*b]\n"
             proc { @parser.parse }.should raise_error(ArgumentError)
-- 
1.6.1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to