Skip to content
Browse files

Got subversion working. Add "scm 'subversion'" to the deploy block al…

…ong with svn_username and svn_password, if applicable.

Signed-off-by: ezmobius <ez@engineyard.com>
  • Loading branch information...
1 parent 6d9e999 commit d2e10bd39cfb10df77d613a26b86b8a3f35fd5ff Dave Myron committed with ezmobius
Showing with 67 additions and 26 deletions.
  1. +5 −1 README.rdoc
  2. +45 −17 lib/chef-deploy.rb
  3. +7 −2 lib/chef-deploy/cached_deploy.rb
  4. +10 −6 lib/chef-deploy/subversion.rb
View
6 README.rdoc
@@ -45,4 +45,8 @@ These scripts will be called with two command line params in ARGV:
ruby before_migrate.rb production app_master
Where ARGV[0] is the RAILS_ENV, MERB_ENV or RACK_ENV and ARGV[1] is the role passed in to the deploy resource, this
-can be used to identify certain servers as database, application, cache, etc roles so you can act accordingly
+can be used to identify certain servers as database, application, cache, etc roles so you can act accordingly
+
+Using subversion:
+
+In your deploy block, simply add: scm 'subversion' (as well as svn_username and svn_password, if needed). Obviously, git-specific options like enable_submodules can be removed as they're not applicable.
View
62 lib/chef-deploy.rb
@@ -1,3 +1,4 @@
+require File.join(File.dirname(__FILE__), 'chef-deploy/subversion')
require File.join(File.dirname(__FILE__), 'chef-deploy/git')
require File.join(File.dirname(__FILE__), 'chef-deploy/cached_deploy')
@@ -151,6 +152,30 @@ def git_ssh_wrapper(arg=nil)
:kind_of => [ String ]
)
end
+
+ def scm(arg=nil)
+ set_or_return(
+ :scm,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def svn_username(arg=nil)
+ set_or_return(
+ :svn_username,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def svn_password(arg=nil)
+ set_or_return(
+ :svn_password,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
end
end
@@ -161,24 +186,27 @@ class Deploy < Chef::Provider
def load_current_resource
FileUtils.mkdir_p "#{@new_resource.name}/shared"
FileUtils.mkdir_p "#{@new_resource.name}/releases"
- @dep = CachedDeploy.new :user => @new_resource.user,
- :group => @new_resource.group,
- :role => @new_resource.role,
- :branch => (@new_resource.branch || 'HEAD'),
- :restart_command => (@new_resource.restart_command || ""),
- :repository => @new_resource.repo,
- :environment => @new_resource.environment,
- :migration_command => @new_resource.migration_command,
- :migrate => @new_resource.migrate,
- :deploy_to => @new_resource.name,
- :repository_cache => @new_resource.repository_cache,
- :copy_exclude => @new_resource.copy_exclude,
- :revision => (@new_resource.revision || ''),
+ @dep = CachedDeploy.new :user => @new_resource.user,
+ :group => @new_resource.group,
+ :role => @new_resource.role,
+ :branch => (@new_resource.branch || 'HEAD'),
+ :restart_command => (@new_resource.restart_command || ""),
+ :repository => @new_resource.repo,
+ :environment => @new_resource.environment,
+ :migration_command => @new_resource.migration_command,
+ :migrate => @new_resource.migrate,
+ :deploy_to => @new_resource.name,
+ :repository_cache => @new_resource.repository_cache,
+ :copy_exclude => @new_resource.copy_exclude,
+ :revision => (@new_resource.revision || ''),
:git_enable_submodules => @new_resource.enable_submodules,
- :git_shallow_clone => @new_resource.shallow_clone,
- :node => @node,
- :new_resource => @new_resource,
- :git_ssh_wrapper => @git_ssh_wrapper
+ :git_shallow_clone => @new_resource.shallow_clone,
+ :svn_username => @new_resource.svn_username,
+ :svn_password => @new_resource.svn_password,
+ :scm => @new_resource.scm || 'git',
+ :node => @node,
+ :new_resource => @new_resource,
+ :git_ssh_wrapper => @git_ssh_wrapper
end
def action_deploy
View
9 lib/chef-deploy/cached_deploy.rb
@@ -176,7 +176,12 @@ def configuration
end
def source
- @source ||= Git.new(configuration)
+ @source ||= case configuration[:scm]
+ when 'git'
+ Git.new configuration
+ when 'svn'
+ Subversion.new configuration
+ end
end
private
@@ -256,4 +261,4 @@ def mark
def copy_exclude
@copy_exclude ||= Array(configuration.fetch(:copy_exclude, []))
end
-end
+end
View
16 lib/chef-deploy/subversion.rb
@@ -1,3 +1,5 @@
+require 'yaml'
+
class Subversion
def initialize(opts={})
@@ -27,13 +29,13 @@ def checkout(revision, destination)
# Returns the command that will do an "svn update" to the given
# revision, for the working copy at the given destination.
def sync(revision, destination)
- scm :update, arguments, verbose, authentication, "-r#{revision}", destination
+ scm :update, config[:arguments], verbose, authentication, "-r#{revision}", destination
end
# Returns the command that will do an "svn export" of the given revision
# to the given destination.
def export(revision, destination)
- scm :export, arguments, verbose, authentication, "-r#{revision}", repository, destination
+ scm :export, config[:arguments], verbose, authentication, "-r#{revision}", repository, destination
end
# Returns the command that will do an "svn diff" for the two revisions.
@@ -72,15 +74,17 @@ def next_revision(revision)
# switch, since Capistrano will check for that prompt in the output
# and will respond appropriately.
def authentication
- username = config(:svn_username)
+ username = config[:svn_username]
return "" unless username
- result = "--username #{config(:svn_username)} "
- result << "--password #{config(:svn_password)} "
+ result = "--username #{config[:svn_username]} "
+ result << "--password #{config[:svn_password]} "
result
end
# If verbose output is requested, return nil, otherwise return the
# command-line switch for "quiet" ("-q").
+ # FIXME: This is currently flipped logically since it doesn't check
+ # for any verbosity configuration flag
def verbose
"-q"
end
@@ -96,6 +100,6 @@ def scm(*args)
end
def svn_password_prompt
- config[:password]
+ config[:svn_password]
end
end

0 comments on commit d2e10bd

Please sign in to comment.
Something went wrong with that request. Please try again.