capistrano-psw 1.0.0.pre35 → 1.0.0.pre36

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9f60cb544de44bea7b4729226b3e02d4bf4af28
4
- data.tar.gz: 5ad8ff5e9c74abd4d4407edc62604bc2841e72eb
3
+ metadata.gz: adb04c574096e7f4584e52646f1534ef82a6c9f0
4
+ data.tar.gz: 163ed475c4a1b70c7b7239f170df7dfe8976419b
5
5
  SHA512:
6
- metadata.gz: 59ce3e6ea10f45feda0d1084eb37ef101ffb8540a048d885f86bceb746679fab754a3437ecb2f3c27e07bddb5bba37c6e6eff3198f0272d7a4d1257a4709a2da
7
- data.tar.gz: 7c3b3ed6c541aba84d311e299e192481a9528b6d723889f7f8fba3acdf2d0cce57a71cb932a90fa4f3f31f9e88df9e6e7a259384fb3389ca6a3528947ebd406c
6
+ metadata.gz: 0b2f0c33c767c8af621d41890c5ed32f2a60f59520c93fe9a01b511f80ed5b4f2fd785701c0af008926545498e3c826bfa674cadccde4919f84c5a0d281ccab6
7
+ data.tar.gz: 734bb3836063de1377595c49b17927902b5ea985190bacad23fcf9660f2967600afd24df40f7ab9644655f5bc577f20909eaf5af8db6274cf97372a0e05859fa
@@ -10,6 +10,6 @@
10
10
 
11
11
  module Capistrano
12
12
  module Psw
13
- VERSION = "1.0.0.pre35"
13
+ VERSION = "1.0.0.pre36"
14
14
  end
15
15
  end
@@ -46,6 +46,7 @@
46
46
  # Copyright:: 2013 Lexmark International Technology S.A. All rights reserved.
47
47
  # License:: 3-Clause BSD
48
48
  require 'capistrano/psw/peppr_app_deploy_file_utils'
49
+ require 'capistrano/dsl'
49
50
 
50
51
  namespace :psw_peppr_app_deploy do
51
52
 
@@ -121,49 +122,6 @@ namespace :psw_peppr_app_deploy do
121
122
 
122
123
  info "Uploading #{local_shared_files_path} (local) to #{remote_shared_files_path} on remote server #{host}..."
123
124
  PepprAppDeployFileUtils::upload_compressed_local_dir(local_shared_files_path, remote_shared_files_path)
124
-
125
- #this will only list the top-level folders and files, nested will show as a result of the link
126
- if File.directory?(local_shared_files_path)
127
- Dir.foreach(local_shared_files_path) do |file|
128
- next if file == '.' || file == '..' || file == '.absolute_paths'
129
-
130
- if File.directory?(file)
131
- new_file_path = File.join(shared_path, file)
132
- debug "Deleting existing environment file: #{new_file_path}"
133
- sudo :rm, '-rf', new_file_path
134
-
135
- debug "Creating a symlink for environment folder #{remote_shared_files_path}/#{file}..."
136
- sudo :ln, '-sf', "#{remote_shared_files_path}/#{file}", "#{shared_path}"
137
- else
138
- new_file_path = File.join(shared_path, file)
139
- debug "Deleting existing environment file: #{new_file_path}"
140
- sudo :rm, '-rf', new_file_path
141
-
142
- debug "Creating a symlink for environment file #{remote_shared_files_path}/#{file}..."
143
- sudo :ln, '-sf', "#{remote_shared_files_path}/#{file}", "#{shared_path}/#{file}"
144
- end
145
- end
146
- end
147
-
148
- #absolute directories and files need to explicitly link files (can't just link to remote file folder)
149
- if File.directory?("#{local_shared_files_path}/.absolute_paths")
150
- files = Find.find(local_shared_files_path)
151
- absolute_path_files, shared_files = files.partition { |f| f.start_with? "#{local_shared_files_path}/.absolute_paths" }
152
-
153
- absolute_path_files.each do |file|
154
- relative_path = file.gsub("#{local_shared_files_path}/.absolute_paths", '')
155
- filename = Pathname.new(relative_path).basename
156
-
157
- if File.directory?(file) && relative_path.strip != ''
158
- #we need to create the directories because symlinks don't created nested folders
159
- execute :mkdir, '-p', relative_path
160
- elsif relative_path.gsub(/\s+/, '') != '' and relative_path != '.' and relative_path != '..'
161
- original_location = File.join(remote_shared_files_path, ".absolute_paths", relative_path)
162
- debug "Creating a symlink from environment file #{original_location} to #{relative_path}..."
163
- sudo :ln, '-sf', original_location, relative_path
164
- end
165
- end
166
- end
167
125
  end
168
126
  end
169
127
 
@@ -215,4 +173,61 @@ namespace :psw_peppr_app_deploy do
215
173
  desc "Optional steps to execute a Peppr deployment after a Capistrano deploy has finished"
216
174
  task post_deploy_steps: [:'link_artifacts'] do
217
175
  end
