diff options
author | Bruce Williams <bruce@codefluency.com> | 2010-03-14 16:48:19 -0700 |
---|---|---|
committer | Bruce Williams <bruce@codefluency.com> | 2010-03-14 16:48:19 -0700 |
commit | 9304bc707e5c6f6cb5738d939d8e2af69b35149d (patch) | |
tree | 46dcc23faede9e96b05218d46bbd68cc3a79a461 /lib | |
parent | 1c8c9bf87045ef3f14ea0b83909390e728d126b3 (diff) | |
download | puppet-vcsrepo-9304bc707e5c6f6cb5738d939d8e2af69b35149d.tar.gz puppet-vcsrepo-9304bc707e5c6f6cb5738d939d8e2af69b35149d.tar.bz2 |
Make gzip compression and bare repositories explicit features
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/provider/vcsrepo/cvs.rb | 1 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 5 | ||||
-rw-r--r-- | lib/puppet/type/vcsrepo.rb | 27 |
3 files changed, 18 insertions, 15 deletions
diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb index 99faa54..1cedc8b 100644 --- a/lib/puppet/provider/vcsrepo/cvs.rb +++ b/lib/puppet/provider/vcsrepo/cvs.rb @@ -5,6 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) commands :cvs => 'cvs' defaultfor :cvs => :exists + has_features :gzip_compression def create if !@resource.value(:source) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index eeecac3..274f25b 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -5,6 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) commands :git => 'git' defaultfor :git => :exists + has_features :bare_repositories def create if !@resource.value(:source) @@ -47,10 +48,6 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def working_copy_exists? File.directory?(File.join(@resource.value(:path), '.git')) end - - def exists? - bare_exists? || working_copy_exists? - end private diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 7616f41..aae65a1 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -3,33 +3,38 @@ require 'pathname' Puppet::Type.newtype(:vcsrepo) do desc "A local version control repository" + feature :gzip_compression, + "The provider supports explicit GZip compression levels" + + feature :bare_repositories, + "The provider differentiates between bare repositories + and those with working copies", + :methods => [:bare_exists?, :working_copy_exists?] + + ensurable do defaultvalues - newvalue :bare do + newvalue :bare, :required_features => [:bare_repositories] do provider.create end def retrieve prov = @resource.provider if prov - if prov.respond_to?(:bare_exists?) - if prov.respond_to?(:working_copy_exists?) && prov.working_copy_exists? + if prov.class.feature?(:bare_repositories) + if prov.working_copy_exists? :present - elsif prov.respond_to?(:bare_exists?) && prov.bare_exists? + elsif prov.bare_exists? :bare else :absent end else - if prov.exists? - :present - else - :absent - end + prov.exists? ? :present : :absent end else - :absent + raise Puppet::Error, "Could not find provider" end end @@ -59,7 +64,7 @@ Puppet::Type.newtype(:vcsrepo) do newvalue(/^\S+$/) end - newparam :compression do + newparam :compression, :required_features => [:gzip_compression] do desc "Compression level (used by CVS)" validate do |amount| unless Integer(amount).between?(0, 6) |