avm-tools 0.28.0 → 0.30.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: e9056924dbceab142648a79e5da4b931c3391e2138fdf10196e0b0b7f79a529f
4
- data.tar.gz: b09f24e9e27940bfc314a9e4d236470ff6d0c0fd2e4d5b42f80b78f37848cf0b
3
+ metadata.gz: 0cfe97a7d0fe91a8c981753c6a1f54613eca1224a291b21f79fc40d599706dcb
4
+ data.tar.gz: 24af1b76d95b1f49502a676c2530cae9796848b601e97c66f2c2c2ad799ca30f
5
5
  SHA512:
6
- metadata.gz: 52a94ce93193368d76c1985d691672470699a54febfa7f957f0c48c1c0983bbc78e7b5d985c144a0678a9320577215f3be5a68a401678c708def8ba2f2dd3ccd
7
- data.tar.gz: 644e16d5d4bfc5d74b0410cad8ad382ceabb0cae1a9822dd1b9650fa9c711deab8060fd3566176e82b4baaf669a49c1473d2ab4859d7756c24f3fe8ce4cb7327
6
+ metadata.gz: c703058938922ecb22415179574396eff2d2ab775d7a9b9d46293e27f9510ee7701eb2c72184d777e5e5b8b2a4620b3622bf86c0af6c7ea09158762458f1b660
7
+ data.tar.gz: a42d70070a33d8452e02aac392864a62aae5d30c159ba93eb10bf0c24d5691ba9607a4994ea3b00ce45c8734ac257fe7d48605cf178e40e2f3c8619f8b9b04ce
@@ -11,6 +11,7 @@ module Avm
11
11
  enable_listable
12
12
 
13
13
  DEFAULT_EXPIRE_TIME = 1.days
14
+ DEFAULT_FILE_EXTENSION = '.tar'
14
15
 
15
16
  attr_reader :package, :data_file_path, :existing
16
17
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/self/instance'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module Avm
@@ -7,7 +8,9 @@ module Avm
7
8
  class Registry
8
9
  class << self
9
10
  def default
10
- @default ||= new(::Avm.configs.read_entry('self.docker.registry.name'))
11
+ @default ||= new(::Avm::Self.instance.read_entry(
12
+ ::Avm::Self::Instance::EntryKeys::DOCKER_REGISTRY_NAME
13
+ ))
11
14
  end
12
15
  end
13
16
 
@@ -10,7 +10,7 @@ module Avm
10
10
  extend ::ActiveSupport::Concern
11
11
 
12
12
  included do
13
- %w[Access Admin Database Filesystem Ruby Source System Web].each do |class_name|
13
+ %w[Access Admin Data Database Filesystem Ruby Source System Web].each do |class_name|
14
14
  include const_get(class_name)
15
15
  end
