Merge pull request #6 from justintime/svn-basic-auth

Adding basic_auth feature and adding --non-interactive to all svn command
This commit is contained in:
Nibalizer 2011-08-18 10:56:51 -07:00
commit 18d4cf890c
2 changed files with 29 additions and 7 deletions

View File

@ -7,7 +7,7 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo)
:svnadmin => 'svnadmin' :svnadmin => 'svnadmin'
defaultfor :svn => :exists defaultfor :svn => :exists
has_features :filesystem_types, :reference_tracking has_features :filesystem_types, :reference_tracking, :basic_auth
def create def create
if !@resource.value(:source) if !@resource.value(:source)
@ -41,30 +41,43 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo)
end end
end end
end end
def buildargs
args = ['--non-interactive']
if @resource.value(:basic_auth_username) && @resource.value(:basic_auth_password)
args.push('--username', @resource.value(:basic_auth_username))
args.push('--password', @resource.value(:basic_auth_password))
args.push('--no-auth-cache')
end
return args
end
def latest def latest
args = buildargs.push('info', '-r', 'HEAD')
at_path do at_path do
svn('info', '-r', 'HEAD')[/^Revision:\s+(\d+)/m, 1] svn(*args)[/^Revision:\s+(\d+)/m, 1]
end end
end end
def revision def revision
args = buildargs.push('info')
at_path do at_path do
svn('info')[/^Revision:\s+(\d+)/m, 1] svn(*args)[/^Revision:\s+(\d+)/m, 1]
end end
end end
def revision=(desired) def revision=(desired)
args = buildargs.push('update', '-r', desired)
at_path do at_path do
svn('update', '-r', desired) svn(*args)
end end
update_owner update_owner
end end
private private
def checkout_repository(source, path, revision = nil) def checkout_repository(source, path, revision)
args = ['checkout'] args = buildargs.push('checkout')
if revision if revision
args.push('-r', revision) args.push('-r', revision)
end end

View File

@ -5,7 +5,8 @@ Puppet::Type.newtype(:vcsrepo) do
feature :gzip_compression, feature :gzip_compression,
"The provider supports explicit GZip compression levels" "The provider supports explicit GZip compression levels"
feature :basic_auth,
"The provider supports HTTP Basic Authentication"
feature :bare_repositories, feature :bare_repositories,
"The provider differentiates between bare repositories "The provider differentiates between bare repositories
and those with working copies", and those with working copies",
@ -136,6 +137,14 @@ Puppet::Type.newtype(:vcsrepo) do
end end
end end
newparam :basic_auth_username, :required_features => [:basic_auth] do
desc "HTTP Basic Auth username"
end
newparam :basic_auth_password, :required_features => [:basic_auth] do
desc "HTTP Basic Auth password"
end
newparam :identity, :required_features => [:ssh_identity] do newparam :identity, :required_features => [:ssh_identity] do
desc "SSH identity file" desc "SSH identity file"
end end