(MODULES-1014) Adding noop mode option
authorPeter Souter <p.morsou@gmail.com>
Mon, 2 Jun 2014 22:03:19 +0000 (23:03 +0100)
committerPeter Souter <p.morsou@gmail.com>
Mon, 2 Jun 2014 22:03:19 +0000 (23:03 +0100)
lib/puppet/type/vcsrepo.rb

index 3dd7bc6..0e4450b 100644 (file)
@@ -98,10 +98,15 @@ Puppet::Type.newtype(:vcsrepo) do
       if prov
         if prov.working_copy_exists?
           if @resource.value(:force)
-            notice "Deleting current repository before recloning"
-            prov.destroy
-            notice "Create repository from latest"
-            prov.create
+            if noop?
+              notice "Noop Mode - Would have deleted repository"
+              notice "Noop Mode - Would have created repository from latest"
+            else
+              notice "Deleting current repository before recloning"
+              prov.destroy
+              notice "Create repository from latest"
+              prov.create
+            end
           end
           (@should.include?(:latest) && prov.latest?) ? :latest : :present
         elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
@@ -208,4 +213,12 @@ Puppet::Type.newtype(:vcsrepo) do
     ['git', 'git-core']
   end
 
+  def noop?
+    if defined?(@noop)
+      @noop
+    else
+      Puppet[:noop]
+    end
+  end
+
 end