16
16
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/package/dump'
4
+ require 'avm/self/instance'
5
+
6
+ module Avm
7
+ module Instances
8
+ class Base
9
+ module AutoValues
10
+ module Data
11
+ def auto_data_default_dump_path
12
+ ::Avm::Self
13
+ .instance
14
+ .read_entry_optional(::Avm::Self::Instance::EntryKeys::DATA_DEFAULT_PATH)
15
+ .if_present do |v|
16
+ ::File.join(
17
+ v,
18
+ "#{id}#{::Avm::Data::Instance::Package::Dump::DEFAULT_FILE_EXTENSION}"
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'avm/instances/base'
4
4
  require 'avm/self/docker_image'
5
+ require 'avm/self/instance/entry_keys'
5
6
  require 'avm/stereotypes/eac_ubuntu_base0/docker_image'
6
7
 
7
8
  module Avm
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Self
5
+ class Instance < ::Avm::Instances::Base
6
+ module EntryKeys
7
+ DATA_DEFAULT_PATH = 'data.default_path'
8
+ DOCKER_REGISTRY_NAME = 'docker.registry.name'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,23 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/stereotypes/eac_webapp_base0/instance'
4
+ require 'avm/stereotypes/rails/instance'
4
5
 
5
6
  module Avm
6
7
  module Stereotypes
7
8
  module EacRailsBase0
8
9
  class Instance < ::Avm::Stereotypes::EacWebappBase0::Instance
9
- FILES_UNITS = { uploads: 'public/uploads' }.freeze
10
-
11
- def bundle(*args)
12
- host_env.command('bundle', *args)
13
- .envvar('BUNDLE_GEMFILE', ::File.join(read_entry('fs_path'), 'Gemfile'))
14
- .envvar('RAILS_ENV', 'production')
15
- .chdir(read_entry('fs_path'))
16
- end
10
+ include ::Avm::Stereotypes::Rails::Instance
17
11
 
18
- def rake(*args)
19
- bundle('exec', 'rake', *args)
20
- end
12
+ FILES_UNITS = { uploads: 'public/uploads' }.freeze
21
13
  end
22
14
  end
23
15
  end
@@ -2,11 +2,14 @@
2
2
 
3
3
  require 'avm/stereotypes/eac_ubuntu_base0/docker_image'
4
4
  require 'avm/stereotypes/eac_webapp_base0/instance'
5
+ require 'avm/stereotypes/rails/instance'
5
6
 
6
7
  module Avm
7
8
  module Stereotypes
8
9
  module EacRedmineBase0
9
10
  class Instance < ::Avm::Stereotypes::EacWebappBase0::Instance
11
+ include ::Avm::Stereotypes::Rails::Instance
12
+
10
13
  FILES_UNITS = { files: 'files' }.freeze
11
14
 
12
15
  def docker_image_class
@@ -12,8 +12,6 @@ module Avm
12
12
  class Instance < ::Avm::Instances::Base
13
13
  include ::Avm::Stereotypes::Postgresql::InstanceWith
14
14
 
15
- FILES_UNITS = { uploads: 'wp-content/uploads', themes: 'wp-content/themes' }.freeze
16
-
17
15
  def stereotype_name
18
16
  self.class.name.desconstantize.demodulize
19
17
  end
@@ -44,7 +42,7 @@ module Avm
44
42
  private
45
43
 
46
44
  def files_units
47
- FILES_UNITS.map do |data_key, fs_path_subpath|
45
+ self.class.const_get('FILES_UNITS').map do |data_key, fs_path_subpath|
48
46
  [data_key, ::Avm::Data::Instance::FilesUnit.new(self, fs_path_subpath)]
49
47
  end.to_h
50
48
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/numeric/time'
4
+ require 'eac_ruby_utils/console/speaker'
5
+ require 'eac_ruby_utils/simple_cache'
6
+ require 'avm/data/package/dump'
7
+
8
+ module Avm
9
+ module Stereotypes
10
+ module EacWebappBase0
11
+ module Runner
12
+ module Data
13
+ class Dump < ::EacRubyUtils::Console::DocoptRunner
14
+ include ::EacRubyUtils::SimpleCache
15
+ include ::EacRubyUtils::Console::Speaker
16
+
17
+ DUMP_EXPIRE_TIME = 1.days
18
+ DEFAULT_DUMP_PATH_ENTRY_SUFFIX = 'data.default_dump_path'
19
+ NO_DUMP_MESSAGE = 'Dump "%s" already exist and rewrite options was no setted nor ' \
20
+ 'dump was expired.'
21
+
22
+ DOC = <<~DOCUMENT
23
+ Dump utility for EacRailsBase instance.
24
+
25
+ Usage:
26
+ __PROGRAM__ [options]
27
+
28
+ Options:
29
+ -h --help Show this screen.
30
+ --rewrite Forces dump overwrite.
31
+ --dump-path=<dump_path> Set DUMP_PATH variable.
32
+ DOCUMENT
33
+
34
+ def run
35
+ infov 'Instance to dump', "#{context(:instance)} (#{context(:instance).class})"
36
+ if package_dump.runnable?
37
+ package_dump.run
38
+ else
39
+ warn(package_dump.cannot_run_reason)
40
+ end
41
+ success("Dump path: \"#{dump_path}\"")
42
+ dump_path
43
+ end
44
+
45
+ private
46
+
47
+ def package_dump_uncached
48
+ context(:instance).data_package.dump(dump_path, existing: package_dump_existing)
49
+ end
50
+
51
+ def dump_path
52
+ options.fetch('--dump-path') || default_dump_path
53
+ end
54
+
55
+ def default_dump_path
56
+ context(:instance).read_entry(DEFAULT_DUMP_PATH_ENTRY_SUFFIX)
57
+ end
58
+
59
+ def package_dump_existing
60
+ if options.fetch('--rewrite')
61
+ ::Avm::Data::Package::Dump::EXISTING_ROTATE
62
+ else
63
+ ::Avm::Data::Package::Dump::EXISTING_ROTATE_EXPIRED
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+
5
+ module Avm
6
+ module Stereotypes
7
+ module Rails
8
+ ::EacRubyUtils.require_sub(__FILE__)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Stereotypes
5
+ module Rails
6
+ module Instance
7
+ def bundle(*args)
8
+ host_env.command('bundle', *args)
9
+ .envvar('BUNDLE_GEMFILE', ::File.join(read_entry('fs_path'), 'Gemfile'))
10
+ .envvar('RAILS_ENV', 'production')
11
+ .chdir(read_entry('fs_path'))
12
+ end
13
+
14
+ def rake(*args)
15
+ bundle('exec', 'rake', *args)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_ruby_utils/require_sub'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
10
+ class Data < ::EacRubyUtils::Console::DocoptRunner
11
+ ::EacRubyUtils.require_sub(__FILE__)
12
+
13
+ DOC = <<~DOCOPT
14
+ Data utilities for EacRailsBase0 instances.
15
+
16
+ Usage:
17
+ __PROGRAM__ __SUBCOMMANDS__
18
+ __PROGRAM__ -h | --help
19
+
20
+ Options:
21
+ -h --help Show this screen.
22
+ DOCOPT
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'avm/stereotypes/eac_webapp_base0/runner/data/dump'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
10
+ class Data < ::EacRubyUtils::Console::DocoptRunner
11
+ class Dump < ::Avm::Stereotypes::EacWebappBase0::Runner::Data::Dump
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/stereotypes/eac_redmine_base0/deploy'
4
+ require 'avm/stereotypes/eac_webapp_base0/runner/deploy'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
10
+ class Bundle < ::EacRubyUtils::Console::DocoptRunner
11
+ enable_console_speaker
12
+
13
+ DOC = <<~DOCOPT
14
+ Runs "bundle ...".
15
+
16
+ Usage:
17
+ __PROGRAM__ [<bundle-args>...]
18
+ __PROGRAM__ -h | --help
19
+
20
+ Options:
21
+ -h --help Show this screen.
22
+ DOCOPT
23
+
24
+ def run
25
+ infov 'Bundle arguments', ::Shellwords.join(bundle_args)
26
+ context(:instance).bundle(*bundle_args).system!
27
+ end
28
+
29
+ def bundle_args
30
+ options.fetch('<bundle-args>').reject { |arg| arg == '--' }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,67 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/numeric/time'
4
- require 'eac_ruby_utils/console/speaker'
5
- require 'eac_ruby_utils/simple_cache'
6
- require 'avm/data/package/dump'
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'avm/stereotypes/eac_webapp_base0/runner/data/dump'
7
5
 
8
6
  module Avm
9
7
  module Tools
10
8
  class Runner < ::EacRubyUtils::Console::DocoptRunner
11
9
  class EacWordpressBase0 < ::EacRubyUtils::Console::DocoptRunner
12
10
  class Data < ::EacRubyUtils::Console::DocoptRunner
13
- class Dump < ::EacRubyUtils::Console::DocoptRunner
14
- include ::EacRubyUtils::SimpleCache
15
- include ::EacRubyUtils::Console::Speaker
16
-
17
- DUMP_EXPIRE_TIME = 1.days
18
- DEFAULT_DUMP_PATH_ENTRY_SUFFIX = 'data.default_dump_path'
19
- NO_DUMP_MESSAGE = 'Dump "%s" already exist and rewrite options was no setted nor ' \
20
- 'dump was expired.'
21
-
22
- DOC = <<~DOCUMENT
23
- Dump utility for EacRailsBase instance.
24
-
25
- Usage:
26
- __PROGRAM__ [options]
27
-
28
- Options:
29
- -h --help Show this screen.
30
- --rewrite Forces dump overwrite.
31
- --dump-path=<dump_path> Set DUMP_PATH variable.
32
- DOCUMENT
33
-
34
- def run
35
- if package_dump.runnable?
36
- package_dump.run
37
- else
38
- warn(package_dump.cannot_run_reason)
39
- end
40
- success("Dump path: \"#{dump_path}\"")
41
- dump_path
42
- end
43
-
44
- private
45
-
46
- def package_dump_uncached
47
- context(:instance).data_package.dump(dump_path, existing: package_dump_existing)
48
- end
49
-
50
- def dump_path
51
- options.fetch('--dump-path') || default_dump_path
52
- end
53
-
54
- def default_dump_path
55
- context(:instance).read_entry(DEFAULT_DUMP_PATH_ENTRY_SUFFIX)
56
- end
57
-
58
- def package_dump_existing
59
- if options.fetch('--rewrite')
60
- ::Avm::Data::Package::Dump::EXISTING_ROTATE
61
- else
62
- ::Avm::Data::Package::Dump::EXISTING_ROTATE_EXPIRED
63
- end
64
- end
11
+ class Dump < ::Avm::Stereotypes::EacWebappBase0::Runner::Data::Dump
65
12
  end
66
13
  end
67
14
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.28.0'
5
+ VERSION = '0.30.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.28.0
4
+ version: 0.30.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-01-23 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -210,6 +210,7 @@ files:
210
210
  - lib/avm/instances/base/auto_values.rb
211
211
  - lib/avm/instances/base/auto_values/access.rb
212
212
  - lib/avm/instances/base/auto_values/admin.rb
213
+ - lib/avm/instances/base/auto_values/data.rb
213
214
  - lib/avm/instances/base/auto_values/database.rb
214
215
  - lib/avm/instances/base/auto_values/filesystem.rb
215
216
  - lib/avm/instances/base/auto_values/ruby.rb
@@ -227,6 +228,7 @@ files:
227
228
  - lib/avm/self.rb
228
229
  - lib/avm/self/docker_image.rb
229
230
  - lib/avm/self/instance.rb
231
+ - lib/avm/self/instance/entry_keys.rb
230
232
  - lib/avm/stereotypes.rb
231
233
  - lib/avm/stereotypes/eac_rails_base0.rb
232
234
  - lib/avm/stereotypes/eac_rails_base0/apache_host.rb
@@ -245,6 +247,7 @@ files:
245
247
  - lib/avm/stereotypes/eac_webapp_base0/deploy/_appended_directories.rb
246
248
  - lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb
247
249
  - lib/avm/stereotypes/eac_webapp_base0/instance.rb
250
+ - lib/avm/stereotypes/eac_webapp_base0/runner/data/dump.rb
248
251
  - lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb
249
252
  - lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb
250
253
  - lib/avm/stereotypes/eac_wordpress_base0/deploy.rb
@@ -253,12 +256,17 @@ files:
253
256
  - lib/avm/stereotypes/postgresql/instance.rb
254
257
  - lib/avm/stereotypes/postgresql/instance/data_unit.rb
255
258
  - lib/avm/stereotypes/postgresql/instance_with.rb
259
+ - lib/avm/stereotypes/rails.rb
260
+ - lib/avm/stereotypes/rails/instance.rb
256
261
  - lib/avm/tools.rb
257
262
  - lib/avm/tools/runner.rb
258
263
  - lib/avm/tools/runner/eac_rails_base0.rb
259
264
  - lib/avm/tools/runner/eac_rails_base0/apache_host.rb
265
+ - lib/avm/tools/runner/eac_rails_base0/data.rb
266
+ - lib/avm/tools/runner/eac_rails_base0/data/dump.rb
260
267
  - lib/avm/tools/runner/eac_rails_base0/deploy.rb
261
268
  - lib/avm/tools/runner/eac_redmine_base0.rb
269
+ - lib/avm/tools/runner/eac_redmine_base0/bundle.rb
262
270
  - lib/avm/tools/runner/eac_redmine_base0/deploy.rb
263
271
  - lib/avm/tools/runner/eac_redmine_base0/docker.rb
264
272
  - lib/avm/tools/runner/eac_wordpress_base0.rb