avm 0.4.0 → 0.7.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/data/instance/files_unit.rb +40 -0
- data/lib/avm/data/instance/package.rb +18 -0
- data/lib/avm/data/instance/unit.rb +17 -0
- data/lib/avm/{git/issue.rb → data/instance.rb} +2 -2
- data/lib/avm/data/package/dump.rb +119 -0
- data/lib/avm/data/package/load.rb +48 -0
- data/lib/avm/data/package.rb +42 -0
- data/lib/avm/{files → data}/rotate.rb +1 -1
- data/lib/avm/data/unit.rb +94 -0
- data/lib/avm/docker/runner.rb +8 -0
- data/lib/avm/instances/application.rb +25 -0
- data/lib/avm/instances/base/auto_values/access.rb +40 -0
- data/lib/avm/instances/base/auto_values/admin.rb +19 -0
- data/lib/avm/instances/base/auto_values/data.rb +26 -0
- data/lib/avm/instances/base/auto_values/database.rb +71 -0
- data/lib/avm/instances/base/auto_values/filesystem.rb +45 -0
- data/lib/avm/instances/base/auto_values/mailer.rb +34 -0
- data/lib/avm/instances/base/auto_values/ruby.rb +15 -0
- data/lib/avm/instances/base/auto_values/source.rb +15 -0
- data/lib/avm/instances/base/auto_values/system.rb +23 -0
- data/lib/avm/instances/base/auto_values/web.rb +46 -0
- data/lib/avm/instances/base/auto_values.rb +21 -0
- data/lib/avm/instances/base/dockerizable.rb +45 -0
- data/lib/avm/instances/base/entry_keys.rb +22 -0
- data/lib/avm/instances/base.rb +64 -0
- data/lib/avm/instances/entries.rb +43 -0
- data/lib/avm/instances/entry.rb +54 -0
- data/lib/avm/instances/entry_keys.rb +57 -0
- data/lib/avm/instances/runner.rb +38 -0
- data/lib/avm/instances.rb +8 -0
- data/lib/avm/jobs/base.rb +1 -0
- data/lib/avm/path_string.rb +27 -0
- data/lib/avm/registry/base.rb +65 -0
- data/lib/avm/registry.rb +29 -0
- data/lib/avm/rspec/setup.rb +22 -0
- data/lib/avm/rspec/shared_examples/in_avm_registry.rb +11 -0
- data/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +14 -0
- data/lib/avm/{app_src.rb → rspec.rb} +1 -1
- data/lib/avm/runners/base.rb +31 -0
- data/lib/avm/scms/base.rb +28 -0
- data/lib/avm/scms/commit.rb +43 -0
- data/lib/avm/self/docker_image.rb +14 -0
- data/lib/avm/self/instance/entry_keys.rb +12 -0
- data/lib/avm/self/instance.rb +24 -0
- data/lib/avm/source_stereotypes/base.rb +21 -0
- data/lib/avm/{app_src → sources}/base.rb +25 -3
- data/lib/avm/{app_src → sources}/configuration/_locale.rb +1 -1
- data/lib/avm/{app_src → sources}/configuration/_rubocop.rb +1 -1
- data/lib/avm/{app_src → sources}/configuration/_tests.rb +1 -1
- data/lib/avm/{app_src → sources}/configuration.rb +1 -1
- data/lib/avm/{git/organize.rb → sources.rb} +2 -4
- data/lib/avm/sync.rb +94 -0
- data/lib/avm/version.rb +1 -1
- metadata +74 -73
- data/lib/avm/files/appendable/file_content.rb +0 -24
- data/lib/avm/files/appendable/plain_directory.rb +0 -25
- data/lib/avm/files/appendable/resource_base.rb +0 -13
- data/lib/avm/files/appendable/tar_output_command.rb +0 -26
- data/lib/avm/files/appendable/templatized_directory.rb +0 -29
- data/lib/avm/files/appendable.rb +0 -55
- data/lib/avm/files/appender.rb +0 -11
- data/lib/avm/files/deploy.rb +0 -71
- data/lib/avm/files/formatter/formats/base.rb +0 -62
- data/lib/avm/files/formatter/formats/generic_plain.rb +0 -34
- data/lib/avm/files/formatter/formats/html.rb +0 -45
- data/lib/avm/files/formatter/formats/javascript.rb +0 -24
- data/lib/avm/files/formatter/formats/json.rb +0 -27
- data/lib/avm/files/formatter/formats/php.rb +0 -22
- data/lib/avm/files/formatter/formats/python.rb +0 -22
- data/lib/avm/files/formatter/formats/ruby.rb +0 -22
- data/lib/avm/files/formatter/formats/xml.rb +0 -28
- data/lib/avm/files/formatter/formats.rb +0 -13
- data/lib/avm/files/formatter/utf8_assert.rb +0 -74
- data/lib/avm/files/formatter.rb +0 -90
- data/lib/avm/files.rb +0 -9
- data/lib/avm/git/auto_commit/commit_info.rb +0 -23
- data/lib/avm/git/auto_commit/rules/base.rb +0 -39
- data/lib/avm/git/auto_commit/rules/last.rb +0 -19
- data/lib/avm/git/auto_commit/rules/manual.rb +0 -45
- data/lib/avm/git/auto_commit/rules/new.rb +0 -24
- data/lib/avm/git/auto_commit/rules/nth.rb +0 -31
- data/lib/avm/git/auto_commit/rules/unique.rb +0 -21
- data/lib/avm/git/auto_commit/rules.rb +0 -31
- data/lib/avm/git/auto_commit_path/ruby.rb +0 -20
- data/lib/avm/git/auto_commit_path.rb +0 -28
- data/lib/avm/git/commit/class_methods.rb +0 -31
- data/lib/avm/git/commit/deploy.rb +0 -38
- data/lib/avm/git/commit/deploy_methods.rb +0 -19
- data/lib/avm/git/commit/diff_tree_line.rb +0 -32
- data/lib/avm/git/commit/file.rb +0 -46
- data/lib/avm/git/commit.rb +0 -59
- data/lib/avm/git/file_auto_fixup.rb +0 -83
- data/lib/avm/git/issue/complete/commits.rb +0 -42
- data/lib/avm/git/issue/complete/git_subrepos.rb +0 -23
- data/lib/avm/git/issue/complete/local_branch.rb +0 -54
- data/lib/avm/git/issue/complete/local_tag.rb +0 -39
- data/lib/avm/git/issue/complete/push.rb +0 -54
- data/lib/avm/git/issue/complete/remote.rb +0 -33
- data/lib/avm/git/issue/complete/test.rb +0 -45
- data/lib/avm/git/issue/complete/tracker.rb +0 -28
- data/lib/avm/git/issue/complete/validation.rb +0 -31
- data/lib/avm/git/issue/complete/validations.rb +0 -53
- data/lib/avm/git/issue/complete/working_tree.rb +0 -19
- data/lib/avm/git/issue/complete.rb +0 -51
- data/lib/avm/git/issue/deliver.rb +0 -56
- data/lib/avm/git/organize/reference_update.rb +0 -34
- data/lib/avm/git/organize/repository.rb +0 -76
- data/lib/avm/git/revision_test.rb +0 -105
- data/lib/avm/git/subrepo_check/parent.rb +0 -51
- data/lib/avm/git/subrepo_check/remote.rb +0 -89
- data/lib/avm/git/subrepo_check/show_result.rb +0 -32
- data/lib/avm/git/subrepo_check.rb +0 -38
- data/lib/avm/git/subrepo_checks.rb +0 -59
- data/lib/avm/git.rb +0 -10
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/entry'
|
4
|
+
require 'avm/instances/entry_keys'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Instances
|
8
|
+
class Base
|
9
|
+
module AutoValues
|
10
|
+
module Mailer
|
11
|
+
::Avm::Instances::EntryKeys.all.select { |c| c.to_s.start_with?('mailer.') }
|
12
|
+
.reject { |c| c == ::Avm::Instances::EntryKeys::MAILER_ID }
|
13
|
+
.each do |mailer_key|
|
14
|
+
define_method ::Avm::Instances::Entry.auto_value_method_name(mailer_key) do
|
15
|
+
mailer_auto_common(mailer_key)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def auto_mailer_id
|
20
|
+
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID,
|
21
|
+
::Avm::Instances::EntryKeys::MAILER_ID) ||
|
22
|
+
read_entry_optional(::Avm::Instances::EntryKeys::HOST_ID)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def mailer_auto_common(mailer_key)
|
28
|
+
inherited_entry_value(::Avm::Instances::EntryKeys::MAILER_ID, mailer_key)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module Instances
|
5
|
+
class Base
|
6
|
+
module AutoValues
|
7
|
+
module Ruby
|
8
|
+
def auto_ruby_version
|
9
|
+
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ruby.version')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'addressable'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Instances
|
7
|
+
class Base
|
8
|
+
module AutoValues
|
9
|
+
module System
|
10
|
+
def auto_system_username
|
11
|
+
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'system.username') ||
|
12
|
+
read_entry_optional('ssh.username')
|
13
|
+
end
|
14
|
+
|
15
|
+
def auto_system_groupname
|
16
|
+
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'system.groupname') ||
|
17
|
+
read_entry_optional('system.username')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'addressable'
|
4
|
+
require 'avm/instances/entry_keys'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Instances
|
8
|
+
class Base
|
9
|
+
module AutoValues
|
10
|
+
module Web
|
11
|
+
def auto_web_authority
|
12
|
+
web_url_as_uri(&:authority)
|
13
|
+
end
|
14
|
+
|
15
|
+
def auto_web_hostname
|
16
|
+
web_url_as_uri(&:host)
|
17
|
+
end
|
18
|
+
|
19
|
+
def auto_web_path
|
20
|
+
web_url_as_uri(&:path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def auto_web_port
|
24
|
+
web_url_as_uri(&:port)
|
25
|
+
end
|
26
|
+
|
27
|
+
def auto_web_scheme
|
28
|
+
web_url_as_uri(&:scheme)
|
29
|
+
end
|
30
|
+
|
31
|
+
def auto_web_userinfo
|
32
|
+
web_url_as_uri(&:userinfo)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def web_url_as_uri
|
38
|
+
read_entry_optional(::Avm::Instances::EntryKeys::WEB_URL).if_present do |v|
|
39
|
+
yield(::Addressable::URI.parse(v))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
::EacRubyUtils.require_sub(__FILE__)
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Instances
|
8
|
+
class Base
|
9
|
+
module AutoValues
|
10
|
+
extend ::ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
%w[Access Admin Data Database Filesystem Mailer Ruby Source System Web]
|
14
|
+
.each do |class_name|
|
15
|
+
include const_get(class_name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_docker/executables'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'avm/docker/container'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Instances
|
9
|
+
class Base
|
10
|
+
module Dockerizable
|
11
|
+
enable_simple_cache
|
12
|
+
attr_reader :docker_image_options
|
13
|
+
|
14
|
+
def docker_image_options=(options)
|
15
|
+
@docker_image_options = ::ActiveSupport::HashWithIndifferentAccess.new(options)
|
16
|
+
reset_cache
|
17
|
+
end
|
18
|
+
|
19
|
+
def docker_container_exist?
|
20
|
+
::EacDocker::Executables.docker.command.append(
|
21
|
+
['ps', '-qaf', "name=#{docker_container_name}"]
|
22
|
+
).execute!.present?
|
23
|
+
end
|
24
|
+
|
25
|
+
def docker_container_name
|
26
|
+
id
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def docker_container_uncached
|
32
|
+
::Avm::Docker::Container.new(self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def docker_image_uncached
|
36
|
+
r = docker_image_class.new(docker_image_options.fetch(:registry))
|
37
|
+
r.instance = self if r.respond_to?(:instance)
|
38
|
+
r.version = docker_image_options[:version] if docker_image_options.key?(:version)
|
39
|
+
r.snapshot = docker_image_options[:snapshot] if docker_image_options.key?(:snapshot)
|
40
|
+
r
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/entry_keys'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Instances
|
7
|
+
class Base
|
8
|
+
module EntryKeys
|
9
|
+
::Avm::Instances::EntryKeys.all.each do |key|
|
10
|
+
method_name = key.to_s.variableize
|
11
|
+
define_method method_name do
|
12
|
+
read_entry(key)
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method "#{method_name}_optional" do
|
16
|
+
read_entry(key, required: false)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
require 'avm/instances/entries'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Instances
|
9
|
+
class Base
|
10
|
+
enable_listable
|
11
|
+
enable_simple_cache
|
12
|
+
require_sub __FILE__, include_modules: true
|
13
|
+
include ::Avm::Instances::Entries
|
14
|
+
|
15
|
+
lists.add_string :access, :local, :ssh
|
16
|
+
|
17
|
+
ID_PATTERN = /\A([a-z0-9]+(?:\-[a-z0-9]+)*)_(.+)\z/.freeze
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def by_id(id)
|
21
|
+
application_id, suffix = parse_id(id)
|
22
|
+
require 'avm/instances/application'
|
23
|
+
new(::Avm::Instances::Application.new(application_id), suffix)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def parse_id(id)
|
29
|
+
m = ID_PATTERN.match(id)
|
30
|
+
return [m[1], m[2]] if m
|
31
|
+
|
32
|
+
raise "ID Pattern no matched: \"#{id}\""
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
common_constructor :application, :suffix do
|
37
|
+
self.suffix = suffix.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
def id
|
41
|
+
"#{application.id}_#{suffix}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
id
|
46
|
+
end
|
47
|
+
|
48
|
+
def host_env_uncached
|
49
|
+
access = read_entry(:access, list: ::Avm::Instances::Base.lists.access.values)
|
50
|
+
case access
|
51
|
+
when 'local' then ::EacRubyUtils::Envs.local
|
52
|
+
when 'ssh' then ::EacRubyUtils::Envs.ssh(read_entry('ssh.url'))
|
53
|
+
else raise("Unmapped access value: \"#{access}\"")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def source_instance_uncached
|
60
|
+
::Avm::Instances::Base.by_id(source_instance_id)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/instances/entry'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Instances
|
8
|
+
module Entries
|
9
|
+
def entry(suffix, options = {})
|
10
|
+
::Avm::Instances::Entry.new(self, suffix, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def path_prefix
|
14
|
+
@path_prefix ||= [id].freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
def read_entry(entry_suffix, options = {})
|
18
|
+
entry(entry_suffix, options).value
|
19
|
+
end
|
20
|
+
|
21
|
+
def read_entry_optional(entry_suffix, options = {})
|
22
|
+
entry(entry_suffix, options).optional_value
|
23
|
+
end
|
24
|
+
|
25
|
+
def full_entry_path(entry_suffix)
|
26
|
+
unless entry_suffix.is_a?(::Array)
|
27
|
+
entry_suffix = ::EacConfig::PathsHash.parse_entry_key(entry_suffix.to_s)
|
28
|
+
end
|
29
|
+
(path_prefix + entry_suffix).join('.')
|
30
|
+
end
|
31
|
+
|
32
|
+
def inherited_entry_value(source_entry_suffix, target_entry_suffix, &block)
|
33
|
+
read_entry_optional(source_entry_suffix).if_present do |instance_id|
|
34
|
+
other_entry_value(instance_id, target_entry_suffix).if_present(&block)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def other_entry_value(instance_id, entry_suffix)
|
39
|
+
::Avm::Instances::Base.by_id(instance_id).read_entry_optional(entry_suffix)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_config/node'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Instances
|
8
|
+
class Entry
|
9
|
+
class << self
|
10
|
+
def auto_value_method_name(suffix)
|
11
|
+
"auto_#{suffix.to_s.gsub('.', '_')}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
common_constructor :parent, :suffix, :options
|
16
|
+
|
17
|
+
def auto_value
|
18
|
+
parent.respond_to?(auto_value_method, true) ? parent.send(auto_value_method) : nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def auto_value_method
|
22
|
+
self.class.auto_value_method_name(suffix)
|
23
|
+
end
|
24
|
+
|
25
|
+
def full_path
|
26
|
+
(parent.path_prefix + suffix_as_array).join('.')
|
27
|
+
end
|
28
|
+
|
29
|
+
def optional_value
|
30
|
+
read(required: false, noinput: true) || auto_value
|
31
|
+
end
|
32
|
+
|
33
|
+
def read(extra_options = {})
|
34
|
+
::EacConfig::Node.context.current.entry(full_path, options.merge(extra_options)).value
|
35
|
+
end
|
36
|
+
|
37
|
+
def suffix_as_array
|
38
|
+
if suffix.is_a?(::Array)
|
39
|
+
suffix.dup
|
40
|
+
else
|
41
|
+
::EacConfig::PathsHash.parse_entry_key(suffix.to_s)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def value
|
46
|
+
optional_value || read
|
47
|
+
end
|
48
|
+
|
49
|
+
def write(value)
|
50
|
+
::EacConfig::Node.context.current.entry(full_path).value = value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Instances
|
7
|
+
module EntryKeys
|
8
|
+
class << self
|
9
|
+
def all
|
10
|
+
all_keys.to_a
|
11
|
+
end
|
12
|
+
|
13
|
+
def keys_consts_set(prefix, suffixes)
|
14
|
+
if suffixes.is_a?(::Hash)
|
15
|
+
keys_consts_set_from_hash(prefix, suffixes)
|
16
|
+
elsif suffixes.is_a?(::Enumerable)
|
17
|
+
keys_consts_set_from_enum(prefix, suffixes)
|
18
|
+
else
|
19
|
+
raise "Unmapped suffixes class: #{suffixes.class}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def key_const_set(prefix, suffix)
|
24
|
+
key = [prefix, suffix].reject(&:blank?).join('.')
|
25
|
+
const_set(key.gsub('.', '_').upcase, key)
|
26
|
+
all_keys << key
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def all_keys
|
32
|
+
@all_keys ||= ::Set.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def keys_consts_set_from_enum(prefix, suffixes)
|
36
|
+
suffixes.each { |suffix| key_const_set(prefix, suffix) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def keys_consts_set_from_hash(prefix, suffixes)
|
40
|
+
suffixes.each { |k, v| keys_consts_set(prefix.to_s + (k.blank? ? '' : ".#{k}"), v) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
{
|
45
|
+
'' => %w[fs_path host_id source_instance_id],
|
46
|
+
database: %w[id hostname limit name password port system timeout username],
|
47
|
+
docker: %w[registry],
|
48
|
+
mailer: {
|
49
|
+
'' => %w[id from reply_to],
|
50
|
+
smtp: %w[address port domain username password authentication starttls_auto]
|
51
|
+
},
|
52
|
+
ssh: %w[hostname port url username],
|
53
|
+
web: %w[authority hostname path port scheme url userinfo]
|
54
|
+
}.each { |prefix, suffixes| keys_consts_set(prefix, suffixes) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Instances
|
7
|
+
class Runner
|
8
|
+
class << self
|
9
|
+
def instance_class
|
10
|
+
::Avm.const_get(stereotype_name).const_get('Instance')
|
11
|
+
end
|
12
|
+
|
13
|
+
def stereotype_module
|
14
|
+
::Avm.const_get(stereotype_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def stereotype_name
|
18
|
+
name.demodulize
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
description = "Utilities for #{stereotype_name} instances."
|
23
|
+
runner_with :help, :subcommands do
|
24
|
+
desc description
|
25
|
+
pos_arg 'instance-id'
|
26
|
+
subcommands
|
27
|
+
end
|
28
|
+
|
29
|
+
delegate :instance_class, :stereotype_module, :stereotype_name, to: :class
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def instance_uncached
|
34
|
+
self.class.instance_class.by_id(parsed.instance_id)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/avm/jobs/base.rb
CHANGED
@@ -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
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/gems_registry'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Registry
|
8
|
+
class Base
|
9
|
+
enable_simple_cache
|
10
|
+
common_constructor :module_suffix
|
11
|
+
|
12
|
+
def detect(*registered_initialize_args)
|
13
|
+
detect_optional(*registered_initialize_args) ||
|
14
|
+
raise("No registered module valid for #{registered_initialize_args}" \
|
15
|
+
" (Module suffix: #{module_suffix})")
|
16
|
+
end
|
17
|
+
|
18
|
+
def detect_optional(*registered_initialize_args)
|
19
|
+
registered_modules.lazy.map { |klass| klass.new(*registered_initialize_args) }
|
20
|
+
.find(&:valid?)
|
21
|
+
end
|
22
|
+
|
23
|
+
def provider_module_suffix
|
24
|
+
"#{module_suffix}::Provider"
|
25
|
+
end
|
26
|
+
|
27
|
+
def single_module_suffix
|
28
|
+
"#{module_suffix}::Base"
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
"#{self.class}[#{module_suffix}]"
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid_registered_module?(a_module)
|
36
|
+
a_module.is_a?(::Class) && !a_module.abstract?
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def registered_modules_uncached
|
42
|
+
(single_registered_modules + provider_registered_modules)
|
43
|
+
.select { |v| valid_registered_module?(v) }.uniq.sort_by { |s| [s.name] }
|
44
|
+
end
|
45
|
+
|
46
|
+
def single_registered_modules
|
47
|
+
single_instance_registry.registered.map(&:registered_module)
|
48
|
+
end
|
49
|
+
|
50
|
+
def provider_registered_modules
|
51
|
+
provider_registry.registered.map(&:registered_module).flat_map do |provider_class|
|
52
|
+
provider_class.new.all
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def single_instance_registry_uncached
|
57
|
+
::EacRubyUtils::GemsRegistry.new(single_module_suffix)
|
58
|
+
end
|
59
|
+
|
60
|
+
def provider_registry_uncached
|
61
|
+
::EacRubyUtils::GemsRegistry.new(provider_module_suffix)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/avm/registry.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/gems_registry'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Registry
|
8
|
+
require_sub __FILE__
|
9
|
+
enable_listable
|
10
|
+
lists.add_symbol :category, :instance_stereotypes, :runners, :scms, :source_stereotypes
|
11
|
+
|
12
|
+
class << self
|
13
|
+
enable_simple_cache
|
14
|
+
|
15
|
+
# @return [Array<Avm::Registry::Base>]
|
16
|
+
def registries
|
17
|
+
lists.category.values.map { |c| send(c) }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
::Avm::Registry.lists.category.each_value do |category|
|
23
|
+
define_method "#{category}_uncached" do
|
24
|
+
::Avm::Registry::Base.new(category.to_s.camelize)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Rspec
|
7
|
+
module Setup
|
8
|
+
def self.extended(obj)
|
9
|
+
obj.setup_in_avm_registry_example
|
10
|
+
obj.setup_not_in_avm_registry_example
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup_in_avm_registry_example
|
14
|
+
require 'avm/rspec/shared_examples/in_avm_registry'
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup_not_in_avm_registry_example
|
18
|
+
require 'avm/rspec/shared_examples/not_in_avm_registry'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/registry'
|
4
|
+
|
5
|
+
::RSpec.shared_examples 'in_avm_registry' do |registry_method|
|
6
|
+
let(:avm_registry) { ::Avm::Registry.send(registry_method) }
|
7
|
+
|
8
|
+
it 'is in the avm registry' do
|
9
|
+
expect(avm_registry.registered_modules).to include(described_class)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/registry'
|
4
|
+
|
5
|
+
::RSpec.shared_examples 'not_in_avm_registry' do |registry_method = nil|
|
6
|
+
registry_method.if_present(::Avm::Registry.registries) { |v| [::Avm::Registry.send(v)] }
|
7
|
+
.each do |registry|
|
8
|
+
context "when registry is #{registry}" do
|
9
|
+
it 'is not in the avm registry' do
|
10
|
+
expect(registry.registered_modules).not_to include(described_class)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|