summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Fautley <jon@dead.li>2014-10-28 16:21:48 +0000
committerJon Fautley <jon@dead.li>2014-10-28 16:21:48 +0000
commitecf02352a371e3c4a9c72bf94297f047bc400aa7 (patch)
treef6bab38dbd0ef9945dae6ae6c9d16699dd206b5a
parentf6f870b959d1c897cbe23778e54087550e110d14 (diff)
downloadpuppet-vcsrepo-ecf02352a371e3c4a9c72bf94297f047bc400aa7.tar.gz
puppet-vcsrepo-ecf02352a371e3c4a9c72bf94297f047bc400aa7.tar.bz2
Add `user` feature support to CVS provider
-rw-r--r--README.markdown4
-rw-r--r--lib/puppet/provider/vcsrepo/cvs.rb14
2 files changed, 8 insertions, 10 deletions
diff --git a/README.markdown b/README.markdown
index 6d03a7c..de6ae9a 100644
--- a/README.markdown
+++ b/README.markdown
@@ -456,7 +456,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers
* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
* `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
-* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.)
+* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.)
* `dummy` -
* `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
* `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.)
@@ -477,7 +477,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers
* `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.)
* `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.)
* `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.)
-* `user` - The provider can run as a different user. (Available with `git` and `hg`.)
+* `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.)
* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.)
####Parameters
diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb
index 01094b1..891a5c6 100644
--- a/lib/puppet/provider/vcsrepo/cvs.rb
+++ b/lib/puppet/provider/vcsrepo/cvs.rb
@@ -4,7 +4,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo)
desc "Supports CVS repositories/workspaces"
commands :cvs => 'cvs'
- has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh
+ has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh, :user
def create
if !@resource.value(:source)
@@ -125,13 +125,11 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo)
e = {}
end
- # The location of withenv changed from Puppet 2.x to 3.x
- withenv = Puppet::Util.method(:withenv) if Puppet::Util.respond_to?(:withenv)
- withenv = Puppet::Util::Execution.method(:withenv) if Puppet::Util::Execution.respond_to?(:withenv)
- fail("Cannot set custom environment #{e}") if e && !withenv
-
- withenv.call e do
- Puppet.debug cvs *args
+ if @resource.value(:user) and @resource.value(:user) != Facter['id'].value
+ debug "Running as user " + @resource.value(:user)
+ Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :uid => @resource.value(:user), :custom_environment => e)
+ else
+ Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :custom_environment => e)
end
end
end