176
+
177
+ desc "Create symlinks for the current deployment environment files"
178
+ task :symlink_env_files do
179
+ on roles(:app) do |host|
180
+ info "Creating symlinks for environment files..."
181
+ local_shared_files_path = PepprAppDeployFileUtils::Local::get_deployment_shared_files_dir
182
+ remote_shared_files_path = PepprAppDeployFileUtils::Remote::get_deployment_shared_files_dir
183
+
184
+ #this will only list the top-level folders and files, nested will show as a result of the link
185
+ if File.directory?(local_shared_files_path)
186
+ Dir.foreach(local_shared_files_path) do |file|
187
+ next if file == '.' || file == '..' || file == '.absolute_paths'
188
+
189
+ if File.directory?(file)
190
+ new_file_path = File.join(shared_path, file)
191
+ debug "Deleting existing environment file: #{new_file_path}"
192
+ sudo :rm, '-rf', new_file_path
193
+
194
+ debug "Creating a symlink for environment folder #{remote_shared_files_path}/#{file}..."
195
+ sudo :ln, '-sf', "#{remote_shared_files_path}/#{file}", "#{shared_path}"
196
+ else
197
+ new_file_path = File.join(shared_path, file)
198
+ debug "Deleting existing environment file: #{new_file_path}"
199
+ sudo :rm, '-rf', new_file_path
200
+
201
+ debug "Creating a symlink for environment file #{remote_shared_files_path}/#{file}..."
202
+ sudo :ln, '-sf', "#{remote_shared_files_path}/#{file}", "#{shared_path}/#{file}"
203
+ end
204
+ end
205
+ end
206
+
207
+ #absolute directories and files need to explicitly link files (can't just link to remote file folder)
208
+ if File.directory?("#{local_shared_files_path}/.absolute_paths")
209
+ files = Find.find(local_shared_files_path)
210
+ absolute_path_files, shared_files = files.partition { |f| f.start_with? "#{local_shared_files_path}/.absolute_paths" }
211
+
212
+ absolute_path_files.each do |file|
213
+ relative_path = file.gsub("#{local_shared_files_path}/.absolute_paths", '')
214
+ filename = Pathname.new(relative_path).basename
215
+
216
+ if File.directory?(file) && relative_path.strip != ''
217
+ #we need to create the directories because symlinks don't created nested folders
218
+ execute :mkdir, '-p', relative_path
219
+ elsif relative_path.gsub(/\s+/, '') != '' and relative_path != '.' and relative_path != '..'
220
+ original_location = File.join(remote_shared_files_path, ".absolute_paths", relative_path)
221
+ debug "Creating a symlink from environment file #{original_location} to #{relative_path}..."
222
+ sudo :ln, '-sf', original_location, relative_path
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
228
+ #Need to create symlinks after the Capistrano directory structure exists, but before the Capistrano shared
229
+ #symlinks are created
230
+ #(https://github.com/capistrano/capistrano/blob/6353a02ed63dfe7f16921650e3b6e6d6317f0711/lib/capistrano/tasks/deploy.rake)
231
+ after 'deploy:check:directories', 'psw_peppr_app_deploy:symlink_env_files'
232
+
218
233
  end
@@ -2,6 +2,15 @@ require "rake"
2
2
  require File.expand_path('../spec_helper.rb', __FILE__)
3
3
 
4
4
 
5
+ namespace :check do
6
+ desc 'Check shared and release directories exist'
7
+ task :directories do
8
+ on release_roles :all do
9
+ execute :mkdir, '-pv', shared_path, releases_path
10
+ end
11
+ end
12
+ end
13
+
5
14
  describe "psw_peppr_app_deploy:" do
6
15
  describe "create_deployment_directories" do
7
16
  let(:rake) { Rake::Application.new }
@@ -9,6 +18,8 @@ describe "psw_peppr_app_deploy:" do
9
18
 
10
19
  before do
11
20
  Rake.application = rake
21
+ Rake::Task.define_task('deploy:check:directories')
22
+
12
23
  Rake.application.add_import("./resources/lib/capistrano/tasks/psw-peppr-app-deploy.cap")
13
24
  Rake.application.load_imports()
14
25
  end
@@ -24,6 +35,7 @@ describe "psw_peppr_app_deploy:" do
24
35
 
25
36
  before do
26
37
  Rake.application = rake
38
+ Rake::Task.define_task('deploy:check:directories')
27
39
  Rake.application.add_import("./resources/lib/capistrano/tasks/psw-peppr-app-deploy.cap")
28
40
  Rake.application.load_imports()
29
41
  end
@@ -39,6 +51,7 @@ describe "psw_peppr_app_deploy:" do
39
51
 
40
52
  before do
41
53
  Rake.application = rake
54
+ Rake::Task.define_task('deploy:check:directories')
42
55
  Rake.application.add_import("./resources/lib/capistrano/tasks/psw-peppr-app-deploy.cap")
43
56
  Rake.application.load_imports()
44
57
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  class Object
2
4
  def fetch(key, default=nil)
3
5
  @env_vars = Hash.new unless @env_vars != nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-psw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre35
4
+ version: 1.0.0.pre36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lexmark International Technology S.A