avm-tools 0.71.0 → 0.72.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f1459b957df5b13191a6411437651630d19ef6db3b12f62441d59238ede4679
4
- data.tar.gz: 816d7f150ca0aa5e5cc573a77395b92c36fcba8fb41429f93dadc94f506233d8
3
+ metadata.gz: acf6e22d7179f5a2ad489b5091ef57883c91d94020815952bc3135df2f1cfd7d
4
+ data.tar.gz: 4f4eb1ef234e44157bc7b66dc44b2903e2c881e3406f31ee6a183eebba3f2ec0
5
5
  SHA512:
6
- metadata.gz: 422c93704e878d5894ac17e38f4df881d98a70ebd90696fa98fa9968b583710e2c2f7ff2f31cefb1df3fd9b01f2536d7ae6ee26ea35f6a98d5ae113415cec610
7
- data.tar.gz: 3720efd94cdeb9dc295f53f7ac22e3460bf67f6e8c5ee1ef654ee4f3320de65138dfc70538d6bc2e2ae4f1b589c81960ca685af5685a4778f42158a59ce9118c
6
+ metadata.gz: c0fbaaa584f10fc580e2f6c1c2635b673b9f481603b00a5851c2894955cc930d748111d3eb15a5e7069d0f35ac93fe6da7e1519e757822e03641eae989bf08f3
7
+ data.tar.gz: 8040458407704e5d6541556dfc03929ff6cf753e7e1fec83ac835602faac08327fece6b7e684cf58f80ddf1938d8ade8059fd2f6343f78010ca437228947e4e0
@@ -13,6 +13,10 @@ module Avm
13
13
  @id = id.to_s
14
14
  end
15
15
 
16
+ def to_s
17
+ id
18
+ end
19
+
16
20
  def instance(suffix)
17
21
  ::Avm::Instances::Base.new(self, suffix)
18
22
  end
@@ -3,6 +3,7 @@
3
3
  require 'eac_ruby_utils/require_sub'
4
4
  require 'eac_ruby_utils/simple_cache'
5
5
  require 'avm/instances/entries'
6
+ require 'avm/instances/entry_keys'
6
7
  ::EacRubyUtils.require_sub(__FILE__)
7
8
 
8
9
  module Avm
@@ -62,7 +63,7 @@ module Avm
62
63
  private
63
64
 
64
65
  def source_instance_uncached
65
- ::Avm::Instances::Base.by_id(read_entry(:source_instance_id))
66
+ ::Avm::Instances::Base.by_id(read_entry(::Avm::Instances::EntryKeys::SOURCE_INSTANCE_ID))
66
67
  end
67
68
  end
68
69
  end
@@ -10,19 +10,20 @@ module Avm
10
10
  end
11
11
 
12
12
  def auto_ssh_hostname
13
- inherited_entry_value(:host_id, 'ssh.hostname')
13
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.hostname')
14
14
  end
15
15
 
16
16
  def auto_ssh_port
17
- inherited_entry_value(:host_id, 'ssh.port') || 22
17
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.port') || 22
18
18
  end
19
19
 
20
20
  def auto_ssh_username
21
- inherited_entry_value(:host_id, 'ssh.username')
21
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.username')
22
22
  end
23
23
 
24
24
  def auto_ssh_url
25
- inherited_entry_value(:host_id, 'ssh.url') || auto_ssh_url_by_parts
25
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.url') ||
26
+ auto_ssh_url_by_parts
26
27
  end
27
28
 
28
29
  def auto_ssh_url_by_parts
@@ -6,11 +6,11 @@ module Avm
6
6
  module AutoValues
7
7
  module Admin
8
8
  def auto_admin_email
9
- inherited_entry_value(:host_id, 'admin.email')
9
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'admin.email')
10
10
  end
11
11
 
12
12
  def auto_admin_name
13
- inherited_entry_value(:host_id, 'admin.name')
13
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'admin.name')
14
14
  end
15
15
  end
16
16
  end
@@ -46,7 +46,7 @@ module Avm
46
46
  def database_auto_common(suffix)
47
47
  database_key = ::Avm::Instances::EntryKeys.const_get("database_#{suffix}".upcase)
48
48
  inherited_entry_value(::Avm::Instances::EntryKeys::DATABASE_ID, database_key) ||
49
- inherited_entry_value(:host_id, database_key)
49
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, database_key)
50
50
  end
51
51
 
52
52
  def database_port_by_system
@@ -8,11 +8,15 @@ module Avm
8
8
  FS_PATH_KEY = :fs_path
9
9
 
10
10
  def auto_fs_path
11
- inherited_entry_value(:host_id, FS_PATH_KEY) { |v| v + '/' + id }
11
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, FS_PATH_KEY) do |v|
12
+ v + '/' + id
13
+ end
12
14
  end
13
15
 
14
16
  def auto_data_fs_path
15
- inherited_entry_value(:host_id, :data_fs_path) { |v| v + '/' + id }
17
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, :data_fs_path) do |v|
18
+ v + '/' + id
19
+ end
16
20
  end
17
21
 
18
22
  def auto_fs_url
@@ -6,7 +6,7 @@ module Avm
6
6
  module AutoValues
7
7
  module Ruby
8
8
  def auto_ruby_version
9
- inherited_entry_value(:host_id, 'ruby.version')
9
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ruby.version')
10
10
  end
11
11
  end
12
12
  end
@@ -8,12 +8,12 @@ module Avm
8
8
  module AutoValues
9
9
  module System
