avm 0.91.0 → 0.93.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: 24587b61abe782918bcfe1b372328d0e9f9ca88db23c9c3990883a8cd88d444b
4
- data.tar.gz: 2b1f1f7d2aa5cb42e8ca326d659b7b749aa7f50278c81347432dbc4e68a32b8d
3
+ metadata.gz: 2c1fee20bfe64a0b6d97f7866255914971859fb503ab18825eaf9be01a137aad
4
+ data.tar.gz: 964391eaa0ac606596e4aeb3b87ecd0c4ffcc1c78cadb86e98569e6ab660e06d
5
5
  SHA512:
6
- metadata.gz: c97c2ad6f2857a9b6ccf70f0854b02e39cda4c555aec46174fc7a19ab41f440e7a1b505f6e3c1f377423efad38738a8e843417b30038dda054f151715402401e
7
- data.tar.gz: b0231edc3a011674a2c2cbf048ad4efc66139171f91798e175dc867f889b94888d4086350f27a916f94471956f3f366e0242ffb7c832b9e0ae37589fd6647828
6
+ metadata.gz: 03a07968e45e58c41fcf6a5aed935b78f116b51e4fc536c9cd408b316404d5f8ac24ae262bd1d77e584fda8ad62641a13062b529a859483895389ac7ca6db732
7
+ data.tar.gz: a1f51632e1d257cfbf50197c60bc9f8bd3acd18a9e136911387b12257b296373f72bf640de5b5cf09c187770ca47b0e3b8cf5a0b18efb264d0757893924c7db8
@@ -7,6 +7,7 @@ module Avm
7
7
  module Docker
8
8
  class Runner
9
9
  DOCKER_DEFAULT_REGISTRY_METHOD = :docker_default_registry
10
+ DOCKER_DEFAULT_REGISTRY_NAME = 'local'
10
11
 
11
12
  enable_speaker
12
13
  enable_simple_cache
@@ -33,6 +34,11 @@ module Avm
33
34
  container_run
34
35
  end
35
36
 
37
+ # @return [EacDocker::Registry, nil]
38
+ def docker_default_registry
39
+ ::EacDocker::Registry.new(default_docker_registry_name)
40
+ end
41
+
36
42
  private
37
43
 
38
44
  def setup
@@ -65,6 +71,11 @@ module Avm
65
71
  instance.docker_container
66
72
  end
67
73
 
74
+ # @return [String]
75
+ def default_docker_registry_name
76
+ DOCKER_DEFAULT_REGISTRY_NAME
77
+ end
78
+
68
79
  def docker_image
69
80
  instance.docker_image
70
81
  end
@@ -22,6 +22,11 @@ module Avm
22
22
  context_entry.found?
23
23
  end
24
24
 
25
+ # @return [Boolean]
26
+ def found?
27
+ context_found?
28
+ end
29
+
25
30
  def full_path
26
31
  (parent.path_prefix + suffix_as_array).join('.')
27
32
  end
@@ -18,6 +18,11 @@ module Avm
18
18
  )
19
19
  end
20
20
  end
21
+
22
+ # @return [Boolean]
23
+ def auto_data_allow_loading
24
+ local? || !production?
25
+ end
21
26
  end
22
27
  end
23
28
  end
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/applications/base/local_instance'
4
+
3
5
  module Avm
4
6
  module Instances
5
7
  class Base
6
8
  module AutoValues
7
9
  module Source
8
10
  def auto_source_instance_id
9
- "#{application.id}_dev"
11
+ [application.id, ::Avm::Applications::Base::LocalInstance::LOCAL_INSTANCE_SUFFIX]
12
+ .join('_')
10
13
  end
11
14
  end
12
15
  end
@@ -0,0 +1,34 @@
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 Production
10
+ DEFAULT_PRODUCTION = true
11
+ PRODUCTION_KEY = 'production'
12
+
13
+ # @return [Boolean]
14
+ def default_production?
15
+ DEFAULT_PRODUCTION
16
+ end
17
+
18
+ # @return [Boolean]
19
+ def production?
20
+ if production_entry.found?
21
+ production_entry.value.to_bool
22
+ else
23
+ default_production?
24
+ end
25
+ end
26
+
27
+ # @return [Avm::Entries::Entry]
28
+ def production_entry
29
+ entry(PRODUCTION_KEY)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/instances/ids'
4
+ require 'avm/applications/base/local_instance'
4
5
  require 'avm/with/application_stereotype'
