summaryrefslogtreecommitdiff
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb24
-rw-r--r--lib/puppet/type/vcsrepo.rb25
2 files changed, 29 insertions, 20 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 7fa755d..5febce2 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -6,7 +6,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
##TODO modify the commands below so that the su - is included
optional_commands :git => 'git'
defaultfor :git => :exists
- has_features :bare_repositories, :reference_tracking, :ssh_identity
+ has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes
def create
if !@resource.value(:source)
@@ -40,11 +40,11 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def latest
branch = on_branch?
if branch == 'master'
- return get_revision('origin/HEAD')
+ return get_revision("#{@resource.value(:remote)}/HEAD")
elsif branch == '(no branch)'
return get_revision('HEAD')
else
- return get_revision('origin/%s' % branch)
+ return get_revision("#{@resource.value(:remote)}/%s" % branch)
end
end
@@ -73,7 +73,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
# authoritative.
# might be worthwhile to have an allow_local_changes param to decide
# whether to reset or pull when we're ensuring latest.
- at_path { git_with_identity('reset', '--hard', "origin/#{desired}") }
+ at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") }
end
if @resource.value(:ensure) != :bare
update_submodules
@@ -95,7 +95,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def update_references
at_path do
- git_with_identity('fetch', '--tags', 'origin')
+ git_with_identity('fetch', '--tags', @resource.value(:remote))
update_owner_and_excludes
end
end
@@ -190,7 +190,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def checkout(revision = @resource.value(:revision))
if !local_branch_revision? && remote_branch_revision?
- at_path { git_with_identity('checkout', '-b', revision, '--track', "origin/#{revision}") }
+ at_path { git_with_identity('checkout', '-b', revision, '--track', "#{@resource.value(:remote)}/#{revision}") }
else
at_path { git_with_identity('checkout', '--force', revision) }
end
@@ -212,9 +212,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def remote_branch_revision?(revision = @resource.value(:revision))
- # git < 1.6 returns 'origin/#{revision}'
- # git 1.6+ returns 'remotes/origin/#{revision}'
- branch = at_path { branches.grep /(remotes\/)?origin\/#{revision}/ }
+ # git < 1.6 returns '#{@resource.value(:remote)}/#{revision}'
+ # git 1.6+ returns 'remotes/#{@resource.value(:remote)}/#{revision}'
+ branch = at_path { branches.grep /(remotes\/)?#{@resource.value(:remote)}\/#{revision}/ }
if branch.length > 0
return branch
end
@@ -249,15 +249,15 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
create
end
at_path do
- git_with_identity('fetch', 'origin')
- git_with_identity('fetch', '--tags', 'origin')
+ git_with_identity('fetch', @resource.value(:remote))
+ git_with_identity('fetch', '--tags', @resource.value(:remote))
end
current = at_path { git_with_identity('rev-parse', rev).strip }
if @resource.value(:revision)
if local_branch_revision?
canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).strip }
elsif remote_branch_revision?
- canonical = at_path { git_with_identity('rev-parse', 'origin/' + @resource.value(:revision)).strip }
+ canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:remote)}/" + @resource.value(:revision)).strip }
end
current = @resource.value(:revision) if current == canonical
end
diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb
index 9824726..e291066 100644
--- a/lib/puppet/type/vcsrepo.rb
+++ b/lib/puppet/type/vcsrepo.rb
@@ -25,6 +25,9 @@ Puppet::Type.newtype(:vcsrepo) do
feature :modules,
"The repository contains modules that can be chosen of"
+ feature :multiple_remotes,
+ "The repository tracks multiple remote repositories"
+
ensurable do
attr_accessor :latest
@@ -89,7 +92,7 @@ Puppet::Type.newtype(:vcsrepo) do
end
- newparam(:path) do
+ newparam :path do
desc "Absolute path to repository"
isnamevar
validate do |value|
@@ -100,32 +103,32 @@ Puppet::Type.newtype(:vcsrepo) do
end
end
- newparam(:source) do
+ newparam :source do
desc "The source URI for the repository"
end
- newparam(:fstype, :required_features => [:filesystem_types]) do
+ newparam :fstype, :required_features => [:filesystem_types] do
desc "Filesystem type"
end
- newproperty(:revision) do
+ newproperty :revision do
desc "The revision of the repository"
newvalue(/^\S+$/)
end
- newparam(:owner) do
+ newparam :owner do
desc "The user/uid that owns the repository files"
end
- newparam(:group) do
+ newparam :group do
desc "The group/gid that owns the repository files"
end
- newparam(:excludes) do
+ newparam :excludes do
desc "Files to be excluded from the repository"
end
- newparam(:force) do
+ newparam :force do
desc "Force repository creation, destroying any files on the path in the process."
newvalues(:true, :false)
defaultto false
@@ -155,4 +158,10 @@ Puppet::Type.newtype(:vcsrepo) do
newparam :module, :required_features => [:modules] do
desc "The repository module to manage"
end
+
+ newparam :remote, :required_features => [:multiple_remotes] do
+ desc "The remote repository to track"
+ defaultto "origin"
+ end
+
end