avm 0.12.1 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e949017d91bbc44c21d53d6d20f778651263e189b74df7b977ec0cadd363834f
4
- data.tar.gz: b1fee81908269fe0f8be74cf9a331b1683a16e526c3c4c3ca99b7566676d2ce5
3
+ metadata.gz: af8b48e6c2b68eae42fc189f37800c24267c60d74dab16e65b271848d45f553e
4
+ data.tar.gz: 2cc8fa0683ba1133e61847ee85ac838bb30ec638972e2126df1ebd77d6368606
5
5
  SHA512:
6
- metadata.gz: 248e15f73b3e1a022a418ed769fe6a2fe29c90be527e81684e509a0fb71f6139893414ae4db827711fee517bc6631de493b23cfe2883637811d4f693a53bb9ae
7
- data.tar.gz: b68181fc9625e26ef5bb103e431d9f1f7150f661d23503aa56252cff69e67615c687165b7d53dfdb257c09ef10672f6701b8bdb496056bdaaadc1ddcab1d4d06
6
+ metadata.gz: 6da4fd9d1296dae4e716d6da17ce53df86981dcade20a5df3e1aad9f044faeda2dd0287e39f680e393d78ed7a0a5b9de16a4e510ede5aa6ade061e86f036d815
7
+ data.tar.gz: 44ca2f513f2a86b30a5125fadcfe6a3d18877ad7ead72b97c4371f957abda401b07c7f2164a2f2e7fbf5f821219cd42b3f77394ce973dca0d5a5c07bcbd0f724
@@ -9,8 +9,8 @@ module Avm
9
9
  module AutoValues
10
10
  module Data
11
11
  def auto_data_default_dump_path
12
- ::Avm::Self
13
- .instance
12
+ ::Avm::Self::Instance
13
+ .default
14
14
  .read_entry_optional(::Avm::Self::Instance::EntryKeys::DATA_DEFAULT_PATH)
15
15
  .if_present do |v|
16
16
  ::File.join(
@@ -1,22 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/entry_keys'
4
+
3
5
  module Avm
4
6
  module Instances
5
7
  class Base
6
8
  module AutoValues
7
9
  module Filesystem
8
- FS_PATH_KEY = :fs_path
9
-
10
10
  def auto_fs_path
11
- inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, FS_PATH_KEY) do |v|
12
- v + '/' + id
13
- end
11
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID,
12
+ ::Avm::Instances::EntryKeys::FS_PATH) { |v| v + '/' + id }
14
13
  end
15
14
 
16
15
  def auto_data_fs_path
17
- inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, :data_fs_path) do |v|
18
- v + '/' + id
19
- end
16
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID,
17
+ ::Avm::Instances::EntryKeys::DATA_FS_PATH) { |v| v + '/' + id }
20
18
  end
21
19
 
22
20
  def auto_fs_url
@@ -27,11 +27,11 @@ module Avm
27
27
  end
28
28
 
29
29
  def optional_value
30
- read(required: false, noinput: true) || auto_value
30
+ context_entry.found? ? context_entry.value : auto_value
31
31
  end
32
32
 
33
- def read(extra_options = {})
34
- ::EacConfig::Node.context.current.entry(full_path, options.merge(extra_options)).value
33
+ def read
34
+ context_entry.value
35
35
  end
36
36
 
37
37
  def suffix_as_array
@@ -47,7 +47,13 @@ module Avm
47
47
  end
48
48
 
49
49
  def write(value)
50
- ::EacConfig::Node.context.current.entry(full_path).value = value
50
+ context_entry.value = value
51
+ end
52
+
53
+ private
54
+
55
+ def context_entry
56
+ ::EacConfig::Node.context.current.entry(full_path)
51
57
  end
52
58
  end
53
59
  end
@@ -42,7 +42,7 @@ module Avm
42
42
  end
43
43
 
