avm-tools 0.27.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/path_string.rb +27 -0
- data/lib/avm/stereotypes/eac_webapp_base0/deploy.rb +22 -41
- data/lib/avm/stereotypes/eac_webapp_base0/deploy/_appended_directories.rb +25 -0
- data/lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb +43 -0
- data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +1 -0
- data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +8 -1
- data/lib/avm/tools/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9056924dbceab142648a79e5da4b931c3391e2138fdf10196e0b0b7f79a529f
|
4
|
+
data.tar.gz: b09f24e9e27940bfc314a9e4d236470ff6d0c0fd2e4d5b42f80b78f37848cf0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52a94ce93193368d76c1985d691672470699a54febfa7f957f0c48c1c0983bbc78e7b5d985c144a0678a9320577215f3be5a68a401678c708def8ba2f2dd3ccd
|
7
|
+
data.tar.gz: 644e16d5d4bfc5d74b0410cad8ad382ceabb0cae1a9822dd1b9650fa9c711deab8060fd3566176e82b4baaf669a49c1473d2ab4859d7756c24f3fe8ce4cb7327
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
# String with paths like PATH variable.
|
7
|
+
# Note: the separator is not system dependent.
|
8
|
+
class PathString < String
|
9
|
+
SEPARATOR = ':'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Shortcut for [Avm::Paths.new(string).paths].
|
13
|
+
def paths(string)
|
14
|
+
new(string).paths
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(string = nil)
|
19
|
+
super(string.to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array] List of paths. Blank paths are rejected.
|
23
|
+
def paths
|
24
|
+
split(SEPARATOR).reject(&:blank?)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -14,17 +14,28 @@ module Avm
|
|
14
14
|
class Deploy
|
15
15
|
include ::ActiveSupport::Callbacks
|
16
16
|
|
17
|
+
require_relative 'deploy/_appended_directories'
|
18
|
+
|
19
|
+
DEFAULT_REFERENCE = 'HEAD'
|
20
|
+
|
17
21
|
enable_console_speaker
|
18
22
|
enable_simple_cache
|
19
23
|
|
20
24
|
JOBS = %w[git_deploy setup_files_units assert_instance_branch request_test].freeze
|
21
25
|
define_callbacks(*JOBS)
|
22
26
|
|
23
|
-
attr_reader :instance, :
|
27
|
+
attr_reader :instance, :options
|
24
28
|
|
25
|
-
def initialize(instance,
|
29
|
+
def initialize(instance, options = {})
|
26
30
|
@instance = instance
|
27
|
-
@
|
31
|
+
@options = options
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_git_commit
|
35
|
+
::Avm::Git::Commit.new(git, commit_sha1).deploy_to_env_path(
|
36
|
+
instance.host_env,
|
37
|
+
instance.read_entry(:fs_path)
|
38
|
+
).variables_source_set(instance)
|
28
39
|
end
|
29
40
|
|
30
41
|
def run
|
@@ -45,14 +56,18 @@ module Avm
|
|
45
56
|
infov 'Git remote name', git_remote_name
|
46
57
|
infov 'Git reference (Found)', git_reference_found
|
47
58
|
infov 'Git commit SHA1', commit_sha1
|
59
|
+
infov 'Appended directories', appended_directories
|
48
60
|
end
|
49
61
|
|
50
62
|
def git_deploy
|
51
63
|
infom 'Deploying source code and appended content...'
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
build_git_commit.append_directory(template.path).append_directories(
|
65
|
+
appended_directories
|
66
|
+
).run
|
67
|
+
end
|
68
|
+
|
69
|
+
def git_reference
|
70
|
+
options[:reference] || DEFAULT_REFERENCE
|
56
71
|
end
|
57
72
|
|
58
73
|
def setup_files_units
|
@@ -122,40 +137,6 @@ module Avm
|
|
122
137
|
def remote_branch(name)
|
123
138
|
git_remote_hashs.key?("refs/heads/#{name}") ? "#{git_remote_name}/#{name}" : nil
|
124
139
|
end
|
125
|
-
|
126
|
-
class FilesUnit < ::SimpleDelegator
|
127
|
-
attr_reader :data_key, :fs_path_subpath
|
128
|
-
|
129
|
-
def initialize(deploy, data_key, fs_path_subpath)
|
130
|
-
super(deploy)
|
131
|
-
@data_key = data_key
|
132
|
-
@fs_path_subpath = fs_path_subpath
|
133
|
-
end
|
134
|
-
|
135
|
-
def run
|
136
|
-
assert_source_directory
|
137
|
-
link_source_target
|
138
|
-
end
|
139
|
-
|
140
|
-
def assert_source_directory
|
141
|
-
infom "Asserting \"#{data_key}\" source directory..."
|
142
|
-
instance.host_env.command('mkdir', '-p', source_path).execute!
|
143
|
-
end
|
144
|
-
|
145
|
-
def source_path
|
146
|
-
::File.join(instance.read_entry(:data_fs_path), data_key.to_s)
|
147
|
-
end
|
148
|
-
|
149
|
-
def target_path
|
150
|
-
::File.join(instance.read_entry(:fs_path), fs_path_subpath.to_s)
|
151
|
-
end
|
152
|
-
|
153
|
-
def link_source_target
|
154
|
-
infom "Linking \"#{data_key}\" directory..."
|
155
|
-
instance.host_env.command('rm', '-rf', target_path).execute!
|
156
|
-
instance.host_env.command('ln', '-s', source_path, target_path).execute!
|
157
|
-
end
|
158
|
-
end
|
159
140
|
end
|
160
141
|
end
|
161
142
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/path_string'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Stereotypes
|
7
|
+
module EacWebappBase0
|
8
|
+
class Deploy
|
9
|
+
APPENDED_DIRECTORIES_ENTRY_KEY = 'deploy.appended_directories'
|
10
|
+
|
11
|
+
def appended_directories
|
12
|
+
appended_directories_from_instance_entry + appended_directories_from_options
|
13
|
+
end
|
14
|
+
|
15
|
+
def appended_directories_from_instance_entry
|
16
|
+
::Avm::PathString.paths(instance.read_entry_optional(APPENDED_DIRECTORIES_ENTRY_KEY))
|
17
|
+
end
|
18
|
+
|
19
|
+
def appended_directories_from_options
|
20
|
+
options[:appended_directories] || []
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module Stereotypes
|
5
|
+
module EacWebappBase0
|
6
|
+
class Deploy
|
7
|
+
class FilesUnit < ::SimpleDelegator
|
8
|
+
attr_reader :data_key, :fs_path_subpath
|
9
|
+
|
10
|
+
def initialize(deploy, data_key, fs_path_subpath)
|
11
|
+
super(deploy)
|
12
|
+
@data_key = data_key
|
13
|
+
@fs_path_subpath = fs_path_subpath
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
assert_source_directory
|
18
|
+
link_source_target
|
19
|
+
end
|
20
|
+
|
21
|
+
def assert_source_directory
|
22
|
+
infom "Asserting \"#{data_key}\" source directory..."
|
23
|
+
instance.host_env.command('mkdir', '-p', source_path).execute!
|
24
|
+
end
|
25
|
+
|
26
|
+
def source_path
|
27
|
+
::File.join(instance.read_entry(:data_fs_path), data_key.to_s)
|
28
|
+
end
|
29
|
+
|
30
|
+
def target_path
|
31
|
+
::File.join(instance.read_entry(:fs_path), fs_path_subpath.to_s)
|
32
|
+
end
|
33
|
+
|
34
|
+
def link_source_target
|
35
|
+
infom "Linking \"#{data_key}\" directory..."
|
36
|
+
instance.host_env.command('rm', '-rf', target_path).execute!
|
37
|
+
instance.host_env.command('ln', '-s', source_path, target_path).execute!
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/path_string'
|
3
4
|
require 'eac_ruby_utils/console/docopt_runner'
|
4
5
|
require 'eac_ruby_utils/console/speaker'
|
5
6
|
|
@@ -20,6 +21,7 @@ module Avm
|
|
20
21
|
Options:
|
21
22
|
-h --help Show this screen.
|
22
23
|
-r --reference=<git-reference> Git reference to deploy.
|
24
|
+
-a --append-dirs=<append-dirs> Append directories to deploy (List separated by ":").
|
23
25
|
DOCOPT
|
24
26
|
def initialize(settings = {})
|
25
27
|
super settings.merge(doc: DOC.gsub('%%STEREOTYPE_NAME%%', stereotype_name))
|
@@ -38,13 +40,18 @@ module Avm
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def run
|
41
|
-
result = deploy_class.new(context(:instance),
|
43
|
+
result = deploy_class.new(context(:instance), deploy_options).run
|
42
44
|
if result.error?
|
43
45
|
fatal_error result.to_s
|
44
46
|
else
|
45
47
|
infov 'Result', result.label
|
46
48
|
end
|
47
49
|
end
|
50
|
+
|
51
|
+
def deploy_options
|
52
|
+
{ reference: options.fetch('--reference'),
|
53
|
+
appended_directories: ::Avm::PathString.paths(options.fetch('--append-dirs')) }
|
54
|
+
end
|
48
55
|
end
|
49
56
|
end
|
50
57
|
end
|
data/lib/avm/tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- lib/avm/patches.rb
|
223
223
|
- lib/avm/patches/eac_launcher_git_base.rb
|
224
224
|
- lib/avm/patches/object/template.rb
|
225
|
+
- lib/avm/path_string.rb
|
225
226
|
- lib/avm/result.rb
|
226
227
|
- lib/avm/self.rb
|
227
228
|
- lib/avm/self/docker_image.rb
|
@@ -241,6 +242,8 @@ files:
|
|
241
242
|
- lib/avm/stereotypes/eac_webapp_base0.rb
|
242
243
|
- lib/avm/stereotypes/eac_webapp_base0/apache_host.rb
|
243
244
|
- lib/avm/stereotypes/eac_webapp_base0/deploy.rb
|
245
|
+
- lib/avm/stereotypes/eac_webapp_base0/deploy/_appended_directories.rb
|
246
|
+
- lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb
|
244
247
|
- lib/avm/stereotypes/eac_webapp_base0/instance.rb
|
245
248
|
- lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb
|
246
249
|
- lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb
|