Class: Avm::Stereotypes::EacWebappBase0::Deploy
- Inherits:
-
Object
- Object
- Avm::Stereotypes::EacWebappBase0::Deploy
show all
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/avm/stereotypes/eac_webapp_base0/deploy.rb,
lib/avm/stereotypes/eac_webapp_base0/deploy/version.rb,
lib/avm/stereotypes/eac_webapp_base0/deploy/git_info.rb,
lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb,
lib/avm/stereotypes/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.
28
29
30
31
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 28
def initialize(instance, options = {})
@instance = instance
@options = options
end
|
Instance Attribute Details
#instance ⇒ Object
Returns the value of attribute instance.
26
27
28
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 26
def instance
@instance
end
|
#options ⇒ Object
Returns the value of attribute options.
26
27
28
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 26
def options
@options
end
|
Instance Method Details
#assert_instance_branch ⇒ Object
76
77
78
79
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 76
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
33
34
35
36
37
38
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 33
def build_git_commit
::Avm::Git::Commit.new(git, commit_sha1).deploy_to_env_path(
instance.host_env,
instance.read_entry(:fs_path)
).variables_source_set(instance)
end
|
#git_deploy ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 61
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
93
94
95
96
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 93
def git_fetch_uncached
infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..."
git.fetch(git_remote_name)
end
|
#git_repository_path ⇒ Object
98
99
100
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 98
def git_repository_path
instance.source_instance.read_entry(:fs_path)
end
|
#git_uncached ⇒ Object
89
90
91
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 89
def git_uncached
::EacLauncher::Git::Base.new(git_repository_path)
end
|
#request_test ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 81
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
|
#run ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 40
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
70
71
72
73
74
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 70
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
52
53
54
55
56
57
58
59
|
# File 'lib/avm/stereotypes/eac_webapp_base0/deploy.rb', line 52
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
|