44
44
  {
45
- '' => %w[fs_path host_id name source_instance_id],
45
+ '' => %w[data_fs_path fs_path host_id name source_instance_id],
46
46
  database: %w[id hostname limit name password port system timeout username extra],
47
47
  docker: %w[registry],
48
48
  mailer: {
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Launcher
5
+ module Errors
6
+ class Base < ::StandardError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/launcher/errors/base'
4
+
5
+ module Avm
6
+ module Launcher
7
+ module Errors
8
+ class NonProject < ::Avm::Launcher::Errors::Base
9
+ def initialize(path)
10
+ super("#{path} is not a project")
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Launcher
5
+ module Paths
6
+ class Real < String
7
+ def initialize(path)
8
+ raise "Argument path is not a string: \"#{path}\"|#{path.class}" unless path.is_a?(String)
9
+
10
+ super(path)
11
+ end
12
+
13
+ def subpath(relative_path)
14
+ ::Avm::Launcher::Paths::Real.new(::File.expand_path(relative_path, self))
15
+ end
16
+
17
+ def basename
18
+ ::File.basename(self)
19
+ end
20
+
21
+ def dirname
22
+ return nil if self == '/'
23
+
24
+ self.class.new(::File.dirname(self))
25
+ end
26
+
27
+ def find_file_with_extension(extension)
28
+ r = find_files_with_extension(extension)
29
+ return r.first if r.any?
30
+
31
+ raise "Extension \"#{extension}\" not found in directory \"#{self}\""
32
+ end
33
+
34
+ def find_files_with_extension(extension)
35
+ r = []
36
+ ::Dir.entries(self).each do |i|
37
+ r << ::File.expand_path(i, self) if i =~ /#{::Regexp.quote(extension)}\z/
38
+ end
39
+ r
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern' # Missing on "eac/listable"
4
+ require 'active_support/hash_with_indifferent_access'
5
+ require 'eac_ruby_utils/listable'
6
+
7
+ module Avm
8
+ module Launcher
9
+ module Publish
10
+ class CheckResult
11
+ include ::EacRubyUtils::Listable
12
+
13
+ lists.add_string :status, :updated, :pending, :blocked, :outdated
14
+
15
+ lists.status.values.each do |status| # rubocop:disable Style/HashEachMethods
16
+ class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
17
+ def self.#{status}(message)
18
+ new('#{status}', message)
19
+ end
20
+ RUBY_EVAL
21
+ end
22
+
23
+ class << self
24
+ def pending_status?(status)
25
+ [STATUS_PENDING].include?(status)
26
+ end
27
+
28
+ def updated_color
29
+ 'green'
30
+ end
31
+
32
+ def pending_color
33
+ 'yellow'
34
+ end
35
+
36
+ def blocked_color
37
+ 'red'
38
+ end
39
+
40
+ def outdated_color
41
+ 'light_blue'
42
+ end
43
+ end
44
+
45
+ attr_reader :status, :message
46
+
47
+ def initialize(status, message)
48
+ raise "Status \"#{status}\" not in #{self.class.lists.status.values}" unless
49
+ self.class.lists.status.values.include?(status)
50
+
51
+ @status = status
52
+ @message = message
53
+ end
54
+
55
+ def to_s
56
+ message.light_white.send("on_#{background_color}")
57
+ end
58
+
59
+ private
60
+
61
+ def background_color
62
+ self.class.send("#{status}_color")
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -8,6 +8,14 @@ require 'avm/eac_ubuntu_base0/docker_image'
8
8
  module Avm
9
9
  module Self
10
10
  class Instance < ::Avm::Instances::Base
11
+ DEFAULT_INSTANCE_ID = 'avm_self'
12
+
13
+ class << self
14
+ def default
15
+ @default ||= by_id(DEFAULT_INSTANCE_ID)
16
+ end
17
+ end
18
+
11
19
  def docker_image_class
12
20
  ::Avm::Self::DockerImage
13
21
  end
data/lib/avm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.12.1'
4
+ VERSION = '0.15.0'
5
5
  end
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.12.1
4
+ version: 0.15.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: 2021-12-11 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -219,6 +219,10 @@ files:
219
219
  - lib/avm/jobs.rb
220
220
  - lib/avm/jobs/base.rb
221
221
  - lib/avm/jobs/variables_source.rb
222
+ - lib/avm/launcher/errors/base.rb
223
+ - lib/avm/launcher/errors/non_project.rb
224
+ - lib/avm/launcher/paths/real.rb
225
+ - lib/avm/launcher/publish/check_result.rb
222
226
  - lib/avm/path_string.rb
223
227
  - lib/avm/registry.rb
224
228
  - lib/avm/registry/base.rb