avm 0.69.0 → 0.71.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: bd7769c233c47e084dedc71f52d43c93aef1ed251f9f0ba0fcd9fe25d38b5cd8
4
- data.tar.gz: 20400fe033dd9bf515f3c971179b5b22ed6097879c317946e6a59d6f5b0544f7
3
+ metadata.gz: 02d8da25080bc20bd3138de4a659dcba371fc150255f823c8fac34ac03ecfbf3
4
+ data.tar.gz: a83f46dd107ca4dd342d9273cb1592d3dd129d6a6da5b2cfb2017d30b5452188
5
5
  SHA512:
6
- metadata.gz: 447679562bdfd2d1da1d38ee1e34eecb3214d0c4763316cf75b69d2b91661c783b732252992e11e1abafab0f34fd38ab7ba3b505c9ff6381c7e9331a378d3cee
7
- data.tar.gz: 38a20f723ac5c348a755cc4b558d89b37acafeafb20e4fc027c314bea5a3717194767ab3afaf533892f16632d250f65ae911bb5b96ca98b7a277769c171fea3b
6
+ metadata.gz: 56fa769340dc76338317f62a4a8b8dd9537de35b4a29c8a2548db53f739d7f6160fdda83f648df74879f7ad03a7f40c7b8a2622957769833c365d5fad250db24
7
+ data.tar.gz: c464874fed76e5877450d76633908073d92a3fdaca4f40c4cf4189d491c1b95118a9aa87f4595e1abffb6ca85433709977e507baf0657e30ff7a1dc553bd28de
@@ -46,7 +46,7 @@ module Avm
46
46
  end
47
47
 
48
48
  # @param id [Symbol]
49
- # @return [Avm::Data::Unit]
49
+ # @return [Avm::Data::UnitWithCommands]
50
50
  def unit(identifier)
51
51
  units[identifier.to_sym] || raise("No unit found with identifier \"#{identifier}\"")
52
52
  end
data/lib/avm/data/unit.rb CHANGED
@@ -6,72 +6,43 @@ require 'eac_ruby_utils/core_ext'
6
6
  module Avm
7
7
  module Data
8
8
  class Unit
9
- include ::Avm::Data::Callbacks
10
-
9
+ acts_as_abstract(
10
+ do_clear: [],
11
+ do_dump: [:dump_path],
12
+ do_load: [:dump_path],
13
+ dump_path_extension: []
14
+ )
11
15
  enable_speaker
16
+ include ::Avm::Data::Callbacks
12
17
 
13
- %w[dump load].each do |action|
14
- method_name = "#{action}_command"
15
- class_eval <<~CODE, __FILE__, __LINE__ + 1
16
- # Should be overrided.
17
- # @return [EacRubyUtils::Envs::Command]
18
- def #{method_name}
19
- fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
20
- end
21
- CODE
22
- end
23
-
24
- def extension
25
- singleton_class.const_get('EXTENSION')
26
- rescue NameError
27
- ''
28
- end
29
-
30
- def name
31
- self.class
32
- end
33
-
34
- def load_from_directory(directory, identifier)
35
- load(unit_on_directory_path(directory, identifier))
36
- end
37
-
38
- def dump_to_directory(directory, identifier)
39
- dump(unit_on_directory_path(directory, identifier))
18
+ # @param dump_path [Pathname]
19
+ # @return [void]
20
+ def clear
21
+ run_callbacks(:dump) { do_clear }
40
22
  end
41
23
 
42
- def dump(data_path)
24
+ # @param dump_path [Pathname]
25
+ # @return [void]
26
+ def dump(dump_path)
43
27
  run_callbacks :dump do
44
- infom "Dumping unit \"#{name}\" to \"#{data_path}\"..."
45
- do_dump(data_path)
28
+ infom "Dumping unit \"#{name}\" to \"#{dump_path}\"..."
29
+ do_dump(dump_path)
46
30
  end
47
31
  end
48
32
 
49
- # @return [Struct(:key, :subpath), nil]
50
- def installation_files_data
51
- nil
52
- end
53
-
54
- def load(data_path)
33
+ # @param dump_path [Pathname]
34
+ # @return [void]
35
+ def load(dump_path)
55
36
  run_callbacks :load do
56
- infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
57
- do_load(data_path)
37
+ clear
38
+ infom "Loading unit \"#{name}\" from \"#{dump_path}\"..."
39
+ do_load(dump_path)
58
40
  end
59
41
  end
60
42
 
61
- protected
62
-
63
- def do_dump(data_path)
64
- dump_command.execute!(output_file: data_path)
65
- end
66
-
67
- def do_load(data_path)
68
- load_command.execute!(input_file: data_path)
69
- end
70
-
71
- private
72
-
73
- def unit_on_directory_path(directory, identifier)
74
- ::File.join(directory, "#{identifier}#{extension}")
43
+ # @return [String]
44
+ def name
45
+ self.class.name
75
46
  end
