dkdeploy-core 9.0.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +36 -8
- data/.travis.yml +7 -5
- data/Berksfile +2 -0
- data/Berksfile.lock +36 -35
- data/CHANGELOG.md +48 -1
- data/CONTRIBUTORS.md +3 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +11 -12
- data/Rakefile +2 -0
- data/Vagrantfile +14 -14
- data/config/vm/cookbooks/dkdeploy-core/metadata.rb +4 -4
- data/config/vm/cookbooks/dkdeploy-core/recipes/default.rb +11 -13
- data/dkdeploy-core.gemspec +13 -11
- data/features/assets.feature +0 -1
- data/features/file_access.feature +2 -2
- data/features/mysql.feature +2 -2
- data/features/support/env.rb +4 -2
- data/features/utils.feature +3 -3
- data/lib/capistrano/dkdeploy/core.rb +14 -17
- data/lib/dkdeploy.rb +2 -0
- data/lib/dkdeploy/constants.rb +2 -0
- data/lib/dkdeploy/core/version.rb +3 -1
- data/lib/dkdeploy/dsl.rb +4 -3
- data/lib/dkdeploy/helpers/assets.rb +2 -0
- data/lib/dkdeploy/helpers/common.rb +2 -0
- data/lib/dkdeploy/helpers/db.rb +7 -5
- data/lib/dkdeploy/helpers/file_system.rb +7 -12
- data/lib/dkdeploy/helpers/mysql.rb +3 -0
- data/lib/dkdeploy/i18n.rb +3 -12
- data/lib/dkdeploy/interaction_handler/mysql.rb +4 -1
- data/lib/dkdeploy/interaction_handler/password.rb +3 -1
- data/lib/dkdeploy/rollback_manager.rb +2 -0
- data/lib/dkdeploy/scm/copy.rake +39 -12
- data/lib/dkdeploy/scm/copy.rb +7 -45
- data/lib/dkdeploy/tasks/apache.rake +2 -0
- data/lib/dkdeploy/tasks/assets.rake +3 -1
- data/lib/dkdeploy/tasks/current_folder.rake +3 -1
- data/lib/dkdeploy/tasks/db.rake +138 -154
- data/lib/dkdeploy/tasks/deploy.rake +5 -3
- data/lib/dkdeploy/tasks/enhanced_symlinks.rake +7 -0
- data/lib/dkdeploy/tasks/fail.rake +2 -0
- data/lib/dkdeploy/tasks/file_access.rake +2 -0
- data/lib/dkdeploy/tasks/maintenance.rake +4 -3
- data/lib/dkdeploy/tasks/mysql.rake +5 -0
- data/lib/dkdeploy/tasks/project_version.rake +3 -3
- data/lib/dkdeploy/tasks/utils.rake +2 -0
- data/spec/fixtures/application/Capfile +2 -0
- data/spec/fixtures/application/Gemfile +3 -1
- data/spec/fixtures/application/config/deploy.rb +25 -23
- data/spec/fixtures/application/config/deploy/dev.rb +3 -1
- data/spec/fixtures/capistrano/configuration/add_output_after_create_symlink.rb +1 -0
- data/spec/fixtures/capistrano/configuration/custom_compass_sources.rb +2 -0
- data/spec/fixtures/capistrano/configuration/custom_file_access.rb +2 -0
- data/spec/fixtures/capistrano/configuration/default_deployment_behaviour.rb +2 -0
- metadata +40 -47
- data/features/bower.feature +0 -52
- data/lib/capistrano/copy.rb +0 -2
- data/lib/dkdeploy/tasks/bower.rake +0 -53
- data/spec/fixtures/application/htdocs/bower.json +0 -15
data/dkdeploy-core.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'dkdeploy/core/version'
|
4
6
|
|
@@ -11,23 +13,23 @@ Gem::Specification.new do |spec|
|
|
11
13
|
spec.description = 'dkd basic deployment tasks and strategies'
|
12
14
|
spec.summary = 'dkd basic deployment tasks and strategies'
|
13
15
|
spec.homepage = 'https://github.com/dkdeploy/dkdeploy-core'
|
14
|
-
spec.required_ruby_version = '~> 2.
|
16
|
+
spec.required_ruby_version = '~> 2.5'
|
15
17
|
|
16
18
|
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
21
|
spec.require_paths = ['lib']
|
20
22
|
|
23
|
+
spec.add_development_dependency 'aruba', '~> 1.0'
|
21
24
|
spec.add_development_dependency 'bundler'
|
22
|
-
spec.add_development_dependency 'rake'
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.5'
|
24
25
|
spec.add_development_dependency 'cucumber', '~> 2.4'
|
25
|
-
spec.add_development_dependency '
|
26
|
-
spec.add_development_dependency 'aruba', '~> 0.14.1'
|
26
|
+
spec.add_development_dependency 'dkdeploy-test_environment', '~> 2.0'
|
27
27
|
spec.add_development_dependency 'mysql2', '~> 0.3'
|
28
28
|
spec.add_development_dependency 'pry', '~> 0.10'
|
29
|
-
spec.add_development_dependency '
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.86.0'
|
30
32
|
|
31
|
-
spec.add_dependency 'capistrano', '~> 3.
|
32
|
-
spec.add_dependency 'highline', '~>
|
33
|
+
spec.add_dependency 'capistrano', '~> 3.14.1'
|
34
|
+
spec.add_dependency 'highline', '~> 2.0.3'
|
33
35
|
end
|
data/features/assets.feature
CHANGED
@@ -37,7 +37,6 @@ Feature: Test tasks for namespace 'assets'
|
|
37
37
|
And I run `cap dev assets:add_htpasswd` interactively
|
38
38
|
And I type "dkd_test_user"
|
39
39
|
And I type "dkd_test_password"
|
40
|
-
And I close the stdin stream
|
41
40
|
Then the exit status should be 0
|
42
41
|
And a remote file named "shared_path/.htpasswd" should exist
|
43
42
|
|
@@ -87,7 +87,7 @@ Feature: Test tasks for namespace 'file_permissions'
|
|
87
87
|
Given I extend the development capistrano configuration variable custom_file_access with value {app: {release_path: {catalog: {mode: 'u+rwx,g+rwx,o-wx'}, not_existing: {mode: 'u+rwx,g+rwx,o-wx'}}}}
|
88
88
|
And a remote directory named "releases_path/not_existing" should not exist
|
89
89
|
When I successfully run `cap dev file_access:set_custom_access`
|
90
|
-
Then the output should contain "The resource /var/www/dkdeploy/current/not_existing does not exist on host dkdeploy-core.
|
90
|
+
Then the output should contain "The resource /var/www/dkdeploy/current/not_existing does not exist on host dkdeploy-core.test"
|
91
91
|
And the output should not contain "sudo chmod u+rwx,g+rwx,o-wx /var/www/dkdeploy/current/not_existing"
|
92
92
|
And the output should contain "sudo chmod u+rwx,g+rwx,o-wx /var/www/dkdeploy/current/catalog"
|
93
93
|
|
@@ -115,6 +115,6 @@ Feature: Test tasks for namespace 'file_permissions'
|
|
115
115
|
And I extend the development capistrano configuration variable selected_custom_file_access with value [:not_existing, :catalog]
|
116
116
|
And a remote directory named "releases_path/not_existing" should not exist
|
117
117
|
When I successfully run `cap dev file_access:set_selected_custom_access`
|
118
|
-
Then the output should contain "The resource /var/www/dkdeploy/current/not_existing does not exist on host dkdeploy-core.
|
118
|
+
Then the output should contain "The resource /var/www/dkdeploy/current/not_existing does not exist on host dkdeploy-core.test"
|
119
119
|
And the output should not contain "sudo chmod -R u+rwx,g+rwx,o-wx /var/www/dkdeploy/current/not_existing"
|
120
120
|
And the output should contain "sudo chmod -R u+rwx,g+rwx,o-wx /var/www/dkdeploy/current/catalog"
|
data/features/mysql.feature
CHANGED
@@ -10,14 +10,14 @@ Feature: Test tasks for namespace 'mysql'
|
|
10
10
|
And I successfully run `cap dev "db:update[temp,dkdeploy_core.sql.gz]"`
|
11
11
|
And I successfully run `cap dev db:download_content`
|
12
12
|
And I successfully run `cap dev mysql:download_slow_log`
|
13
|
-
Then a file named "temp/slow-queries.dev.dkdeploy-core.
|
13
|
+
Then a file named "temp/slow-queries.dev.dkdeploy-core.test.log" should exist
|
14
14
|
|
15
15
|
Scenario: Downloading the MYSQL slow log analyze file
|
16
16
|
When I successfully run `cap dev "db:upload_settings[127.0.0.1,3306,dkdeploy_core,root,ilikerandompasswords,utf8]"`
|
17
17
|
And I successfully run `cap dev "db:update[temp,dkdeploy_core.sql.gz]"`
|
18
18
|
And I successfully run `cap dev db:download_content`
|
19
19
|
And I successfully run `cap dev mysql:analyze_download_slow_log`
|
20
|
-
Then a file named "temp/mysql_slow_log_analyze.dev.dkdeploy-core.
|
20
|
+
Then a file named "temp/mysql_slow_log_analyze.dev.dkdeploy-core.test.log" should exist
|
21
21
|
|
22
22
|
Scenario: Clearing the MySQL slow log file
|
23
23
|
When I successfully run `cap dev "db:upload_settings[127.0.0.1,3306,dkdeploy_core,root,ilikerandompasswords,utf8]"`
|
data/features/support/env.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'dkdeploy/test_environment/application'
|
2
4
|
|
3
5
|
ssh_config = {}
|
@@ -11,8 +13,8 @@ unless ssh_key_files.empty?
|
|
11
13
|
}
|
12
14
|
end
|
13
15
|
|
14
|
-
TEST_APPLICATION = Dkdeploy::TestEnvironment::Application.new(File.expand_path('
|
15
|
-
TEST_APPLICATION.mysql_connection_settings = { host: 'dkdeploy-core.
|
16
|
+
TEST_APPLICATION = Dkdeploy::TestEnvironment::Application.new(File.expand_path('../..', __dir__), 'dkdeploy-core.test', ssh_config)
|
17
|
+
TEST_APPLICATION.mysql_connection_settings = { host: 'dkdeploy-core.test', username: 'root', password: 'ilikerandompasswords' }
|
16
18
|
|
17
19
|
# this configuration tricks Bundler into executing another Bundler project with clean enviroment
|
18
20
|
# The official way via Bundler.with_clean_env did not work properly here
|
data/features/utils.feature
CHANGED
@@ -28,10 +28,10 @@ Feature: Test tasks for namespace 'utils'
|
|
28
28
|
Remote file content
|
29
29
|
"""
|
30
30
|
When I successfully run `cap dev utils:download_file['download_file.txt']`
|
31
|
-
Then a file named "temp/download_file.dkdeploy-core.
|
31
|
+
Then a file named "temp/download_file.dkdeploy-core.test.txt" should exist
|
32
32
|
|
33
33
|
Scenario: Download a file from server which does exist locally
|
34
|
-
Given a file named "temp/download_file.dkdeploy-core.
|
34
|
+
Given a file named "temp/download_file.dkdeploy-core.test.txt" with:
|
35
35
|
"""
|
36
36
|
Local file content
|
37
37
|
"""
|
@@ -41,7 +41,7 @@ Local file content
|
|
41
41
|
Remote file content
|
42
42
|
"""
|
43
43
|
When I successfully run `cap dev utils:download_file['download_file.txt']`
|
44
|
-
Then the file "temp/download_file.dkdeploy-core.
|
44
|
+
Then the file "temp/download_file.dkdeploy-core.test.txt" should contain exactly:
|
45
45
|
"""
|
46
46
|
Remote file content
|
47
47
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include Capistrano::DSL
|
2
4
|
|
3
5
|
require 'dkdeploy/rollback_manager'
|
@@ -7,19 +9,18 @@ require 'dkdeploy/scm/copy'
|
|
7
9
|
install_plugin Dkdeploy::SCM::Copy
|
8
10
|
|
9
11
|
# Load dkdeploy tasks
|
10
|
-
load File.expand_path('
|
11
|
-
load File.expand_path('
|
12
|
-
load File.expand_path('
|
13
|
-
load File.expand_path('
|
14
|
-
load File.expand_path('
|
15
|
-
load File.expand_path('
|
16
|
-
load File.expand_path('
|
17
|
-
load File.expand_path('
|
18
|
-
load File.expand_path('
|
19
|
-
load File.expand_path('
|
20
|
-
load File.expand_path('
|
21
|
-
load File.expand_path('
|
22
|
-
load File.expand_path('../../../dkdeploy/tasks/mysql.rake', __FILE__)
|
12
|
+
load File.expand_path('../../dkdeploy/tasks/deploy.rake', __dir__)
|
13
|
+
load File.expand_path('../../dkdeploy/tasks/fail.rake', __dir__)
|
14
|
+
load File.expand_path('../../dkdeploy/tasks/maintenance.rake', __dir__)
|
15
|
+
load File.expand_path('../../dkdeploy/tasks/utils.rake', __dir__)
|
16
|
+
load File.expand_path('../../dkdeploy/tasks/file_access.rake', __dir__)
|
17
|
+
load File.expand_path('../../dkdeploy/tasks/assets.rake', __dir__)
|
18
|
+
load File.expand_path('../../dkdeploy/tasks/apache.rake', __dir__)
|
19
|
+
load File.expand_path('../../dkdeploy/tasks/project_version.rake', __dir__)
|
20
|
+
load File.expand_path('../../dkdeploy/tasks/db.rake', __dir__)
|
21
|
+
load File.expand_path('../../dkdeploy/tasks/enhanced_symlinks.rake', __dir__)
|
22
|
+
load File.expand_path('../../dkdeploy/tasks/current_folder.rake', __dir__)
|
23
|
+
load File.expand_path('../../dkdeploy/tasks/mysql.rake', __dir__)
|
23
24
|
|
24
25
|
# Hook into symlink related tasks
|
25
26
|
after 'deploy:check:linked_dirs', 'deploy:enhanced_symlinks:check:linked_dirs'
|
@@ -56,10 +57,6 @@ namespace :load do
|
|
56
57
|
# Number of archives to keep around
|
57
58
|
set :keep_rollback_archives, 5
|
58
59
|
|
59
|
-
# List of bower.json files
|
60
|
-
set(:bower_path, -> { fetch(:copy_source) })
|
61
|
-
set(:bower_paths, -> { Array(fetch(:copy_source)) })
|
62
|
-
|
63
60
|
# List of filters for file_access:set_selected_custom_access
|
64
61
|
set :selected_custom_file_access, []
|
65
62
|
|
data/lib/dkdeploy.rb
CHANGED
data/lib/dkdeploy/constants.rb
CHANGED
data/lib/dkdeploy/dsl.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Dkdeploy
|
2
4
|
# dsl api
|
3
5
|
module DSL
|
@@ -6,15 +8,14 @@ module Dkdeploy
|
|
6
8
|
# @param server [Capistrano::Configuration::Server] Server to execute task
|
7
9
|
# @param task [String] Name of rake/capistrano task
|
8
10
|
# @param args [Array] Arguments of rake/capistrano task
|
9
|
-
def invoke_for_server(server, task, *args)
|
11
|
+
def invoke_for_server(server, task, *args)
|
10
12
|
backup_filter = fetch :filter, {}
|
11
13
|
new_server_filter = Marshal.load(Marshal.dump(backup_filter))
|
12
14
|
new_server_filter[:host] = server.hostname
|
13
15
|
set :filter, new_server_filter
|
14
16
|
env.setup_filters
|
15
17
|
info I18n.t('dsl.invoke_for_server.set_filter', task: task, host: server.hostname, scope: :dkdeploy)
|
16
|
-
invoke task, *args
|
17
|
-
Rake::Task[task].reenable
|
18
|
+
invoke! task, *args
|
18
19
|
ensure
|
19
20
|
set :filter, backup_filter
|
20
21
|
env.setup_filters
|
data/lib/dkdeploy/helpers/db.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
|
3
5
|
include Capistrano::DSL
|
@@ -7,7 +9,7 @@ module Dkdeploy
|
|
7
9
|
# DB related helpers
|
8
10
|
module DB
|
9
11
|
def db_dump_file(infix = '')
|
10
|
-
date =
|
12
|
+
date = Time.now.strftime(datetime_format)
|
11
13
|
['database', fetch(:stage), infix, date].join('-') << '.sql'
|
12
14
|
end
|
13
15
|
|
@@ -22,12 +24,12 @@ module Dkdeploy
|
|
22
24
|
def db_settings_hash
|
23
25
|
{
|
24
26
|
'database' => {
|
25
|
-
'host'
|
26
|
-
'port'
|
27
|
-
'name'
|
27
|
+
'host' => fetch(:db_host),
|
28
|
+
'port' => fetch(:db_port),
|
29
|
+
'name' => fetch(:db_name),
|
28
30
|
'username' => fetch(:db_username),
|
29
31
|
'password' => fetch(:db_password),
|
30
|
-
'charset'
|
32
|
+
'charset' => fetch(:db_charset)
|
31
33
|
}
|
32
34
|
}
|
33
35
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include Capistrano::DSL
|
2
4
|
|
3
5
|
module Dkdeploy
|
@@ -22,9 +24,8 @@ module Dkdeploy
|
|
22
24
|
# @param path [String] path to resolve
|
23
25
|
# @return [String]
|
24
26
|
def resolve_path_if_symlink(context, path)
|
25
|
-
if context.test " [ -L #{path} ] "
|
26
|
-
|
27
|
-
end
|
27
|
+
return context.capture :readlink, '-f', path if context.test " [ -L #{path} ] "
|
28
|
+
|
28
29
|
path
|
29
30
|
end
|
30
31
|
|
@@ -57,19 +58,13 @@ module Dkdeploy
|
|
57
58
|
resolved_path = resolve_path_if_symlink(context, path)
|
58
59
|
|
59
60
|
# change owner if set
|
60
|
-
if access_properties.key?(:owner)
|
61
|
-
context.execute :chown, recursive, access_properties.fetch(:owner), resolved_path
|
62
|
-
end
|
61
|
+
context.execute :chown, recursive, access_properties.fetch(:owner), resolved_path if access_properties.key?(:owner)
|
63
62
|
|
64
63
|
# change group if set
|
65
|
-
if access_properties.key?(:group)
|
66
|
-
context.execute :chgrp, recursive, access_properties.fetch(:group), resolved_path
|
67
|
-
end
|
64
|
+
context.execute :chgrp, recursive, access_properties.fetch(:group), resolved_path if access_properties.key?(:group)
|
68
65
|
|
69
66
|
# change mode if set
|
70
|
-
if access_properties.key?(:mode)
|
71
|
-
context.execute :chmod, recursive, access_properties.fetch(:mode), resolved_path
|
72
|
-
end
|
67
|
+
context.execute :chmod, recursive, access_properties.fetch(:mode), resolved_path if access_properties.key?(:mode)
|
73
68
|
end
|
74
69
|
end
|
75
70
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include Capistrano::DSL
|
2
4
|
|
3
5
|
module Dkdeploy
|
@@ -9,6 +11,7 @@ module Dkdeploy
|
|
9
11
|
# @return [Boolean]
|
10
12
|
def slow_log_exists?(file_path)
|
11
13
|
return true if !file_path.empty? && test("[ -f #{file_path} ]")
|
14
|
+
|
12
15
|
error I18n.t('file.not_exists_or_not_accessible_on_host', file: file_path, host: server, scope: :dkdeploy)
|
13
16
|
false
|
14
17
|
end
|
data/lib/dkdeploy/i18n.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'i18n'
|
2
4
|
|
3
5
|
en = {
|
@@ -42,11 +44,6 @@ en = {
|
|
42
44
|
charset: 'Please enter the database character set',
|
43
45
|
zipped_db_file: 'Please enter the name of the zipped SQL script file'
|
44
46
|
},
|
45
|
-
bower: {
|
46
|
-
command: 'Please enter the command you want to run',
|
47
|
-
path: 'Please enter the path to the bower.json file',
|
48
|
-
paths: 'Please enter the paths bower.json files (separated by spaces)'
|
49
|
-
},
|
50
47
|
selected_custom_file_access: {
|
51
48
|
paths: 'Please enter a list of paths (entries separated by spaces)'
|
52
49
|
},
|
@@ -94,10 +91,6 @@ en = {
|
|
94
91
|
upload_extract: 'Extracting %{file}',
|
95
92
|
exclude_file_not_found: "No exclude file found. To use set variable 'assets_exclude_file'"
|
96
93
|
},
|
97
|
-
bower: {
|
98
|
-
skipping_missing_directory: 'Skipping directory %{bower_path} because it does not exist.',
|
99
|
-
skipping_directory_with_missing_bower_file: 'Skipping directory %{bower_path} because it does not contain a bower.json file.'
|
100
|
-
},
|
101
94
|
copy: {
|
102
95
|
archive: {
|
103
96
|
generate: 'Generating the tar archive.',
|
@@ -144,6 +137,4 @@ capistrano_i18n_overwritten = {
|
|
144
137
|
I18n.backend.store_translations(:en, dkdeploy: en)
|
145
138
|
I18n.backend.store_translations(:en, capistrano: capistrano_i18n_overwritten)
|
146
139
|
|
147
|
-
if I18n.respond_to?(:enforce_available_locales=)
|
148
|
-
I18n.enforce_available_locales = true
|
149
|
-
end
|
140
|
+
I18n.enforce_available_locales = true if I18n.respond_to?(:enforce_available_locales=)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Dkdeploy
|
2
4
|
module InteractionHandler
|
3
5
|
# Interaction handler for mysql
|
@@ -26,8 +28,9 @@ module Dkdeploy
|
|
26
28
|
else
|
27
29
|
@mysql_error_seen = true if data =~ /.*ERROR.*/i
|
28
30
|
return raise 'Unexpected data from stream. Can not send password to undefined stream' unless @mysql_error_seen
|
31
|
+
|
29
32
|
# combine the multiple lines from error message. The fact that the error message will be shown multiple times is simply ignored
|
30
|
-
@return_message
|
33
|
+
@return_message += data
|
31
34
|
message = 'Error on executing MySQL command! Response (error code) is: '
|
32
35
|
SSHKit.config.output.send(:error, "#{message}\n #{@return_message}")
|
33
36
|
raise 'InteractionHandler caught a MySQL error'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Dkdeploy
|
2
4
|
module InteractionHandler
|
3
5
|
# Interaction handler for password
|
@@ -20,7 +22,7 @@ module Dkdeploy
|
|
20
22
|
channel.send_data("#{@password}\n")
|
21
23
|
else
|
22
24
|
channel.close
|
23
|
-
raise 'Unexpected data from stream. Can not send password to undefined stream'
|
25
|
+
raise 'Unexpected data from stream. Can not send password to undefined stream.'
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/dkdeploy/scm/copy.rake
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
#
|
2
|
-
copy_plugin = self
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
namespace :copy do
|
5
4
|
desc 'Check if all configuration variables and copy sources exist'
|
@@ -24,11 +23,11 @@ namespace :copy do
|
|
24
23
|
|
25
24
|
# generate an exclude.txt file with the patterns to be excluded
|
26
25
|
exclude_content = copy_exclude.join("\n")
|
27
|
-
File.write(
|
26
|
+
File.write(local_exclude_path, exclude_content)
|
28
27
|
|
29
28
|
# build the tar archive excluding the patterns from exclude.txt
|
30
29
|
within copy_source do
|
31
|
-
execute :tar, '-X ' +
|
30
|
+
execute :tar, '-X ' + local_exclude_path, '-cpzf', local_archive_path, '.'
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
@@ -38,17 +37,17 @@ namespace :copy do
|
|
38
37
|
#
|
39
38
|
task :copy_archive_to_server do
|
40
39
|
on release_roles :all do
|
41
|
-
info I18n.t('file.upload', file: 'archive', target:
|
42
|
-
execute :mkdir, '-p',
|
40
|
+
info I18n.t('file.upload', file: 'archive', target: remote_tmp_dir, scope: :dkdeploy)
|
41
|
+
execute :mkdir, '-p', remote_tmp_dir
|
43
42
|
|
44
|
-
upload!
|
43
|
+
upload! local_archive_path, remote_tmp_dir
|
45
44
|
|
46
45
|
info I18n.t('directory.create', directory: release_path, scope: :dkdeploy)
|
47
46
|
execute :mkdir, '-p', release_path
|
48
47
|
|
49
48
|
within release_path do
|
50
49
|
info I18n.t('tasks.copy.archive.extract', target: release_path, scope: :dkdeploy)
|
51
|
-
execute :tar, '-xpzf',
|
50
|
+
execute :tar, '-xpzf', remote_archive_path
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
@@ -58,14 +57,14 @@ namespace :copy do
|
|
58
57
|
task :clean_up_temporary_sources do
|
59
58
|
# remove the local temporary directory
|
60
59
|
run_locally do
|
61
|
-
info I18n.t('file.remove', path:
|
62
|
-
execute :rm, '-rf',
|
60
|
+
info I18n.t('file.remove', path: fetch(:copy_local_tmp_dir), scope: :dkdeploy)
|
61
|
+
execute :rm, '-rf', fetch(:copy_local_tmp_dir)
|
63
62
|
end
|
64
63
|
|
65
64
|
# removes the remote temp path including the uploaded archive
|
66
65
|
on release_roles :all do
|
67
|
-
info I18n.t('file.remove', path:
|
68
|
-
execute :rm, '-rf',
|
66
|
+
info I18n.t('file.remove', path: remote_archive_path, scope: :dkdeploy)
|
67
|
+
execute :rm, '-rf', remote_archive_path
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
@@ -73,4 +72,32 @@ namespace :copy do
|
|
73
72
|
task :set_current_revision do
|
74
73
|
set :current_revision, I18n.t('log.revision_log_message', copy_source: fetch(:copy_source), time: Time.now, scope: :dkdeploy)
|
75
74
|
end
|
75
|
+
|
76
|
+
# Archive path in a local temporary directory
|
77
|
+
#
|
78
|
+
# @return [String]
|
79
|
+
def local_exclude_path
|
80
|
+
File.join fetch(:copy_local_tmp_dir), 'exclude.txt'
|
81
|
+
end
|
82
|
+
|
83
|
+
# Archive path in a local temporary directory
|
84
|
+
#
|
85
|
+
# @return [String]
|
86
|
+
def local_archive_path
|
87
|
+
File.join fetch(:copy_local_tmp_dir), fetch(:copy_archive_filename)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Remote temporary directory path
|
91
|
+
#
|
92
|
+
# @return [String]
|
93
|
+
def remote_tmp_dir
|
94
|
+
File.join fetch(:tmp_dir), application
|
95
|
+
end
|
96
|
+
|
97
|
+
# Archive path in a remote temporary directory
|
98
|
+
#
|
99
|
+
# @return [String]
|
100
|
+
def remote_archive_path
|
101
|
+
File.join remote_tmp_dir, fetch(:copy_archive_filename)
|
102
|
+
end
|
76
103
|
end
|