diff options
Diffstat (limited to 'lib/chef/resource/deploy.rb')
-rw-r--r-- | lib/chef/resource/deploy.rb | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/lib/chef/resource/deploy.rb b/lib/chef/resource/deploy.rb index 4252aa230f..613d0cba24 100644 --- a/lib/chef/resource/deploy.rb +++ b/lib/chef/resource/deploy.rb @@ -27,6 +27,7 @@ # migration_command "rake db:migrate" # environment "RAILS_ENV" => "production", "OTHER_ENV" => "foo" # shallow_clone true +# depth 1 # action :deploy # or :rollback # restart_command "touch tmp/restart.txt" # git_ssh_wrapper "wrap-ssh4git.sh" @@ -51,33 +52,32 @@ class Chef # class Deploy < Chef::Resource - provider_base Chef::Provider::Deploy - identity_attr :repository state_attrs :deploy_to, :revision + default_action :deploy + allowed_actions :force_deploy, :deploy, :rollback + def initialize(name, run_context=nil) super - @resource_name = :deploy @deploy_to = name @environment = nil - @repository_cache = 'cached-copy' + @repository_cache = "cached-copy" @copy_exclude = [] @purge_before_symlink = %w{log tmp/pids public/system} @create_dirs_before_symlink = %w{tmp public config} @symlink_before_migrate = {"config/database.yml" => "config/database.yml"} @symlinks = {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"} - @revision = 'HEAD' - @action = :deploy + @revision = "HEAD" @migrate = false @rollback_on_error = false @remote = "origin" @enable_submodules = false @shallow_clone = false + @depth = nil @scm_provider = Chef::Provider::Git @svn_force_export = false - @allowed_actions.push(:force_deploy, :deploy, :rollback) @additional_remotes = Hash[] @keep_releases = 5 @enable_checkout = true @@ -99,8 +99,12 @@ class Chef @current_path ||= @deploy_to + "/current" end - def depth - @shallow_clone ? "5" : nil + def depth(arg=@shallow_clone ? 5 : nil) + set_or_return( + :depth, + arg, + :kind_of => [ Integer ], + ) end # note: deploy_to is your application "meta-root." @@ -108,7 +112,7 @@ class Chef set_or_return( :deploy_to, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -116,7 +120,7 @@ class Chef set_or_return( :repo, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end alias :repository :repo @@ -125,7 +129,7 @@ class Chef set_or_return( :remote, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -133,7 +137,7 @@ class Chef set_or_return( :role, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -142,7 +146,7 @@ class Chef set_or_return( :restart_command, arg, - :kind_of => [ String, Proc ] + :kind_of => [ String, Proc ], ) end alias :restart :restart_command @@ -151,7 +155,7 @@ class Chef set_or_return( :migrate, arg, - :kind_of => [ TrueClass, FalseClass ] + :kind_of => [ TrueClass, FalseClass ], ) end @@ -159,7 +163,7 @@ class Chef set_or_return( :migration_command, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -167,7 +171,7 @@ class Chef set_or_return( :rollback_on_error, arg, - :kind_of => [ TrueClass, FalseClass ] + :kind_of => [ TrueClass, FalseClass ], ) end @@ -175,7 +179,7 @@ class Chef set_or_return( :user, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -183,7 +187,7 @@ class Chef set_or_return( :group, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -191,7 +195,7 @@ class Chef set_or_return( :enable_submodules, arg, - :kind_of => [ TrueClass, FalseClass ] + :kind_of => [ TrueClass, FalseClass ], ) end @@ -199,7 +203,7 @@ class Chef set_or_return( :shallow_clone, arg, - :kind_of => [ TrueClass, FalseClass ] + :kind_of => [ TrueClass, FalseClass ], ) end @@ -207,7 +211,7 @@ class Chef set_or_return( :repository_cache, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -215,7 +219,7 @@ class Chef set_or_return( :copy_exclude, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -223,7 +227,7 @@ class Chef set_or_return( :revision, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end alias :branch :revision @@ -232,7 +236,7 @@ class Chef set_or_return( :git_ssh_wrapper, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end alias :ssh_wrapper :git_ssh_wrapper @@ -241,7 +245,7 @@ class Chef set_or_return( :svn_username, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -249,7 +253,7 @@ class Chef set_or_return( :svn_password, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -257,7 +261,7 @@ class Chef set_or_return( :svn_arguments, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end @@ -277,15 +281,21 @@ class Chef set_or_return( :scm_provider, klass, - :kind_of => [ Class ] + :kind_of => [ Class ], ) end + # This is to support "provider :revision" without deprecation warnings. + # Do NOT copy this. + def self.provider_base + Chef::Provider::Deploy + end + def svn_force_export(arg=nil) set_or_return( :svn_force_export, arg, - :kind_of => [ TrueClass, FalseClass ] + :kind_of => [ TrueClass, FalseClass ], ) end @@ -298,7 +308,7 @@ class Chef set_or_return( :environment, arg, - :kind_of => [ Hash ] + :kind_of => [ Hash ], ) end @@ -318,7 +328,7 @@ class Chef set_or_return( :purge_before_symlink, arg, - :kind_of => Array + :kind_of => Array, ) end @@ -334,7 +344,7 @@ class Chef set_or_return( :create_dirs_before_symlink, arg, - :kind_of => Array + :kind_of => Array, ) end @@ -348,7 +358,7 @@ class Chef set_or_return( :symlinks, arg, - :kind_of => Hash + :kind_of => Hash, ) end @@ -363,7 +373,7 @@ class Chef set_or_return( :symlink_before_migrate, arg, - :kind_of => Hash + :kind_of => Hash, ) end @@ -395,7 +405,7 @@ class Chef set_or_return( :additional_remotes, arg, - :kind_of => Hash + :kind_of => Hash, ) end @@ -403,7 +413,7 @@ class Chef set_or_return( :enable_checkout, arg, - :kind_of => [TrueClass, FalseClass] + :kind_of => [TrueClass, FalseClass], ) end @@ -411,7 +421,7 @@ class Chef set_or_return( :checkout_branch, arg, - :kind_of => String + :kind_of => String, ) end @@ -424,7 +434,7 @@ class Chef set_or_return( :timeout, arg, - :kind_of => Integer + :kind_of => Integer, ) end |