5
6
  require 'avm/with/extra_subcommands'
6
7
  require 'eac_ruby_utils/require_sub'
@@ -61,6 +62,11 @@ module Avm
61
62
  end
62
63
  end
63
64
 
65
+ # @return [Boolean]
66
+ def local?
67
+ suffix == ::Avm::Applications::Base::LocalInstance::LOCAL_INSTANCE_SUFFIX
68
+ end
69
+
64
70
  private
65
71
 
66
72
  def source_instance_uncached
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Instances
5
+ module Data
6
+ class LoadingDeniedError < ::RuntimeError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -18,8 +18,8 @@ module Avm
18
18
  instance.data_default_dump_path.to_pathname
19
19
  end
20
20
 
21
- def load(*args, &block)
22
- instance.on_disabled_processes { super(*args, &block) }
21
+ def load(...)
22
+ instance.on_disabled_processes { super }
23
23
  end
24
24
  end
25
25
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/data/unit_with_commands'
4
+ require 'avm/instances/data/loading_denied_error'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module Avm
@@ -9,6 +10,14 @@ module Avm
9
10
  class Unit < ::Avm::Data::UnitWithCommands
10
11
  common_constructor :instance
11
12
 
13
+ # @return [void]
14
+ # @raise Avm::Instances::Data::Unit
15
+ def check_load_permission!
16
+ return if instance.data_allow_loading
17
+
18
+ raise ::Avm::Instances::Data::LoadingDeniedError, "Instance: #{instance}"
19
+ end
20
+
12
21
  # @return [Pathname]
13
22
  def data_default_dump_path
14
23
  instance.data_default_dump_path.to_pathname.basename_sub('.*') do |b|
@@ -21,8 +30,9 @@ module Avm
21
30
  instance.data_package.units.key(self) || raise("No identifier found for #{self}")
22
31
  end
23
32
 
24
- def load(*args, &block)
25
- instance.on_disabled_processes { super(*args, &block) }
33
+ def load(...)
34
+ check_load_permission!
35
+ instance.on_disabled_processes { super }
26
36
  end
27
37
  end
28
38
  end
@@ -28,7 +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
+ data: %w[allow_loading default_dump_path],
32
32
  database: URI_FIELDS + %w[id limit name system timeout extra],
33
33
  docker: %w[registry],
34
34
  install: URI_FIELDS + %w[id data_path email groupname],
@@ -7,7 +7,7 @@ module Avm
7
7
  def initialize(path)
8
8
  raise "Argument path is not a string: \"#{path}\"|#{path.class}" unless path.is_a?(String)
9
9
 
10
- super(path)
10
+ super
11
11
  end
12
12
 
13
13
  def subpath(relative_path)
@@ -4,15 +4,18 @@ require 'eac_fs/comparator'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  RSpec.shared_examples 'avm_source_generated' do |spec_file, stereotype, options = {}|
7
- fixtures_dir = Pathname.new('base_spec_files').expand_path(File.dirname(spec_file))
7
+ include_context 'spec_paths', spec_file
8
+ block_on_each_source = options.delete(:block_on_each_source)
8
9
 
9
- fixtures_dir.children.select(&:directory?).each do |target_dir|
10
+ spec_paths_controller.fixtures_directory.children.select(&:directory?).each do |target_dir|
10
11
  context "when target is \"#{target_dir.basename}\"" do
11
12
  let(:source) { avm_source(stereotype, options.merge(target_basename: target_dir.basename)) }
12
13
 
13
14
  it do
14
15
  expect(fs_comparator.build(source.path)).to eq(fs_comparator.build(target_dir))
15
16
  end
17
+
18
+ instance_exec(&block_on_each_source) if block_on_each_source
16
19
  end
17
20
  end
18
21
 
@@ -8,6 +8,8 @@ module Avm
8
8
  module SourceGenerators
