avm-tools 0.60.0 → 0.62.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/cached_download.rb +39 -0
- data/lib/avm/eac_redmine_base0/core_update.rb +110 -0
- data/lib/avm/eac_redmine_base0/data_unit.rb +27 -0
- data/lib/avm/eac_redmine_base0/deploy.rb +36 -0
- data/lib/avm/eac_redmine_base0/instance.rb +38 -0
- data/lib/avm/launcher/context/instance_manager.rb +76 -0
- data/lib/avm/launcher/context/instance_manager/cached_instance.rb +37 -0
- data/lib/avm/launcher/context/instance_manager/cached_instances.rb +35 -0
- data/lib/avm/launcher/errors/base.rb +10 -0
- data/lib/avm/launcher/errors/non_project.rb +15 -0
- data/lib/avm/launcher/instances/base.rb +94 -0
- data/lib/avm/launcher/instances/base/cache.rb +43 -0
- data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +5 -4
- data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +3 -1
- data/lib/avm/sync.rb +94 -0
- data/lib/avm/tools/runner/eac_redmine_base0.rb +2 -2
- data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +67 -0
- data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +1 -1
- data/lib/avm/tools/runner/git/issue.rb +43 -4
- data/lib/avm/tools/version.rb +1 -1
- data/lib/eac_launcher/context.rb +2 -2
- data/lib/eac_launcher/context/instance_discovery.rb +2 -2
- data/lib/eac_launcher/git/base/dirty_files.rb +1 -1
- data/lib/eac_launcher/git/sub_warp_base.rb +3 -2
- data/lib/eac_launcher/instances.rb +2 -2
- data/lib/eac_launcher/instances/error.rb +7 -3
- data/lib/eac_launcher/paths/logical.rb +2 -2
- data/lib/eac_launcher/publish/base.rb +2 -2
- data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/install.sh.template +0 -0
- data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/secrets.yml +0 -0
- metadata +19 -11
- data/lib/avm/stereotypes/eac_redmine_base0/data_unit.rb +0 -29
- data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +0 -38
- data/lib/avm/stereotypes/eac_redmine_base0/instance.rb +0 -40
- data/lib/eac_launcher/context/instance_manager.rb +0 -95
- data/lib/eac_launcher/instances/base.rb +0 -91
- data/lib/eac_launcher/instances/base/cache.rb +0 -41
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base/cache'
|
4
|
+
require 'avm/launcher/errors/non_project'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
module Instances
|
9
|
+
module Base
|
10
|
+
class << self
|
11
|
+
def extend_object(object)
|
12
|
+
object.extend ::EacRubyUtils::SimpleCache
|
13
|
+
object.extend ::EacRubyUtils::Console::Speaker
|
14
|
+
object.extend ::Avm::Launcher::Instances::Base::Cache
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def instanciate(path, parent)
|
19
|
+
unless path.is_a?(::Avm::Launcher::Instances::Base)
|
20
|
+
raise ::Avm::Launcher::Errors::NonProject, path unless path.project?
|
21
|
+
|
22
|
+
path.extend(::Avm::Launcher::Instances::Base)
|
23
|
+
path.parent = parent
|
24
|
+
end
|
25
|
+
path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_accessor :parent
|
30
|
+
|
31
|
+
def name
|
32
|
+
logical
|
33
|
+
end
|
34
|
+
|
35
|
+
def stereotype?(stereotype)
|
36
|
+
stereotypes.include?(stereotype)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_parent_path
|
40
|
+
return self unless @parent
|
41
|
+
|
42
|
+
logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
|
43
|
+
end
|
44
|
+
|
45
|
+
def project?
|
46
|
+
stereotypes.any?
|
47
|
+
end
|
48
|
+
|
49
|
+
def publish_run
|
50
|
+
stereotypes.each do |s|
|
51
|
+
next unless publish?(s)
|
52
|
+
|
53
|
+
infov(name, "publishing #{s.label}")
|
54
|
+
s.publish_class.new(self).run
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def publish_check
|
59
|
+
stereotypes.each do |s|
|
60
|
+
next unless publish?(s)
|
61
|
+
|
62
|
+
puts "#{name.to_s.cyan}|#{s.label}|" \
|
63
|
+
"#{s.publish_class.new(self).check}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def project_name
|
68
|
+
::File.basename(logical)
|
69
|
+
end
|
70
|
+
|
71
|
+
def included?
|
72
|
+
!::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_h
|
76
|
+
super.to_h.merge(parent: parent ? parent.logical : nil)
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def publish?(stereotype)
|
82
|
+
return false unless stereotype.publish_class
|
83
|
+
|
84
|
+
filter = ::EacLauncher::Context.current.publish_options[:stereotype]
|
85
|
+
filter.blank? ? true : filter == stereotype.name.demodulize
|
86
|
+
end
|
87
|
+
|
88
|
+
def options_uncached
|
89
|
+
::EacLauncher::Context.current.settings.instance_settings(self)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module Launcher
|
5
|
+
module Instances
|
6
|
+
module Base
|
7
|
+
module Cache
|
8
|
+
def cache_path(subpath)
|
9
|
+
File.join(cache_root, subpath)
|
10
|
+
end
|
11
|
+
|
12
|
+
def cache_key(key, &block)
|
13
|
+
v = cache_key_get(key)
|
14
|
+
return v if v.present? || block.nil?
|
15
|
+
|
16
|
+
v = yield
|
17
|
+
cache_key_write(key, v)
|
18
|
+
v
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def cache_key_get(key)
|
24
|
+
File.file?(cache_key_path(key)) ? File.read(cache_key_path(key)) : nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def cache_key_write(key, value)
|
28
|
+
FileUtils.mkdir_p(File.dirname(cache_key_path(key)))
|
29
|
+
File.write(cache_key_path(key), value)
|
30
|
+
end
|
31
|
+
|
32
|
+
def cache_key_path(key)
|
33
|
+
File.join(cache_root, 'keys', key.parameterize)
|
34
|
+
end
|
35
|
+
|
36
|
+
def cache_root
|
37
|
+
File.join(::EacLauncher::Context.current.cache_root, name.parameterize)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/simple_cache'
|
4
4
|
require 'eac_launcher/git/sub_warp_base'
|
5
|
-
require '
|
5
|
+
require 'avm/launcher/errors/base'
|
6
6
|
require 'eac_launcher/paths/real'
|
7
7
|
require 'eac_launcher/vendor/github'
|
8
8
|
|
@@ -32,8 +32,9 @@ module Avm
|
|
32
32
|
return if parent_git_warped.rev_parse(subrepo_parent_hash) &&
|
33
33
|
parent_git_warped.descendant?('HEAD', subrepo_parent_hash)
|
34
34
|
|
35
|
-
raise EacLauncher::Instances::
|
36
|
-
|
35
|
+
raise EacLauncher::Instances::Errors::Base,
|
36
|
+
"Subrepo parent hash \"#{subrepo_parent_hash}\"" \
|
37
|
+
" not found in \"#{parent_git_warped}\""
|
37
38
|
end
|
38
39
|
|
39
40
|
def subrepo_parent_hash
|
@@ -41,7 +42,7 @@ module Avm
|
|
41
42
|
h = data['Pull Parent']
|
42
43
|
return h if h.present?
|
43
44
|
|
44
|
-
raise EacLauncher::Instances::
|
45
|
+
raise EacLauncher::Instances::Errors::Base, "Subrepo parent hash is blank: #{data}"
|
45
46
|
end
|
46
47
|
|
47
48
|
def init_aux
|
data/lib/avm/sync.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
class Sync
|
7
|
+
attr_reader :excludes, :includes
|
8
|
+
|
9
|
+
common_constructor :source_path, :target_path do
|
10
|
+
self.source_path = source_path.to_pathname
|
11
|
+
self.target_path = target_path.to_pathname
|
12
|
+
@excludes = []
|
13
|
+
@includes = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
clear_target
|
18
|
+
copy
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_exclude(exclude)
|
22
|
+
excludes << exclude
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_excludes(*excludes)
|
28
|
+
excludes.each { |exclude| add_exclude(exclude) }
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_include(include)
|
34
|
+
includes << include
|
35
|
+
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_includes(*includes)
|
40
|
+
includes.each { |include| add_include(include) }
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def move_mode(value)
|
46
|
+
@move_mode = value
|
47
|
+
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def move_mode?
|
52
|
+
@move_mode ? true : false
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def clear_target
|
58
|
+
target_remove(target_path)
|
59
|
+
target_path.children.each { |tchild| target_remove(tchild) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def copy
|
63
|
+
source_path.children.each do |schild|
|
64
|
+
::FileUtils.cp_r(schild.to_path, target_path.to_path)
|
65
|
+
schild.rmtree if move_mode?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def source_to_target_path(source_path)
|
70
|
+
source_path.relative_path_from(self.source_path).expand_path(target_path)
|
71
|
+
end
|
72
|
+
|
73
|
+
def target_remove(tpath)
|
74
|
+
return if skip_target_path?(tpath)
|
75
|
+
|
76
|
+
if tpath.directory?
|
77
|
+
tpath.children.each { |tchild| target_remove(tchild) }
|
78
|
+
tpath.rmdir if tpath.children.empty?
|
79
|
+
elsif tpath.file?
|
80
|
+
tpath.unlink
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def skip_target_path?(tpath)
|
85
|
+
skip_path?(tpath.relative_path_from(target_path))
|
86
|
+
end
|
87
|
+
|
88
|
+
def skip_path?(relpath)
|
89
|
+
relpath = relpath.expand_path('/')
|
90
|
+
excludes.any? { |exclude| relpath.fnmatch?(exclude) } &&
|
91
|
+
includes.none? { |include| relpath.fnmatch?(include) }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/console/docopt_runner'
|
4
4
|
require 'eac_ruby_utils/simple_cache'
|
5
|
-
require 'avm/
|
5
|
+
require 'avm/eac_redmine_base0/instance'
|
6
6
|
require 'eac_ruby_utils/require_sub'
|
7
7
|
::EacRubyUtils.require_sub(__FILE__)
|
8
8
|
|
@@ -26,7 +26,7 @@ module Avm
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def instance_uncached
|
29
|
-
::Avm::
|
29
|
+
::Avm::EacRedmineBase0::Instance.by_id(options['<instance_id>'])
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_redmine_base0/core_update'
|
4
|
+
require 'eac_cli/default_runner'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module Tools
|
10
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class CoreUpdate < ::EacRubyUtils::Console::DocoptRunner
|
13
|
+
include ::EacCli::DefaultRunner
|
14
|
+
|
15
|
+
runner_definition do
|
16
|
+
arg_opt '-u', '--url', 'Core\'s package URL.'
|
17
|
+
arg_opt '-v', '--version', 'Core\'s version.'
|
18
|
+
desc 'Update instance\' core.'
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
start_banner
|
23
|
+
validate
|
24
|
+
update
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def start_banner
|
30
|
+
infov 'URL', url
|
31
|
+
infov 'Version', version
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
::Avm::EacRedmineBase0::CoreUpdate.new(context(:instance), version, url).run
|
36
|
+
end
|
37
|
+
|
38
|
+
def url
|
39
|
+
options.fetch('--url') || url_by_version
|
40
|
+
end
|
41
|
+
|
42
|
+
def url_by_version
|
43
|
+
options.fetch('--version').if_present do |v|
|
44
|
+
"https://www.redmine.org/releases/redmine-#{v}.tar.gz"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate
|
49
|
+
%w[url version].each do |attr|
|
50
|
+
fatal_error "\"#{attr}\" is blank. See avaiable options." if send(attr).blank?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def version
|
55
|
+
options.fetch('--version') || version_by_url
|
56
|
+
end
|
57
|
+
|
58
|
+
def version_by_url
|
59
|
+
options.fetch('--url').if_present do |v|
|
60
|
+
/(\d+.\d+.\d+)/.if_match(v, false) { |m| m[1] }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -9,6 +9,7 @@ module Avm
|
|
9
9
|
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
10
|
class Git < ::EacRubyUtils::Console::DocoptRunner
|
11
11
|
class Issue < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
enable_simple_cache
|
12
13
|
include ::EacRubyUtils::Console::Speaker
|
13
14
|
|
14
15
|
DOC = <<~DOCOPT
|
@@ -20,6 +21,8 @@ module Avm
|
|
20
21
|
|
21
22
|
Options:
|
22
23
|
-h --help Show this screen.
|
24
|
+
-f --uncomplete-unfail Do not exit with error if issue is not completed
|
25
|
+
or is invalid.
|
23
26
|
-s --skip-validations=<validations> Does not validate conditions on <validations>
|
24
27
|
(Comma separated value).
|
25
28
|
-y --yes Does not ask for user confirmation.
|
@@ -28,11 +31,30 @@ module Avm
|
|
28
31
|
%%VALIDATIONS%%
|
29
32
|
DOCOPT
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
UNCOMPLETE_MESSAGE =
|
35
|
+
|
36
|
+
def run
|
37
|
+
banner
|
38
|
+
return unless validate
|
39
|
+
|
40
|
+
run_complete if options.fetch('complete')
|
41
|
+
success('Done!')
|
42
|
+
end
|
43
|
+
|
44
|
+
def banner
|
33
45
|
complete.start_banner
|
34
|
-
|
35
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate
|
49
|
+
return true if complete.valid?
|
50
|
+
|
51
|
+
uncomplete_message('Some validation did not pass')
|
52
|
+
end
|
53
|
+
|
54
|
+
def run_complete
|
55
|
+
return complete.run if confirm?
|
56
|
+
|
57
|
+
uncomplete_message('Issue was not completed')
|
36
58
|
end
|
37
59
|
|
38
60
|
def doc
|
@@ -41,6 +63,10 @@ module Avm
|
|
41
63
|
|
42
64
|
private
|
43
65
|
|
66
|
+
def complete_uncached
|
67
|
+
::Avm::Git::Issue::Complete.new(git_complete_issue_options)
|
68
|
+
end
|
69
|
+
|
44
70
|
def confirm?
|
45
71
|
options.fetch('--yes') || request_input('Confirm issue completion?', bool: true)
|
46
72
|
end
|
@@ -56,6 +82,19 @@ module Avm
|
|
56
82
|
def doc_validations_list
|
57
83
|
::Avm::Git::Issue::Complete::VALIDATIONS.keys.map { |k| " * #{k}" }.join("\n")
|
58
84
|
end
|
85
|
+
|
86
|
+
def uncomplete_unfail?
|
87
|
+
options.fetch('--uncomplete-unfail')
|
88
|
+
end
|
89
|
+
|
90
|
+
def uncomplete_message(message)
|
91
|
+
if uncomplete_unfail?
|
92
|
+
warn(message)
|
93
|
+
else
|
94
|
+
fatal_error(message)
|
95
|
+
end
|
96
|
+
false
|
97
|
+
end
|
59
98
|
end
|
60
99
|
end
|
61
100
|
end
|