summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/provider/vcsrepo/cvs.rb1
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb5
-rw-r--r--lib/puppet/type/vcsrepo.rb27
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)