Skip to content

Commit ecf0235

Browse files
committed
Add user feature support to CVS provider
1 parent f6f870b commit ecf0235

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers
456456

457457
* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
458458
* `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
459-
* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.)
459+
* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.)
460460
* `dummy` -
461461
* `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
462462
* `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
477477
* `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.)
478478
* `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`.)
479479
* `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.)
480-
* `user` - The provider can run as a different user. (Available with `git` and `hg`.)
480+
* `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.)
481481
* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.)
482482

483483
####Parameters

lib/puppet/provider/vcsrepo/cvs.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
desc "Supports CVS repositories/workspaces"
55

66
commands :cvs => 'cvs'
7-
has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh
7+
has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh, :user
88

99
def create
1010
if !@resource.value(:source)
@@ -125,13 +125,11 @@ def runcvs(*args)
125125
e = {}
126126
end
127127

128-
# The location of withenv changed from Puppet 2.x to 3.x
129-
withenv = Puppet::Util.method(:withenv) if Puppet::Util.respond_to?(:withenv)
130-
withenv = Puppet::Util::Execution.method(:withenv) if Puppet::Util::Execution.respond_to?(:withenv)
131-
fail("Cannot set custom environment #{e}") if e && !withenv
132-
133-
withenv.call e do
134-
Puppet.debug cvs *args
128+
if @resource.value(:user) and @resource.value(:user) != Facter['id'].value
129+
debug "Running as user " + @resource.value(:user)
130+
Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :uid => @resource.value(:user), :custom_environment => e)
131+
else
132+
Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :custom_environment => e)
135133
end
136134
end
137135
end

0 commit comments

Comments
 (0)