9
9
  class Base
10
10
  acts_as_abstract
11
+ enable_settings_provider
12
+ enable_speaker
11
13
  include ::Avm::With::ApplicationStereotype
12
14
 
13
15
  class << self
@@ -17,19 +19,29 @@ module Avm
17
19
  end
18
20
  end
19
21
 
22
+ OPTION_NAME = 'name'
23
+ JOBS = [].freeze
24
+
20
25
  common_constructor :target_path, :options, default: [{}] do
21
26
  self.target_path = target_path.to_pathname
22
27
  self.options = option_list.validate(options)
23
28
  end
24
29
 
30
+ # @return [String]
31
+ def name
32
+ options[OPTION_NAME].if_present(target_path.basename.to_path)
33
+ end
34
+
25
35
  # @return [Avm::SourceGenerators::OptionList]
26
36
  def option_list
27
37
  self.class.option_list
28
38
  end
29
39
 
30
40
  def perform
41
+ start_banner
31
42
  assert_clear_directory
32
43
  apply_template
44
+ perform_jobs
33
45
  end
34
46
 
35
47
  def assert_clear_directory
@@ -38,7 +50,25 @@ module Avm
38
50
  end
39
51
 
40
52
  def apply_template
41
- template.apply(self, target_path)
53
+ root_template.apply(self, target_path)
54
+ end
55
+
56
+ def perform_jobs
57
+ setting_value(:jobs).each do |job|
58
+ infom "Generating #{job.humanize}..."
59
+ send("generate_#{job}")
60
+ end
61
+ end
62
+
63
+ # @return [void]
64
+ def start_banner
65
+ infov 'Target path', target_path
66
+ infov 'Application name', name
67
+ end
68
+
69
+ # @return [EacTemlates::Modules::Base]
70
+ def root_template
71
+ template
42
72
  end
43
73
  end
44
74
  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.91.0'
4
+ VERSION = '0.93.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.91.0
4
+ version: 0.93.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: 2024-05-15 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.40'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.40.1
19
+ version: '0.42'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.40'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.40.1
26
+ version: '0.42'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: eac_config
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,34 +78,28 @@ dependencies:
84
78
  requirements:
85
79
  - - "~>"
86
80
  - !ruby/object:Gem::Version
87
- version: '0.121'
81
+ version: '0.122'
88
82
  type: :runtime
89
83
  prerelease: false
90
84
  version_requirements: !ruby/object:Gem::Requirement
91
85
  requirements:
92
86
  - - "~>"
93
87
  - !ruby/object:Gem::Version
94
- version: '0.121'
88
+ version: '0.122'
95
89
  - !ruby/object:Gem::Dependency
96
90
  name: eac_templates
97
91
  requirement: !ruby/object:Gem::Requirement
98
92
  requirements:
99
93
  - - "~>"
100
94
  - !ruby/object:Gem::Version
101
- version: '0.5'
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: 0.5.1
95
+ version: '0.7'
105
96
  type: :runtime
106
97
  prerelease: false
107
98
  version_requirements: !ruby/object:Gem::Requirement
108
99
  requirements:
109
100
  - - "~>"
110
101
  - !ruby/object:Gem::Version
111
- version: '0.5'
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: 0.5.1
102
+ version: '0.7'
115
103
  - !ruby/object:Gem::Dependency
116
104
  name: minitar
117
105
  requirement: !ruby/object:Gem::Requirement
@@ -269,10 +257,12 @@ files:
269
257
  - lib/avm/instances/base/entry_keys.rb
270
258
  - lib/avm/instances/base/install.rb
271
259
  - lib/avm/instances/base/processes.rb
260
+ - lib/avm/instances/base/production.rb
272
261
  - lib/avm/instances/base/subcommand_parent.rb
273
262
  - lib/avm/instances/base/web.rb
274
263
  - lib/avm/instances/data.rb
275
264
  - lib/avm/instances/data/files_unit.rb
265
+ - lib/avm/instances/data/loading_denied_error.rb
276
266
  - lib/avm/instances/data/package.rb
277
267
  - lib/avm/instances/data/unit.rb
278
268
  - lib/avm/instances/docker_image.rb