summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormikeknox <mike@hfnix.net>2010-07-07 21:10:56 +1000
committerJames Turnbull <james@lovedthanlost.net>2010-07-22 09:19:38 +1000
commitdd31bce5655d7417cb4685ec6740898929a0b10c (patch)
tree9055d719e490a6c6716535180fe27aa3e626c4aa
parent6112583f15d6db63adca1e58593be7427422c2bd (diff)
When ensure => latest, svn didn't update.
svn provider now gets the latest revision from the repo, rather than the checkout Test with revision => <some value> as well now when ensure => latest, only refresh dependent resources if the repo is actually updated Tidied up debug messages
-rw-r--r--lib/puppet/provider/vcsrepo/svn.rb18
-rw-r--r--lib/puppet/type/vcsrepo.rb28
2 files changed, 42 insertions, 4 deletions
diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb
index f712bf5..e856220 100644
--- a/lib/puppet/provider/vcsrepo/svn.rb
+++ b/lib/puppet/provider/vcsrepo/svn.rb
@@ -26,6 +26,22 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo)
def destroy
FileUtils.rm_rf(@resource.value(:path))
end
+
+ def latest?
+ at_path do
+ if self.revision < self.latest then
+ return false
+ else
+ return true
+ end
+ end
+ end
+
+ def latest
+ at_path do
+ svn('info', '-r', 'HEAD')[/^Revision:\s+(\d+)/m, 1]
+ end
+ end
def revision
at_path do
@@ -59,4 +75,4 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo)
svnadmin(*args)
end
-end
+end \ No newline at end of file
diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb
index 137f8cd..ff3624b 100644
--- a/lib/puppet/type/vcsrepo.rb
+++ b/lib/puppet/type/vcsrepo.rb
@@ -19,7 +19,25 @@ Puppet::Type.newtype(:vcsrepo) do
over time (eg, some VCS tags and branch names)"
ensurable do
-
+ attr_accessor :latest
+
+ def insync?(is)
+ @should ||= []
+
+ case should
+ when :present
+ return true unless [:absent, :purged, :held].include?(is)
+ when :latest
+ if provider.latest?
+ return true
+ else
+ self.debug "%s repo revision is %s, latest is %s" %
+ [@resource.name, provider.revision, provider.latest]
+ return false
+ end
+ end
+ end
+
newvalue :present do
provider.create
end
@@ -37,7 +55,11 @@ Puppet::Type.newtype(:vcsrepo) do
if provider.respond_to?(:update_references)
provider.update_references
end
- reference = resource.value(:revision) || provider.revision
+ if provider.respond_to?(:latest?)
+ reference = provider.latest || provider.revision
+ else
+ reference = resource.value(:revision) || provider.revision
+ end
notice "Updating to latest '#{reference}' revision"
provider.revision = reference
else
@@ -99,4 +121,4 @@ Puppet::Type.newtype(:vcsrepo) do
end
end
-end
+end \ No newline at end of file