Permalink
Browse files

Added optional removal of scm files

  • Loading branch information...
ajgon committed Apr 25, 2016
1 parent 9f8615f commit 82b25ec0c30fb0a140f3c4c8b2440c7e19b181db
View
@@ -101,6 +101,10 @@ you don't need to provide them here. Currently only `git` is supported.
* **Supported values:** `git`
* **Default:** `git`
* SCM used by the cookbook to clone the repo.
* `app['scm']['remove_scm_files']`
* **Supported values:** `true`, `false`
* **Default:** `true`
* If set to true, all SCM leftovers (like `.git`) will be removed.
* `app['scm']['repository']`
* Repository URL
* `app['scm']['revision']`
View
@@ -21,6 +21,11 @@
nginx::http_stub_status_module
)
# scm
## common
default['defaults']['scm']['remove_scm_files'] = true
# appserver
## common
@@ -26,7 +26,8 @@ def raw_out
end
def out_defaults
base = JSON.parse((node['deploy'][app['shortname']]['scm'] || {}).to_json, symbolize_names: true)
base = node['defaults']['scm'].to_h.symbolize_keys
base = base.merge(JSON.parse((node['deploy'][app['shortname']]['scm'] || {}).to_json, symbolize_names: true))
defaults.merge(base).merge(scm_provider: adapter.constantize)
end
@@ -5,7 +5,7 @@ class Git < Drivers::Scm::Base
adapter Chef::Provider::Git
allowed_engines :git
packages :git
output filter: [:scm_provider, :repository, :revision, :enable_submodules, :ssh_wrapper]
output filter: [:scm_provider, :repository, :revision, :enable_submodules, :ssh_wrapper, :remove_scm_files]
defaults enable_submodules: true, ssh_wrapper: '/tmp/ssh-git-wrapper.sh'
def before_deploy(context)
View
@@ -40,7 +40,7 @@
symlinks(node['defaults']['deploy']['symlinks'].merge(deploy[:symlinks] || {}))
scm.out.each do |scm_key, scm_value|
send(scm_key, scm_value)
send(scm_key, scm_value) if respond_to?(scm_key)
end
[appserver, webserver].each do |server|
@@ -69,7 +69,7 @@
directory File.join(release_path, '.git') do
recursive true
action :delete
end
end if scm.out[:remove_scm_files]
run_callback_from_file(File.join(release_path, 'deploy', 'before_restart.rb'))
end
View
@@ -64,6 +64,9 @@ def node(override = {})
create_dirs_before_symlink: %w(tmp public config ../../shared/cache ../../shared/assets),
purge_before_symlink: %w(log tmp/cache tmp/pids public/system public/assets)
},
scm: {
remove_scm_files: true
},
appserver: {
adapter: 'unicorn',
worker_processes: 8
@@ -91,7 +91,8 @@
revision: 'master',
repository: 'git@git.example.com:repo/project.git',
enable_submodules: false,
ssh_wrapper: 'ssh-wrap'
ssh_wrapper: 'ssh-wrap',
remove_scm_files: true
)
end

0 comments on commit 82b25ec

Please sign in to comment.