Class: Avm::EacWebappBase0::Deploy
- Inherits:
-
Object
- Object
- Avm::EacWebappBase0::Deploy
show all
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/avm/eac_webapp_base0/deploy.rb,
lib/avm/eac_webapp_base0/deploy/version.rb,
lib/avm/eac_webapp_base0/deploy/git_info.rb,
lib/avm/eac_webapp_base0/deploy/file_unit.rb,
lib/avm/eac_webapp_base0/deploy/appended_directories.rb
Defined Under Namespace
Modules: AppendedDirectories, GitInfo, Version
Classes: FileUnit
Constant Summary
collapse
- DEFAULT_REFERENCE =
'HEAD'
- JOBS =
%w[git_deploy setup_files_units assert_instance_branch request_test].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(instance, options = {}) ⇒ Deploy
Returns a new instance of Deploy.
27
28
29
30
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 27
def initialize(instance, options = {})
@instance = instance
@options = options
end
|
Instance Attribute Details
Returns the value of attribute instance.
25
26
27
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 25
def instance
@instance
end
|
Returns the value of attribute options.
25
26
27
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 25
def options
@options
end
|
Instance Method Details
#assert_instance_branch ⇒ Object
75
76
77
78
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 75
def assert_instance_branch
infom 'Setting instance branch...'
git.execute!('push', git_remote_name, "#{commit_sha1}:refs/heads/#{instance.id}", '-f')
end
|
#build_git_commit ⇒ Object
32
33
34
35
36
37
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 32
def build_git_commit
::Avm::Git::Commit.new(git, commit_sha1).deploy_to_env_path(
instance.host_env,
instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
).variables_source_set(instance)
end
|
#git_deploy ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 60
def git_deploy
infom 'Deploying source code and appended content...'
build_git_commit
.append_directory(template.path)
.append_directories(appended_directories)
.append_file_content(VERSION_TARGET_PATH, version)
.run
end
|
#git_fetch_uncached ⇒ Object
92
93
94
95
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 92
def git_fetch_uncached
infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..."
git.fetch(git_remote_name)
end
|
#git_repository_path ⇒ Object
97
98
99
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 97
def git_repository_path
instance.source_instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
end
|
#git_uncached ⇒ Object
88
89
90
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 88
def git_uncached
::EacLauncher::Git::Base.new(git_repository_path)
end
|
#request_test ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 80
def request_test
infom 'Requesting web interface...'
uri = URI(instance.read_entry('web.url'))
response = ::Net::HTTP.get_response(uri)
infov 'Response status', response.code
fatal_error "Request to #{uri} failed" unless response.code.to_i == 200
end
|
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 39
def run
start_banner
JOBS.each do |job|
run_callbacks job do
send(job)
end
end
::Avm::Result.success('Deployed')
rescue ::Avm::Result::Error => e
e.to_result
end
|
#setup_files_units ⇒ Object
69
70
71
72
73
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 69
def setup_files_units
instance.class.const_get('FILES_UNITS').each do |data_key, fs_path_subpath|
FileUnit.new(self, data_key, fs_path_subpath).run
end
end
|
#start_banner ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/avm/eac_webapp_base0/deploy.rb', line 51
def start_banner
infov 'Instance', instance
infov 'Git reference (User)', git_reference.if_present('- BLANK -')
infov 'Git remote name', git_remote_name
infov 'Git reference (Found)', git_reference_found
infov 'Git commit SHA1', commit_sha1
infov 'Appended directories', appended_directories
end
|