10
10
  def auto_system_username
11
- inherited_entry_value(:host_id, 'system.username') ||
11
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'system.username') ||
12
12
  read_entry_optional('ssh.username')
13
13
  end
14
14
 
15
15
  def auto_system_groupname
16
- inherited_entry_value(:host_id, 'system.groupname') ||
16
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'system.groupname') ||
17
17
  read_entry_optional('system.username')
18
18
  end
19
19
  end
@@ -5,6 +5,12 @@ require 'eac_ruby_utils/core_ext'
5
5
  module Avm
6
6
  module Instances
7
7
  class Entry
8
+ class << self
9
+ def auto_value_method_name(suffix)
10
+ "auto_#{suffix.to_s.gsub('.', '_')}"
11
+ end
12
+ end
13
+
8
14
  common_constructor :parent, :suffix, :options
9
15
 
10
16
  def auto_value
@@ -12,7 +18,7 @@ module Avm
12
18
  end
13
19
 
14
20
  def auto_value_method
15
- "auto_#{suffix.to_s.gsub('.', '_')}"
21
+ self.class.auto_value_method_name(suffix)
16
22
  end
17
23
 
18
24
  def full_path
@@ -3,17 +3,48 @@
3
3
  module Avm
4
4
  module Instances
5
5
  module EntryKeys
6
- {
7
- database: %w[id hostname name password port system username],
8
- web: %w[authority hostname path port scheme url userinfo]
9
- }.each do |prefix, suffixes|
10
- suffixes.each do |suffix|
11
- key = "#{prefix}.#{suffix}"
6
+ class << self
7
+ def all
8
+ all_keys.to_a
9
+ end
10
+
11
+ def keys_consts_set(prefix, suffixes)
12
+ if suffixes.is_a?(::Hash)
13
+ keys_consts_set_from_hash(prefix, suffixes)
14
+ elsif suffixes.is_a?(::Enumerable)
15
+ keys_consts_set_from_enum(prefix, suffixes)
16
+ else
17
+ raise "Unmapped suffixes class: #{suffixes.class}"
18
+ end
19
+ end
20
+
21
+ def key_const_set(prefix, suffix)
22
+ key = [prefix, suffix].reject(&:blank?).join('.')
12
23
  const_set(key.gsub('.', '_').upcase, key)
24
+ all_keys << key
25
+ end
26
+
27
+ private
28
+
29
+ def all_keys
30
+ @all_keys ||= ::Set.new
31
+ end
32
+
33
+ def keys_consts_set_from_enum(prefix, suffixes)
34
+ suffixes.each { |suffix| key_const_set(prefix, suffix) }
35
+ end
36
+
37
+ def keys_consts_set_from_hash(prefix, suffixes)
38
+ suffixes.each { |k, v| keys_consts_set(prefix.to_s + (k.blank? ? '' : ".#{k}"), v) }
13
39
  end
14
40
  end
15
41
 
16
- FS_PATH = 'fs_path'
42
+ {
43
+ '' => %w[fs_path host_id source_instance_id],
44
+ database: %w[id hostname name password port system username],
45
+ ssh: %w[hostname port url username],
46
+ web: %w[authority hostname path port scheme url userinfo]
47
+ }.each { |prefix, suffixes| keys_consts_set(prefix, suffixes) }
17
48
  end
18
49
  end
19
50
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'eac_cli/core_ext'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Instance < ::EacRubyUtils::Console::DocoptRunner
11
+ require_sub __FILE__
12
+ runner_with
13
+
14
+ runner_definition do
15
+ desc 'Utilities for generic instances.'
16
+ pos_arg :instance_id
17
+ subcommands
18
+ end
19
+
20
+ private
21
+
22
+ def instance_uncached
23
+ ::Avm::Instances::Base.by_id(options['<instance_id>'])
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/entry_keys'
4
+ require 'eac_cli/core_ext'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Instance < ::EacRubyUtils::Console::DocoptRunner
11
+ class Info < ::EacRubyUtils::Console::DocoptRunner
12
+ runner_with
13
+
14
+ runner_definition do
15
+ desc 'Show info about a instance.'
16
+ end
17
+
18
+ def run
19
+ base_banner
20
+ entry_keys_banner
21
+ end
22
+
23
+ private
24
+
25
+ def base_banner
26
+ infov 'ID', instance.id
27
+ infov 'Application ID', instance.application.id
28
+ infov 'Suffix', instance.suffix
29
+ end
30
+
31
+ def entry_keys_banner
32
+ ::Avm::Instances::EntryKeys.all.each do |key|
33
+ infov key, instance.read_entry_optional(key)
34
+ end
35
+ end
36
+
37
+ def instance
38
+ context(:instance)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.71.0'
5
+ VERSION = '0.72.0'
6
6
  end
7
7
  end
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.71.0
4
+ version: 0.72.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-10-14 00:00:00.000000000 Z
11
+ date: 2020-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -493,6 +493,8 @@ files:
493
493
  - lib/avm/tools/runner/git/revisions_test.rb
494
494
  - lib/avm/tools/runner/git/subrepo.rb
495
495
  - lib/avm/tools/runner/git/subrepo/check.rb
496
+ - lib/avm/tools/runner/instance.rb
497
+ - lib/avm/tools/runner/instance/info.rb
496
498
  - lib/avm/tools/runner/launcher.rb
497
499
  - lib/avm/tools/runner/launcher/instances.rb
498
500
  - lib/avm/tools/runner/launcher/projects.rb