eac_tools 0.86.7 → 0.86.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -9
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm-eac_webapp_base0/Gemfile +8 -0
- data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +25 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/executables.rb +26 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/css/file_apply.rb +48 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/css.rb +22 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/html.rb +43 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/javascript.rb +22 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/json.rb +25 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/provider.rb +24 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/xml.rb +26 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats.rb +11 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_base.rb +33 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_host.rb +78 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_path.rb +42 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base/apache.rb +44 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base/install.rb +22 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base.rb +44 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/appended_directories.rb +27 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/build.rb +50 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb +72 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb +53 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/version.rb +26 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/write_on_target.rb +20 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy.rb +73 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/processes/web_server.rb +37 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/processes.rb +13 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/apache_host.rb +36 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/apache_path.rb +40 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/data/load.rb +60 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/deploy.rb +43 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners.rb +13 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/sources/base.rb +15 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/sources.rb +11 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +7 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0.rb +9 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/css_spec.rb +7 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/css_spec_files/css1.source.css +11 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/css_spec_files/css1.target.css +11 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec.rb +7 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.erb.source +8 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.erb.target +8 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.source +5 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.target +5 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/javascript_spec.rb +7 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/javascript_spec_files/javascript_code1.js.source +29 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/javascript_spec_files/javascript_code1.js.target +21 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/json_spec.rb +7 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/json_spec_files/json_code.json.source +8 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/json_spec_files/json_code.json.target +7 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/xml_spec.rb +7 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/xml_spec_files/xml_code.xml.source +11 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/xml_spec_files/xml_code.xml.target +9 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/instances/base_spec.rb +11 -0
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/sources/base_spec.rb +7 -0
- data/sub/avm-eac_webapp_base0/spec/rubocop_spec.rb +3 -0
- data/sub/avm-eac_webapp_base0/spec/spec_helper.rb +4 -0
- data/sub/avm-eac_webapp_base0/template/avm/eac_webapp_base0/instances/apache_host/no_ssl.conf +11 -0
- data/sub/avm-eac_webapp_base0/template/avm/eac_webapp_base0/instances/apache_path/default.conf +7 -0
- metadata +62 -4
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/files/appender'
|
4
|
+
require 'avm/files/deploy'
|
5
|
+
require 'eac_ruby_utils/envs'
|
6
|
+
require 'eac_ruby_utils/fs/temp'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module EacWebappBase0
|
10
|
+
module Instances
|
11
|
+
class Deploy
|
12
|
+
module Build
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_accessor :build_dir
|
16
|
+
|
17
|
+
def append_instance_content
|
18
|
+
::Avm::Files::Appender
|
19
|
+
.new
|
20
|
+
.variables_source_set(variables_source)
|
21
|
+
.append_templatized_directory(template.path)
|
22
|
+
.append_templatized_directories(appended_directories)
|
23
|
+
.append_file_content(version_target_path, version)
|
24
|
+
.write_appended_on(build_dir)
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_dir_env
|
28
|
+
::EacRubyUtils::Envs.local
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_build_dir
|
32
|
+
self.build_dir = ::EacRubyUtils::Fs::Temp.directory
|
33
|
+
end
|
34
|
+
|
35
|
+
def remove_build_dir
|
36
|
+
build_dir&.remove
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_content
|
40
|
+
infom 'Writing Git source code...'
|
41
|
+
scm.commit(commit_reference).deploy_to_env_path(
|
42
|
+
build_dir_env,
|
43
|
+
build_dir
|
44
|
+
).variables_source_set(variables_source).run
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module EacWebappBase0
|
5
|
+
module Instances
|
6
|
+
class Deploy
|
7
|
+
module Scm
|
8
|
+
DEFAULT_REMOTE_NAME = 'origin'
|
9
|
+
|
10
|
+
def commit_reference_uncached
|
11
|
+
git_fetch
|
12
|
+
r = git.rev_parse(git_reference_found)
|
13
|
+
return r if r
|
14
|
+
|
15
|
+
raise ::Avm::Result::Error, "No commit SHA1 found for \"#{git_reference_found}\""
|
16
|
+
end
|
17
|
+
|
18
|
+
def git_fetch_uncached
|
19
|
+
infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..."
|
20
|
+
git.remote(git_remote_name).fetch
|
21
|
+
end
|
22
|
+
|
23
|
+
def git_reference
|
24
|
+
options[OPTION_REFERENCE] || DEFAULT_REFERENCE
|
25
|
+
end
|
26
|
+
|
27
|
+
def git_reference_found_uncached
|
28
|
+
%w[git_reference instance_branch master_branch].map { |b| send(b) }.find(&:present?) ||
|
29
|
+
raise(
|
30
|
+
::Avm::Result::Error,
|
31
|
+
'No git reference found (Searched for option, instance and master)'
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def git_remote_hashs_uncached
|
36
|
+
git.remote(git_remote_name).ls.hashes
|
37
|
+
end
|
38
|
+
|
39
|
+
def git_remote_name
|
40
|
+
DEFAULT_REMOTE_NAME
|
41
|
+
end
|
42
|
+
|
43
|
+
def git_repository_path
|
44
|
+
instance.source_instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [EacGit::Local]
|
48
|
+
def git_uncached
|
49
|
+
scm.git_repo
|
50
|
+
end
|
51
|
+
|
52
|
+
def instance_branch
|
53
|
+
remote_branch(instance.id)
|
54
|
+
end
|
55
|
+
|
56
|
+
def remote_branch(name)
|
57
|
+
git_remote_hashs.key?("refs/heads/#{name}") ? "#{git_remote_name}/#{name}" : nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def master_branch
|
61
|
+
remote_branch('master')
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [Avm::Scms::Base]
|
65
|
+
def scm
|
66
|
+
instance.application.local_source.scm
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module EacWebappBase0
|
5
|
+
module Instances
|
6
|
+
class Deploy
|
7
|
+
class SetupFilesUnit < ::SimpleDelegator
|
8
|
+
enable_method_class
|
9
|
+
attr_reader :data_key, :fs_path_subpath
|
10
|
+
|
11
|
+
def initialize(deploy, data_key, fs_path_subpath)
|
12
|
+
super(deploy)
|
13
|
+
@data_key = data_key
|
14
|
+
@fs_path_subpath = fs_path_subpath
|
15
|
+
end
|
16
|
+
|
17
|
+
def result
|
18
|
+
assert_source_directory
|
19
|
+
link_source_target
|
20
|
+
end
|
21
|
+
|
22
|
+
def assert_source_directory
|
23
|
+
infom "Asserting \"#{data_key}\" source directory..."
|
24
|
+
instance.host_env.command('mkdir', '-p', source_path).execute!
|
25
|
+
end
|
26
|
+
|
27
|
+
def source_path
|
28
|
+
::File.join(instance.install_data_path, data_key.to_s)
|
29
|
+
end
|
30
|
+
|
31
|
+
def target_path
|
32
|
+
::File.join(instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH),
|
33
|
+
fs_path_subpath.to_s)
|
34
|
+
end
|
35
|
+
|
36
|
+
def link_source_target
|
37
|
+
infom "Linking \"#{data_key}\" directory..."
|
38
|
+
return unless remove_target
|
39
|
+
|
40
|
+
instance.host_env.command('ln', '-s', source_path, target_path).execute!
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# @return [Boolean]
|
46
|
+
def remove_target
|
47
|
+
instance.host_env.command('rm', '-rf', target_path).execute.fetch(:exit_code).zero?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module EacWebappBase0
|
5
|
+
module Instances
|
6
|
+
class Deploy
|
7
|
+
module Version
|
8
|
+
VERSION_TARGET_PATH = 'VERSION'
|
9
|
+
|
10
|
+
def version
|
11
|
+
([::Time.now, commit_reference] + version_git_refs).join('|')
|
12
|
+
end
|
13
|
+
|
14
|
+
def version_git_refs
|
15
|
+
git_remote_hashs.select { |_name, sha1| sha1 == commit_reference }.keys
|
16
|
+
.map { |ref| ref.gsub(%r{\Arefs/}, '') }.reject { |ref| ref == 'HEAD' }
|
17
|
+
end
|
18
|
+
|
19
|
+
def version_target_path
|
20
|
+
VERSION_TARGET_PATH
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacWebappBase0
|
7
|
+
module Instances
|
8
|
+
class Deploy
|
9
|
+
module WriteOnTarget
|
10
|
+
def write_on_target
|
11
|
+
::Avm::Files::Deploy.new(
|
12
|
+
instance.host_env,
|
13
|
+
instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH)
|
14
|
+
).append_plain_directory(build_dir).run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/callbacks'
|
4
|
+
require 'avm/entries/jobs/base'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
require 'eac_templates/core_ext'
|
7
|
+
require 'net/http'
|
8
|
+
|
9
|
+
module Avm
|
10
|
+
module EacWebappBase0
|
11
|
+
module Instances
|
12
|
+
class Deploy
|
13
|
+
require_sub __FILE__, include_modules: true, require_dependency: true
|
14
|
+
|
15
|
+
DEFAULT_REFERENCE = 'HEAD'
|
16
|
+
|
17
|
+
REQUEST_TEST_JOB = 'request_test'
|
18
|
+
JOBS = (%w[create_build_dir build_content append_instance_content write_on_target
|
19
|
+
setup_files_units assert_instance_branch] + [REQUEST_TEST_JOB]).freeze
|
20
|
+
|
21
|
+
include ::Avm::Entries::Jobs::Base
|
22
|
+
|
23
|
+
lists.add_symbol :option, :appended_directories, :no_request_test, :reference
|
24
|
+
|
25
|
+
def option_list
|
26
|
+
::Avm::EacWebappBase0::Instances::Deploy.lists.option
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
super
|
31
|
+
ensure
|
32
|
+
remove_build_dir
|
33
|
+
end
|
34
|
+
|
35
|
+
def start_banner
|
36
|
+
infov 'Instance', instance
|
37
|
+
infov 'Git reference (User)', git_reference.if_present('- BLANK -')
|
38
|
+
infov 'Git remote name', git_remote_name
|
39
|
+
infov 'Git reference (Found)', git_reference_found
|
40
|
+
infov 'Git commit SHA1', commit_reference
|
41
|
+
infov 'Appended directories', appended_directories
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_files_units
|
45
|
+
instance.data_package.units.values.map(&:installation_files_data).select(&:present?)
|
46
|
+
.each { |unit_install| setup_files_unit(unit_install.key, unit_install.subpath) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def assert_instance_branch
|
50
|
+
infom 'Setting instance branch...'
|
51
|
+
git.command('push', git_remote_name, "#{commit_reference}:refs/heads/#{instance.id}",
|
52
|
+
'-f').execute!
|
53
|
+
end
|
54
|
+
|
55
|
+
def request_test
|
56
|
+
infom 'Requesting web interface...'
|
57
|
+
uri = URI(instance.read_entry('web.url'))
|
58
|
+
response = ::Net::HTTP.get_response(uri)
|
59
|
+
infov 'Response status', response.code
|
60
|
+
fatal_error "Request to #{uri} failed" unless response.code.to_i == 200
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def jobs
|
66
|
+
r = super
|
67
|
+
r.delete(REQUEST_TEST_JOB) if options[OPTION_NO_REQUEST_TEST]
|
68
|
+
r
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/process'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module EacWebappBase0
|
8
|
+
module Instances
|
9
|
+
module Processes
|
10
|
+
class WebServer < ::Avm::Instances::Process
|
11
|
+
def available?
|
12
|
+
instance.apache_resource.present?
|
13
|
+
end
|
14
|
+
|
15
|
+
def enable
|
16
|
+
apache_resource_change(__method__)
|
17
|
+
end
|
18
|
+
|
19
|
+
def enabled?
|
20
|
+
instance.apache_resource.enabled?
|
21
|
+
end
|
22
|
+
|
23
|
+
def disable
|
24
|
+
apache_resource_change(__method__)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def apache_resource_change(action)
|
30
|
+
instance.apache_resource.send(action)
|
31
|
+
instance.platform_instance.apache.service(:reload)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacWebappBase0
|
7
|
+
module Instances
|
8
|
+
module Runners
|
9
|
+
class ApacheHost
|
10
|
+
runner_with :help do
|
11
|
+
desc 'Configure Apache virtual host for instance.'
|
12
|
+
bool_opt '-c', '--certbot', 'Install certbot.'
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
result = stereotype_apache_host_class.new(runner_context.call(:instance),
|
17
|
+
stereotype_apache_host_options).run
|
18
|
+
if result.error?
|
19
|
+
fatal_error result.to_s
|
20
|
+
else
|
21
|
+
infov 'Result', result.label
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def stereotype_apache_host_class
|
26
|
+
"#{runner_context.call(:instance).class.name.deconstantize}::ApacheHost".constantize
|
27
|
+
end
|
28
|
+
|
29
|
+
def stereotype_apache_host_options
|
30
|
+
{ certbot: parsed.certbot? }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacWebappBase0
|
7
|
+
module Instances
|
8
|
+
module Runners
|
9
|
+
class ApachePath
|
10
|
+
runner_with :help do
|
11
|
+
desc 'Configure Apache path configuration for instance.'
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
infov 'ApachePath class', stereotype_apache_path_class
|
16
|
+
if result.error?
|
17
|
+
fatal_error result.to_s
|
18
|
+
else
|
19
|
+
infov 'Result', result.label
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def apache_path_uncached
|
26
|
+
stereotype_apache_path_class.new(runner_context.call(:instance))
|
27
|
+
end
|
28
|
+
|
29
|
+
def result_uncached
|
30
|
+
apache_path.run
|
31
|
+
end
|
32
|
+
|
33
|
+
def stereotype_apache_path_class
|
34
|
+
runner_context.call(:instance).apache_path_class
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/numeric/time'
|
4
|
+
require 'avm/result'
|
5
|
+
require 'eac_cli/speaker'
|
6
|
+
require 'eac_ruby_utils/simple_cache'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module EacWebappBase0
|
10
|
+
module Instances
|
11
|
+
module Runners
|
12
|
+
class Data
|
13
|
+
class Load
|
14
|
+
runner_with :help do
|
15
|
+
desc 'Load utility for EacRailsBase instance.'
|
16
|
+
arg_opt '-S', '--source-instance', 'Informa a instância a ser extraída o dump.'
|
17
|
+
pos_arg :dump_path, optional: true
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
return fatal_error("Dump \"#{dump_path}\" does not exist") unless
|
22
|
+
::File.exist?(dump_path)
|
23
|
+
|
24
|
+
load_dump
|
25
|
+
success("Dump loaded from \"#{dump_path}\"")
|
26
|
+
end
|
27
|
+
|
28
|
+
def dump_path_uncached
|
29
|
+
return parsed.dump_path.to_s if parsed.dump_path.present?
|
30
|
+
return source_instance_dump_path if parsed.source_instance.present?
|
31
|
+
|
32
|
+
raise "Dump path unknown (Options: #{parsed})"
|
33
|
+
end
|
34
|
+
|
35
|
+
def source_instance_dump_path
|
36
|
+
runner_context.call(:instance).class.by_id(parsed.source_instance).run_subcommand(
|
37
|
+
::Avm::EacWebappBase0::Instances::Runners::Data::Dump, []
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def load_dump
|
42
|
+
info "Loading dump \"#{dump_path}\"..."
|
43
|
+
package_load.run
|
44
|
+
end
|
45
|
+
|
46
|
+
def dump_instance_method
|
47
|
+
:dump_database
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def package_load_uncached
|
53
|
+
runner_context.call(:instance).data_package.load(dump_path)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/runner'
|
4
|
+
require 'avm/path_string'
|
5
|
+
require 'eac_cli/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module EacWebappBase0
|
9
|
+
module Instances
|
10
|
+
module Runners
|
11
|
+
class Deploy
|
12
|
+
runner_with :help do
|
13
|
+
desc 'Deploy for instance.'
|
14
|
+
arg_opt '-r', '--reference', 'Git reference to deploy.'
|
15
|
+
arg_opt '-a', '--append-dirs', 'Append directories to deploy (List separated by ":").'
|
16
|
+
bool_opt '-T', '--no-request-test', 'Do not test web interface after deploy.'
|
17
|
+
end
|
18
|
+
|
19
|
+
def deploy_class
|
20
|
+
runner_context.call(:stereotype_module).const_get('Instances').const_get('Deploy')
|
21
|
+
rescue ::NameError
|
22
|
+
runner_context.call(:stereotype_module).const_get('Deploy')
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
result = deploy_class.new(runner_context.call(:instance), deploy_options).run
|
27
|
+
if result.error?
|
28
|
+
fatal_error result.to_s
|
29
|
+
else
|
30
|
+
infov 'Result', result.label
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def deploy_options
|
35
|
+
{ reference: parsed.reference,
|
36
|
+
appended_directories: ::Avm::PathString.paths(parsed.append_dirs),
|
37
|
+
no_request_test: parsed.no_request_test? }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|