76
47
  end
77
48
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/callbacks'
4
+ require 'avm/data/unit'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Data
9
+ class UnitWithCommands < ::Avm::Data::Unit
10
+ acts_as_abstract
11
+
12
+ abstract_method :dump_command
13
+ abstract_method :load_command
14
+
15
+ # @return [String]
16
+ def dump_path_extension
17
+ singleton_class.const_get('EXTENSION')
18
+ rescue NameError
19
+ ''
20
+ end
21
+
22
+ def load_from_directory(directory, identifier)
23
+ load(unit_on_directory_path(directory, identifier))
24
+ end
25
+
26
+ def dump_to_directory(directory, identifier)
27
+ dump(unit_on_directory_path(directory, identifier))
28
+ end
29
+
30
+ # @return [Struct(:key, :subpath), nil]
31
+ def installation_files_data
32
+ nil
33
+ end
34
+
35
+ protected
36
+
37
+ def do_dump(data_path)
38
+ dump_command.execute!(output_file: data_path)
39
+ end
40
+
41
+ def do_load(data_path)
42
+ load_command.execute!(input_file: data_path)
43
+ end
44
+
45
+ private
46
+
47
+ def unit_on_directory_path(directory, identifier)
48
+ ::File.join(directory, "#{identifier}#{dump_path_extension}")
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner/context'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Instances
8
+ class Base
9
+ class SubcommandParent
10
+ enable_simple_cache
11
+ common_constructor :instance
12
+
13
+ private
14
+
15
+ def runner_context_uncached
16
+ ::EacCli::Runner::Context.new(self, argv: runner_argv)
17
+ end
18
+
19
+ def runner_argv
20
+ [instance.class.name.split('::')[-2].dasherize, instance.id]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -17,8 +17,6 @@ module Avm
17
17
  self.options = self.class.lists.option.hash_keys_validate!(options)
18
18
  end
19
19
 
20
- before_load :clear
21
-
22
20
  # @return [Pathname]
23
21
  def files_path
24
22
  fs_path_subpath
@@ -33,8 +31,7 @@ module Avm
33
31
  instance_command('tar', '-xzf', '-', '-C', files_path)
34
32
  end
35
33
 
36
- def clear
37
- infom "Removing all files under #{files_path}..."
34
+ def do_clear
38
35
  instance_command('mkdir', '-p', files_path).execute!
39
36
  instance_command('find', files_path, '-mindepth', 1, '-delete').execute!
40
37
  end
@@ -1,13 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/data/unit'
3
+ require 'avm/data/unit_with_commands'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Instances
8
8
  module Data
9
- class Unit < ::Avm::Data::Unit
9
+ class Unit < ::Avm::Data::UnitWithCommands
10
10
  common_constructor :instance
11
+
12
+ # @return [Pathname]
13
+ def data_default_dump_path
14
+ instance.data_default_dump_path.to_pathname.basename_sub('.*') do |b|
15
+ "#{b}_#{identifier}#{dump_path_extension}"
16
+ end
17
+ end
18
+
19
+ # @return [String]
20
+ def identifier
21
+ instance.data_package.units.key(self) || raise("No identifier found for #{self}")
22
+ end
11
23
  end
12
24
  end
13
25
  end
@@ -28,6 +28,7 @@ module Avm
28
28
  {
29
29
  '' => %w[name source_instance_id],
30
30
  admin: URI_FIELDS + %w[api_key],
31
+ data: %w[default_dump_path],
31
32
  database: URI_FIELDS + %w[id limit name system timeout extra],
32
33
  docker: %w[registry],
33
34
  install: URI_FIELDS + %w[id data_path email groupname],
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.69.0'
4
+ VERSION = '0.71.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.69.0
4
+ version: 0.71.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: 2023-05-10 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.32'
39
+ version: '0.33'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.32'
46
+ version: '0.33'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eac_config
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +112,14 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '0.113'
115
+ version: '0.115'
116
116
  type: :runtime
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '0.113'
122
+ version: '0.115'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: eac_templates
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -244,6 +244,7 @@ files:
244
244
  - lib/avm/data/package/load.rb
245
245
  - lib/avm/data/rotate.rb
246
246
  - lib/avm/data/unit.rb
247
+ - lib/avm/data/unit_with_commands.rb
247
248
  - lib/avm/docker.rb
248
249
  - lib/avm/docker/container.rb
249
250
  - lib/avm/docker/image.rb
@@ -288,6 +289,7 @@ files:
288
289
  - lib/avm/instances/base/dockerizable.rb
289
290
  - lib/avm/instances/base/entry_keys.rb
290
291
  - lib/avm/instances/base/install.rb
292
+ - lib/avm/instances/base/subcommand_parent.rb
291
293
  - lib/avm/instances/base/web.rb
292
294
  - lib/avm/instances/data.rb
293
295
  - lib/avm/instances/data/files_unit.rb