avm 0.45.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/avm/launcher/context/instance_collector.rb +46 -0
- data/lib/avm/launcher/context/instance_discovery.rb +56 -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/context/instance_manager.rb +76 -0
- data/lib/avm/launcher/context/settings.rb +53 -0
- data/lib/avm/launcher/context.rb +94 -0
- data/lib/avm/launcher/instances/base/cache.rb +43 -0
- data/lib/avm/launcher/instances/base.rb +96 -0
- data/lib/avm/launcher/instances/error.rb +10 -0
- data/lib/avm/launcher/instances/runner_helper.rb +47 -0
- data/lib/avm/launcher/instances/settings.rb +55 -0
- data/lib/avm/launcher/paths/logical.rb +87 -0
- data/lib/avm/launcher/publish/base.rb +44 -0
- data/lib/avm/registry.rb +0 -2
- data/lib/avm/version.rb +1 -1
- metadata +18 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3de16327c43ae558d30a57324fcbaa23da1546da8110c4de0ba502003d6ac42c
|
4
|
+
data.tar.gz: 1bc7005ac83d1191579db59161d656fb4054e35f23c611a46c563df5351c6213
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 893701096abafe979997222cce3150766e944369ad8cb089f4022acfe1673d4651529dfa9b63e8b585028c8cac2f1a394aba20627b8b1b37d73f3ee0b4089d34
|
7
|
+
data.tar.gz: 5c042ea77b1f9daf6b29ea86484ecf24b9ac4eef274eb4c1999a612ae8f92dc3173b3b492c62fb364bb76c89fd8c6406fc46104a8ec652e00803e1dc631ed4a5
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Launcher
|
7
|
+
class Context
|
8
|
+
class InstanceCollector
|
9
|
+
common_constructor :context
|
10
|
+
|
11
|
+
def add_all
|
12
|
+
instances_set.merge(context.instances)
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_path(path)
|
17
|
+
instances_set.merge(instances_on_path(path))
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_pending
|
22
|
+
instances_set.merge(context.pending_instances)
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def instances
|
27
|
+
instances_set.sort
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def instance_match?(instance, instance_name)
|
33
|
+
::File.fnmatch?(instance_name, instance.name)
|
34
|
+
end
|
35
|
+
|
36
|
+
def instances_on_path(path)
|
37
|
+
context.instances.select { |instance| instance_match?(instance, path) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def instances_set
|
41
|
+
@instances_set ||= ::Set.new
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ruby-progressbar'
|
4
|
+
require 'avm/launcher/instances/base'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
class Context
|
9
|
+
class InstanceDiscovery
|
10
|
+
attr_reader :instances
|
11
|
+
|
12
|
+
def initialize(context)
|
13
|
+
@context = context
|
14
|
+
@progress = ::ProgressBar.create(title: 'Instance discovery', total: 1)
|
15
|
+
@instances = path_instances(@context.root, nil)
|
16
|
+
ensure
|
17
|
+
@progress&.finish
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def path_instances(path, parent_instance)
|
23
|
+
update_progress_format(path)
|
24
|
+
on_rescued_path_instances(path) do |r|
|
25
|
+
if path.project?
|
26
|
+
parent_instance = ::Avm::Launcher::Instances::Base.instanciate(path, parent_instance)
|
27
|
+
r << path
|
28
|
+
end
|
29
|
+
children = path.children
|
30
|
+
update_progress_count(children)
|
31
|
+
r.concat(children.flat_map { |c| path_instances(c, parent_instance) })
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_rescued_path_instances(path)
|
36
|
+
r = []
|
37
|
+
begin
|
38
|
+
yield(r) if path.included?
|
39
|
+
rescue StandardError => e
|
40
|
+
warn("#{path}: #{e}")
|
41
|
+
end
|
42
|
+
r
|
43
|
+
end
|
44
|
+
|
45
|
+
def update_progress_format(path)
|
46
|
+
@progress.format = "%t (Paths: %c/%C, Current: #{path.logical}) |%B| %a"
|
47
|
+
end
|
48
|
+
|
49
|
+
def update_progress_count(children)
|
50
|
+
@progress.total += children.count
|
51
|
+
@progress.increment
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/instances/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
class Context
|
9
|
+
class InstanceManager
|
10
|
+
class CachedInstance
|
11
|
+
enable_speaker
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :cached_instances, :data
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def instance_uncached
|
18
|
+
::Avm::Launcher::Instances::Base.instanciate(path, parent_instance)
|
19
|
+
rescue ::Avm::Launcher::Errors::NonProject
|
20
|
+
warn "Cached instance \"#{data[:logical]}\" not found"
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def parent_instance_uncached
|
25
|
+
data[:parent]
|
26
|
+
.if_present { |v| cached_instances.by_logical_path(v) }
|
27
|
+
.if_present(&:instance)
|
28
|
+
end
|
29
|
+
|
30
|
+
def path_uncached
|
31
|
+
::Avm::Launcher::Paths::Logical.from_h(cached_instances.context, data)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/context/instance_manager/cached_instance'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
class Context
|
9
|
+
class InstanceManager
|
10
|
+
class CachedInstances
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :context, :content
|
13
|
+
|
14
|
+
def instances
|
15
|
+
content.keys.map { |k| by_logical_path(k).instance }.reject(&:blank?)
|
16
|
+
end
|
17
|
+
|
18
|
+
def by_logical_path(key)
|
19
|
+
cached_instances[key].if_blank do
|
20
|
+
cached_instances[key] = ::Avm::Launcher::Context::InstanceManager::CachedInstance.new(
|
21
|
+
self, content.fetch(key)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def cached_instances_uncached
|
29
|
+
{}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/launcher/publish/check_result'
|
5
|
+
require('yaml')
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Launcher
|
9
|
+
class Context
|
10
|
+
class InstanceManager
|
11
|
+
require_sub __FILE__
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :context
|
14
|
+
|
15
|
+
def publish_state_set(instance, stereotype_name, check_status)
|
16
|
+
data = cached_instances_file_content_uncached
|
17
|
+
data[instance.logical] ||= {}
|
18
|
+
data[instance.logical][:publish_state] ||= {}
|
19
|
+
data[instance.logical][:publish_state][stereotype_name] = check_status
|
20
|
+
write_cache_file(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def pending_instances
|
24
|
+
instances.select { |instance| pending_instance?(instance) }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def instances_uncached
|
30
|
+
(cached_instances || search_instances).select(&:included?)
|
31
|
+
end
|
32
|
+
|
33
|
+
def search_instances
|
34
|
+
cache_instances(::Avm::Launcher::Context::InstanceDiscovery.new(context).instances)
|
35
|
+
end
|
36
|
+
|
37
|
+
def cached_instances
|
38
|
+
return nil if context.recache
|
39
|
+
return nil unless cached_instances_file_content
|
40
|
+
|
41
|
+
CachedInstances.new(self, cached_instances_file_content).instances
|
42
|
+
end
|
43
|
+
|
44
|
+
def cached_instances_file_content_uncached
|
45
|
+
r = YAML.load_file(cache_file_path)
|
46
|
+
r.is_a?(::Hash) ? r : nil
|
47
|
+
rescue Errno::ENOENT
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def cache_instances(instances)
|
52
|
+
write_cache_file(Hash[instances.map { |i| [i.logical, i.to_h] }])
|
53
|
+
instances
|
54
|
+
end
|
55
|
+
|
56
|
+
def write_cache_file(data)
|
57
|
+
::File.write(cache_file_path, data.to_yaml)
|
58
|
+
end
|
59
|
+
|
60
|
+
def cache_file_path
|
61
|
+
::File.join(context.cache_root, 'instances.yml')
|
62
|
+
end
|
63
|
+
|
64
|
+
def pending_instance?(instance)
|
65
|
+
data = cached_instances_file_content
|
66
|
+
return false unless data[instance.logical]
|
67
|
+
return false unless data[instance.logical][:publish_state].is_a?(Hash)
|
68
|
+
|
69
|
+
data[instance.logical][:publish_state].any? do |_k, v|
|
70
|
+
::Avm::Launcher::Publish::CheckResult.pending_status?(v)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/instances/settings'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Launcher
|
9
|
+
class Context
|
10
|
+
class Settings
|
11
|
+
include ::EacRubyUtils::SimpleCache
|
12
|
+
|
13
|
+
def initialize(file)
|
14
|
+
unless ::File.exist?(file)
|
15
|
+
::FileUtils.mkdir_p(::File.dirname(file))
|
16
|
+
::File.write(file, {}.to_yaml)
|
17
|
+
end
|
18
|
+
@data = YAML.load_file(file)
|
19
|
+
end
|
20
|
+
|
21
|
+
def instance_settings(instance)
|
22
|
+
::Avm::Launcher::Instances::Settings.new(value(['Instances', instance.name]))
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def excluded_projects_uncached
|
28
|
+
enum_value(%w[Projects Exclude])
|
29
|
+
end
|
30
|
+
|
31
|
+
def excluded_paths_uncached
|
32
|
+
enum_value(%w[Paths Exclude])
|
33
|
+
end
|
34
|
+
|
35
|
+
def enum_value(path)
|
36
|
+
r = value(path)
|
37
|
+
r.is_a?(Enumerable) ? r : []
|
38
|
+
end
|
39
|
+
|
40
|
+
def value(path)
|
41
|
+
node_value(@data, path)
|
42
|
+
end
|
43
|
+
|
44
|
+
def node_value(data, path)
|
45
|
+
return data if path.empty?
|
46
|
+
return nil unless data.is_a?(Hash)
|
47
|
+
|
48
|
+
node_value(data[path.first], path.drop(1))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
4
|
+
require 'avm/launcher/context/instance_manager'
|
5
|
+
require 'eac_ruby_utils/simple_cache'
|
6
|
+
require 'eac_cli/speaker'
|
7
|
+
require 'avm/launcher/context/instance_discovery'
|
8
|
+
require 'avm/launcher/context/settings'
|
9
|
+
require 'avm/launcher/paths/logical'
|
10
|
+
require 'avm/launcher/project'
|
11
|
+
require 'avm/tools/self'
|
12
|
+
|
13
|
+
module Avm
|
14
|
+
module Launcher
|
15
|
+
class Context
|
16
|
+
include ::EacRubyUtils::SimpleCache
|
17
|
+
enable_speaker
|
18
|
+
|
19
|
+
class << self
|
20
|
+
attr_writer :current
|
21
|
+
|
22
|
+
def current
|
23
|
+
@current ||= default
|
24
|
+
end
|
25
|
+
|
26
|
+
def default
|
27
|
+
@default ||= Context.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
attr_reader :root, :settings, :cache_root
|
32
|
+
attr_accessor :publish_options, :recache, :instance_manager
|
33
|
+
|
34
|
+
CONFIG_PATH_PREFIX = 'launcher'
|
35
|
+
|
36
|
+
def initialize(options = {})
|
37
|
+
@options = options.with_indifferent_access
|
38
|
+
@root = ::Avm::Launcher::Paths::Logical.new(self, nil, build_option(:projects_root), '/')
|
39
|
+
@settings = ::Avm::Launcher::Context::Settings.new(build_option(:settings_file))
|
40
|
+
@cache_root = build_option(:cache_root)
|
41
|
+
@publish_options = { new: false, confirm: false, stereotype: nil }
|
42
|
+
@instance_manager = ::Avm::Launcher::Context::InstanceManager.new(self)
|
43
|
+
@recache = false
|
44
|
+
end
|
45
|
+
|
46
|
+
def instance(name)
|
47
|
+
instances.find { |i| i.name == name }
|
48
|
+
end
|
49
|
+
|
50
|
+
def instances
|
51
|
+
@instance_manager.instances
|
52
|
+
end
|
53
|
+
|
54
|
+
def pending_instances
|
55
|
+
@instance_manager.pending_instances
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def build_option(key)
|
61
|
+
@options[key] || config_option(key) || default_option(key)
|
62
|
+
end
|
63
|
+
|
64
|
+
def config_option(key)
|
65
|
+
::Avm::Self::Instance.default.entry([CONFIG_PATH_PREFIX, key].join('.')).optional_value
|
66
|
+
end
|
67
|
+
|
68
|
+
def default_cache_root
|
69
|
+
::Avm::Tools::Self.application.cache_dir.join('launcher')
|
70
|
+
end
|
71
|
+
|
72
|
+
def default_option(key)
|
73
|
+
send("default_#{key}".underscore)
|
74
|
+
end
|
75
|
+
|
76
|
+
def default_projects_root
|
77
|
+
'.'
|
78
|
+
end
|
79
|
+
|
80
|
+
def default_settings_file
|
81
|
+
::Avm::Tools::Self.application.config_dir.join('launcher.yaml')
|
82
|
+
end
|
83
|
+
|
84
|
+
def projects_uncached
|
85
|
+
r = {}
|
86
|
+
instances.each do |i|
|
87
|
+
r[i.project_name] ||= []
|
88
|
+
r[i.project_name] << i
|
89
|
+
end
|
90
|
+
r.map { |name, instances| ::Avm::Launcher::Project.new(name, instances) }
|
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(::Avm::Launcher::Context.current.cache_root, name.parameterize)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base/cache'
|
4
|
+
require 'avm/launcher/errors/non_project'
|
5
|
+
require 'eac_ruby_utils/speaker/sender'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Launcher
|
9
|
+
module Instances
|
10
|
+
module Base
|
11
|
+
class << self
|
12
|
+
def extend_object(object)
|
13
|
+
object.extend ::EacRubyUtils::SimpleCache
|
14
|
+
object.extend ::EacRubyUtils::Speaker::Sender
|
15
|
+
object.extend ::Avm::Launcher::Instances::Base::Cache
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def instanciate(path, parent)
|
20
|
+
unless path.is_a?(::Avm::Launcher::Instances::Base)
|
21
|
+
raise ::Avm::Launcher::Errors::NonProject, path unless path.project?
|
22
|
+
|
23
|
+
path.extend(::Avm::Launcher::Instances::Base)
|
24
|
+
path.parent = parent
|
25
|
+
end
|
26
|
+
path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_accessor :parent
|
31
|
+
|
32
|
+
def name
|
33
|
+
logical
|
34
|
+
end
|
35
|
+
|
36
|
+
def stereotype?(stereotype)
|
37
|
+
stereotypes.include?(stereotype)
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_parent_path
|
41
|
+
return self unless @parent
|
42
|
+
|
43
|
+
logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
|
44
|
+
end
|
45
|
+
|
46
|
+
def project?
|
47
|
+
stereotypes.any?
|
48
|
+
end
|
49
|
+
|
50
|
+
def publish_run
|
51
|
+
stereotypes.each do |s|
|
52
|
+
next unless publish?(s)
|
53
|
+
|
54
|
+
infov(name, "publishing #{s.label}")
|
55
|
+
s.publish_class.new(self).run
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def publish_check
|
60
|
+
stereotypes.each do |s|
|
61
|
+
next unless publish?(s)
|
62
|
+
|
63
|
+
puts "#{name.to_s.cyan}|#{s.label}|" \
|
64
|
+
"#{s.publish_class.new(self).check}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def project_name
|
69
|
+
::File.basename(logical)
|
70
|
+
end
|
71
|
+
|
72
|
+
def included?
|
73
|
+
!::Avm::Launcher::Context.current.settings.excluded_projects.include?(project_name)
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_h
|
77
|
+
super.to_h.merge(parent: parent ? parent.logical : nil)
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def publish?(stereotype)
|
83
|
+
return false unless stereotype.publish_class
|
84
|
+
return false unless options.stereotype_publishable?(stereotype)
|
85
|
+
|
86
|
+
filter = ::Avm::Launcher::Context.current.publish_options[:stereotype]
|
87
|
+
filter.blank? ? true : filter == stereotype.name.demodulize
|
88
|
+
end
|
89
|
+
|
90
|
+
def options_uncached
|
91
|
+
::Avm::Launcher::Context.current.settings.instance_settings(self)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/context'
|
4
|
+
require 'avm/tools/core_ext'
|
5
|
+
require 'avm/launcher/context/instance_collector'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Launcher
|
9
|
+
module Instances
|
10
|
+
module RunnerHelper
|
11
|
+
common_concern do
|
12
|
+
runner_definition do
|
13
|
+
bool_opt '--all', 'Select all instances.'
|
14
|
+
bool_opt '--pending', 'Select pending instances.'
|
15
|
+
bool_opt '--recache', 'Rewrite instances cache.'
|
16
|
+
end
|
17
|
+
|
18
|
+
set_callback :run, :before, :setup_cache
|
19
|
+
end
|
20
|
+
|
21
|
+
def context
|
22
|
+
@context ||= ::Avm::Launcher::Context.current
|
23
|
+
end
|
24
|
+
|
25
|
+
def instances
|
26
|
+
collector = ::Avm::Launcher::Context::InstanceCollector.new(context)
|
27
|
+
collector.add_all if parsed.all?
|
28
|
+
collector.add_pending if parsed.pending?
|
29
|
+
parsed.instance_path.flat_map { |p| collector.add_path(p) }
|
30
|
+
collector.instances
|
31
|
+
end
|
32
|
+
|
33
|
+
def instance_stereotypes(instance)
|
34
|
+
instance.stereotypes.map(&:label).join(', ')
|
35
|
+
end
|
36
|
+
|
37
|
+
def instance_label(instance)
|
38
|
+
"#{instance.name} [#{instance_stereotypes(instance)}]"
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_cache
|
42
|
+
::Avm::Launcher::Context.current.recache = parsed.recache?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Launcher
|
7
|
+
module Instances
|
8
|
+
class Settings
|
9
|
+
DEFAULT_CURRENT_REVISION = 'origin/master'
|
10
|
+
DEFAULT_PUBLISH_REMOTE = 'publish'
|
11
|
+
PUBLISHABLE_KEY = :publishable
|
12
|
+
|
13
|
+
common_constructor :data do
|
14
|
+
self.data = (data.is_a?(Hash) ? data : {}).with_indifferent_access
|
15
|
+
end
|
16
|
+
|
17
|
+
def git_current_revision
|
18
|
+
data[__method__] || DEFAULT_CURRENT_REVISION
|
19
|
+
end
|
20
|
+
|
21
|
+
def git_publish_remote
|
22
|
+
data[__method__] || DEFAULT_PUBLISH_REMOTE
|
23
|
+
end
|
24
|
+
|
25
|
+
def publishable?
|
26
|
+
publishable_value ? true : false
|
27
|
+
end
|
28
|
+
|
29
|
+
def stereotype_publishable?(stereotype)
|
30
|
+
return publishable? unless publishable_value.is_a?(::Hash)
|
31
|
+
|
32
|
+
parse_publishable_value(publishable_value[stereotype.stereotype_name], true)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def publishable_value
|
38
|
+
parse_publishable_value(data[PUBLISHABLE_KEY], false)
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_publishable_value(value, hash_to_true)
|
42
|
+
return value.with_indifferent_access if parse_publishable_value_hash?(value, hash_to_true)
|
43
|
+
return true if value.nil? || value == true
|
44
|
+
return false if value == false
|
45
|
+
|
46
|
+
value ? true : false
|
47
|
+
end
|
48
|
+
|
49
|
+
def parse_publishable_value_hash?(value, hash_to_true)
|
50
|
+
!hash_to_true && value.is_a?(::Hash)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/projects/stereotypes'
|
4
|
+
require 'avm/launcher/paths/real'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
module Paths
|
9
|
+
class Logical
|
10
|
+
include ::Comparable
|
11
|
+
include ::EacRubyUtils::SimpleCache
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def from_h(context, hash)
|
15
|
+
parent_path = hash[:parent_path] ? from_h(context, hash[:parent_path]) : nil
|
16
|
+
new(context, parent_path, hash[:real], hash[:logical])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :context, :real, :logical, :parent_path
|
21
|
+
|
22
|
+
def initialize(context, parent_path, real, logical)
|
23
|
+
@context = context
|
24
|
+
@parent_path = parent_path
|
25
|
+
@real = ::Avm::Launcher::Paths::Real.new(real)
|
26
|
+
@logical = logical
|
27
|
+
end
|
28
|
+
|
29
|
+
def <=>(other)
|
30
|
+
[logical, real] <=> [other.logical, other.real]
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
logical
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_h
|
38
|
+
{ logical: logical, real: real.to_s, parent_path: parent_path ? parent_path.to_h : nil }
|
39
|
+
end
|
40
|
+
|
41
|
+
def project?
|
42
|
+
stereotypes.any?
|
43
|
+
end
|
44
|
+
|
45
|
+
def children
|
46
|
+
r = []
|
47
|
+
Dir.entries(warped).each do |c|
|
48
|
+
c_path = ::File.join(warped, c)
|
49
|
+
next unless ::File.directory?(c_path)
|
50
|
+
next if c.start_with?('.')
|
51
|
+
|
52
|
+
r << build_child(c)
|
53
|
+
end
|
54
|
+
r
|
55
|
+
end
|
56
|
+
|
57
|
+
def included?
|
58
|
+
!context.settings.excluded_paths.include?(logical)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def stereotypes_uncached
|
64
|
+
::Avm::Projects::Stereotype.stereotypes.select { |s| s.match?(self) }
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_child(name)
|
68
|
+
::Avm::Launcher::Paths::Logical.new(
|
69
|
+
context,
|
70
|
+
self,
|
71
|
+
::File.join(warped, name),
|
72
|
+
::File.join(logical, name)
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def warped_uncached
|
77
|
+
if is_a?(::Avm::Launcher::Instances::Base)
|
78
|
+
stereotypes.each do |s|
|
79
|
+
return s.warp_class.new(self) if s.warp_class
|
80
|
+
end
|
81
|
+
end
|
82
|
+
real
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/errors/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
module Publish
|
9
|
+
class Base
|
10
|
+
common_constructor :instance
|
11
|
+
|
12
|
+
def run
|
13
|
+
s = check
|
14
|
+
info("Check: #{s}")
|
15
|
+
return unless s.status == ::Avm::Launcher::Publish::CheckResult::STATUS_PENDING
|
16
|
+
|
17
|
+
publish
|
18
|
+
end
|
19
|
+
|
20
|
+
def check
|
21
|
+
s = check_with_rescue
|
22
|
+
::Avm::Launcher::Context.current.instance_manager.publish_state_set(
|
23
|
+
instance, stereotype.stereotype_name, s.status
|
24
|
+
)
|
25
|
+
s
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def stereotype
|
31
|
+
self.class.name.deconstantize.constantize
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_with_rescue
|
35
|
+
internal_check
|
36
|
+
rescue ::Avm::Launcher::Errors::Base => e
|
37
|
+
::Avm::Launcher::Publish::CheckResult.blocked("Error: #{e}")
|
38
|
+
rescue ::Avm::Launcher::Git::Error => e
|
39
|
+
::Avm::Launcher::Publish::CheckResult.blocked("Git error: #{e}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/avm/registry.rb
CHANGED
data/lib/avm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.46.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09
|
11
|
+
date: 2022-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_cli
|
@@ -50,20 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.4.2
|
53
|
+
version: '0.5'
|
57
54
|
type: :runtime
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
58
|
- - "~>"
|
62
59
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0.
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.4.2
|
60
|
+
version: '0.5'
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
62
|
name: eac_git
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,9 +258,23 @@ files:
|
|
264
258
|
- lib/avm/instances/docker_image.rb
|
265
259
|
- lib/avm/instances/entry_keys.rb
|
266
260
|
- lib/avm/instances/runner.rb
|
261
|
+
- lib/avm/launcher/context.rb
|
262
|
+
- lib/avm/launcher/context/instance_collector.rb
|
263
|
+
- lib/avm/launcher/context/instance_discovery.rb
|
264
|
+
- lib/avm/launcher/context/instance_manager.rb
|
265
|
+
- lib/avm/launcher/context/instance_manager/cached_instance.rb
|
266
|
+
- lib/avm/launcher/context/instance_manager/cached_instances.rb
|
267
|
+
- lib/avm/launcher/context/settings.rb
|
267
268
|
- lib/avm/launcher/errors/base.rb
|
268
269
|
- lib/avm/launcher/errors/non_project.rb
|
270
|
+
- lib/avm/launcher/instances/base.rb
|
271
|
+
- lib/avm/launcher/instances/base/cache.rb
|
272
|
+
- lib/avm/launcher/instances/error.rb
|
273
|
+
- lib/avm/launcher/instances/runner_helper.rb
|
274
|
+
- lib/avm/launcher/instances/settings.rb
|
275
|
+
- lib/avm/launcher/paths/logical.rb
|
269
276
|
- lib/avm/launcher/paths/real.rb
|
277
|
+
- lib/avm/launcher/publish/base.rb
|
270
278
|
- lib/avm/launcher/publish/check_result.rb
|
271
279
|
- lib/avm/path_string.rb
|
272
280
|
- lib/avm/registry.rb
|