diff options
author | Bruce Williams <bruce@codefluency.com> | 2010-03-12 17:44:19 -0800 |
---|---|---|
committer | Bruce Williams <bruce@codefluency.com> | 2010-03-12 17:44:19 -0800 |
commit | 350972d6be26cacdcb18875055f9723574312966 (patch) | |
tree | 88a2fa8aca3788e17f67691cce66462767bd89ae /lib/puppet | |
parent | 176b1ec7a4620cae24996609ada33f21cc2eef84 (diff) |
Basic SVN provider
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 2 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/svn.rb | 71 | ||||
-rw-r--r-- | lib/puppet/type/vcsrepo.rb | 4 |
3 files changed, 75 insertions, 2 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 298d1dc..7290387 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -42,8 +42,6 @@ Puppet::Type.type(:vcsrepo).provide(:git) do private def clone_repository(source, path) - parent = File.dirname(path) - FileUtils.mkdir_p(parent) git('clone', source, path) end diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb new file mode 100644 index 0000000..fef7b62 --- /dev/null +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -0,0 +1,71 @@ +Puppet::Type.type(:vcsrepo).provide(:svn) do + desc "Supports Subversion repositories" + + commands :svn => 'svn', + :svnadmin => 'svnadmin' + + def create + if !@resource.value(:source) + create_repository(@resource.value(:path)) + else + checkout_repository(@resource.value(:source), + @resource.value(:path), + @resource.value(:revision)) + end + end + + def exists? + File.directory?(@resource.value(:path)) + end + + def destroy + FileUtils.rm_rf(@resource.value(:path)) + end + + def revision + at_path do + svn('info')[/^Revision:\s+(\d+)/m, 1] + end + end + + def revision=(desired) + at_path do + svn('update', '-r', desired) + end + end + + private + + def checkout_repository(source, path, revision = nil) + args = ['checkout'] + if revision + args.push('-r', revision) + end + args.push(source, path) + svn(*args) + end + + def create_repository(path) + args = ['create'] + if @resource.value(:fstype) + args.push('--fs-type', @resource.value(:fstype)) + end + args << path + svnadmin(*args) + end + + def reset(desired) + at_path do + git('reset', '--hard', desired) + end + end + + def at_path(&block) + value = nil + Dir.chdir(@resource.value(:path)) do + value = yield + end + value + end + +end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 7db571e..04c48a3 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -23,6 +23,10 @@ Puppet::Type.newtype(:vcsrepo) do end end + newparam(:fstype) do + desc "Filesystem type (for providers that support it, eg subversion)" + end + newproperty(:revision) do desc "The revision of the repository" newvalue(/^\S+$/) |