avm-tools 0.118.0 → 0.120.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +3 -3
- data/lib/avm/tools/app_src.rb +1 -5
- data/lib/avm/tools/runner/app_src/ruby.rb +0 -1
- data/lib/avm/tools/runner/app_src.rb +2 -0
- data/lib/avm/tools/version.rb +1 -1
- data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/sources/base.rb +2 -2
- data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/base.rb +3 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/{avm-eac_rails_base1 → avm-eac_redmine_plugin_base0}/Gemfile +0 -0
- data/sub/avm-eac_redmine_plugin_base0/avm-eac_redmine_plugin_base0.gemspec +19 -0
- data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base.rb +30 -0
- data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/version.rb +7 -0
- data/sub/{avm-eac_ruby_base1/lib/avm/eac_ruby_base1.rb → avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0.rb} +1 -1
- data/sub/{avm-eac_rails_base1 → avm-eac_redmine_plugin_base0}/spec/rubocop_spec.rb +0 -0
- data/sub/{avm-eac_rails_base1 → avm-eac_redmine_plugin_base0}/spec/spec_helper.rb +0 -0
- metadata +27 -223
- data/lib/avm/patches/eac_ruby_gems_utils/gem.rb +0 -29
- data/lib/avm/patches/eac_ruby_gems_utils.rb +0 -4
- data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +0 -25
- data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +0 -39
- data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +0 -17
- data/lib/avm/ruby/bundler/incompatible_parser/line_buffer.rb +0 -73
- data/lib/avm/ruby/bundler/incompatible_parser/line_factory.rb +0 -31
- data/lib/avm/ruby/bundler/incompatible_parser/line_parser_base.rb +0 -19
- data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +0 -26
- data/lib/avm/ruby/bundler/incompatible_parser.rb +0 -25
- data/lib/avm/tools/runner/app_src/ruby/bundler/incompatible.rb +0 -82
- data/sub/avm/Gemfile +0 -5
- data/sub/avm/avm.gemspec +0 -26
- data/sub/avm/lib/avm/data/instance/files_unit.rb +0 -40
- data/sub/avm/lib/avm/data/instance/package.rb +0 -18
- data/sub/avm/lib/avm/data/instance/unit.rb +0 -17
- data/sub/avm/lib/avm/data/instance.rb +0 -11
- data/sub/avm/lib/avm/data/package/dump.rb +0 -119
- data/sub/avm/lib/avm/data/package/load.rb +0 -48
- data/sub/avm/lib/avm/data/package.rb +0 -42
- data/sub/avm/lib/avm/data/rotate.rb +0 -107
- data/sub/avm/lib/avm/data/unit.rb +0 -94
- data/sub/avm/lib/avm/docker/container.rb +0 -50
- data/sub/avm/lib/avm/docker/image.rb +0 -71
- data/sub/avm/lib/avm/docker/runner.rb +0 -125
- data/sub/avm/lib/avm/docker.rb +0 -9
- data/sub/avm/lib/avm/executables.rb +0 -24
- data/sub/avm/lib/avm/instances/application.rb +0 -29
- data/sub/avm/lib/avm/instances/base/auto_values/access.rb +0 -40
- data/sub/avm/lib/avm/instances/base/auto_values/admin.rb +0 -19
- data/sub/avm/lib/avm/instances/base/auto_values/data.rb +0 -26
- data/sub/avm/lib/avm/instances/base/auto_values/database.rb +0 -76
- data/sub/avm/lib/avm/instances/base/auto_values/filesystem.rb +0 -43
- data/sub/avm/lib/avm/instances/base/auto_values/mailer.rb +0 -34
- data/sub/avm/lib/avm/instances/base/auto_values/ruby.rb +0 -15
- data/sub/avm/lib/avm/instances/base/auto_values/source.rb +0 -15
- data/sub/avm/lib/avm/instances/base/auto_values/system.rb +0 -23
- data/sub/avm/lib/avm/instances/base/auto_values/web.rb +0 -46
- data/sub/avm/lib/avm/instances/base/auto_values.rb +0 -21
- data/sub/avm/lib/avm/instances/base/dockerizable.rb +0 -45
- data/sub/avm/lib/avm/instances/base/entry_keys.rb +0 -22
- data/sub/avm/lib/avm/instances/base.rb +0 -64
- data/sub/avm/lib/avm/instances/docker_image.rb +0 -15
- data/sub/avm/lib/avm/instances/entries.rb +0 -43
- data/sub/avm/lib/avm/instances/entry.rb +0 -60
- data/sub/avm/lib/avm/instances/entry_keys.rb +0 -60
- data/sub/avm/lib/avm/instances/runner.rb +0 -39
- data/sub/avm/lib/avm/instances.rb +0 -8
- data/sub/avm/lib/avm/jobs/base.rb +0 -63
- data/sub/avm/lib/avm/jobs/variables_source.rb +0 -22
- data/sub/avm/lib/avm/jobs.rb +0 -9
- data/sub/avm/lib/avm/launcher/errors/base.rb +0 -10
- data/sub/avm/lib/avm/launcher/errors/non_project.rb +0 -15
- data/sub/avm/lib/avm/launcher/paths/real.rb +0 -44
- data/sub/avm/lib/avm/launcher/publish/check_result.rb +0 -67
- data/sub/avm/lib/avm/path_string.rb +0 -27
- data/sub/avm/lib/avm/registry/base.rb +0 -67
- data/sub/avm/lib/avm/registry.rb +0 -29
- data/sub/avm/lib/avm/result.rb +0 -86
- data/sub/avm/lib/avm/rspec/setup.rb +0 -22
- data/sub/avm/lib/avm/rspec/shared_examples/in_avm_registry.rb +0 -11
- data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +0 -14
- data/sub/avm/lib/avm/rspec.rb +0 -9
- data/sub/avm/lib/avm/runners/base.rb +0 -27
- data/sub/avm/lib/avm/scms/base.rb +0 -46
- data/sub/avm/lib/avm/scms/commit.rb +0 -43
- data/sub/avm/lib/avm/scms/inflector.rb +0 -22
- data/sub/avm/lib/avm/self/docker_image.rb +0 -14
- data/sub/avm/lib/avm/self/instance/entry_keys.rb +0 -12
- data/sub/avm/lib/avm/self/instance.rb +0 -31
- data/sub/avm/lib/avm/sources/base/configuration.rb +0 -45
- data/sub/avm/lib/avm/sources/base/instance.rb +0 -28
- data/sub/avm/lib/avm/sources/base/parent.rb +0 -31
- data/sub/avm/lib/avm/sources/base/subs.rb +0 -55
- data/sub/avm/lib/avm/sources/base/subs_paths.rb +0 -32
- data/sub/avm/lib/avm/sources/base/testing.rb +0 -21
- data/sub/avm/lib/avm/sources/base.rb +0 -44
- data/sub/avm/lib/avm/sources/configuration/locale.rb +0 -18
- data/sub/avm/lib/avm/sources/configuration/rubocop.rb +0 -26
- data/sub/avm/lib/avm/sources/configuration/tests.rb +0 -29
- data/sub/avm/lib/avm/sources/configuration.rb +0 -59
- data/sub/avm/lib/avm/sources/tester.rb +0 -24
- data/sub/avm/lib/avm/sources/tests/builder.rb +0 -83
- data/sub/avm/lib/avm/sources/tests/performer.rb +0 -35
- data/sub/avm/lib/avm/sources/tests/result.rb +0 -15
- data/sub/avm/lib/avm/sources/tests/single.rb +0 -56
- data/sub/avm/lib/avm/sources/tests.rb +0 -11
- data/sub/avm/lib/avm/sources.rb +0 -9
- data/sub/avm/lib/avm/sync.rb +0 -94
- data/sub/avm/lib/avm/version.rb +0 -5
- data/sub/avm/lib/avm/version_number.rb +0 -45
- data/sub/avm/lib/avm.rb +0 -7
- data/sub/avm/spec/lib/avm/scms/base_spec.rb +0 -7
- data/sub/avm/spec/lib/avm/sources/base_spec.rb +0 -7
- data/sub/avm/spec/rubocop_spec.rb +0 -3
- data/sub/avm/spec/spec_helper.rb +0 -4
- data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +0 -21
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/apache_host.rb +0 -17
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instance.rb +0 -24
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/bundle.rb +0 -26
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/code_runner.rb +0 -26
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/log.rb +0 -43
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/logs/clear.rb +0 -26
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/logs.rb +0 -18
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/rails_server.rb +0 -32
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler/systemd_unit.rb +0 -46
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler.rb +0 -17
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner.rb +0 -12
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/bundle.rb +0 -27
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/rails_environment.rb +0 -47
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/sources/base.rb +0 -27
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/service.rb +0 -70
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.rb +0 -29
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit.rb +0 -57
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +0 -7
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1.rb +0 -9
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler.service +0 -12
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +0 -6
- data/sub/avm-eac_ruby_base1/Gemfile +0 -5
- data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +0 -21
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb +0 -56
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb +0 -19
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile.rb +0 -34
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler.rb +0 -11
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb +0 -31
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb +0 -17
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/gemfile.rb +0 -41
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop.rb +0 -55
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/version_bump.rb +0 -23
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +0 -50
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +0 -38
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update/sub_update.rb +0 -56
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update.rb +0 -52
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources.rb +0 -11
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +0 -7
- data/sub/avm-eac_ruby_base1/locale/en.yaml +0 -8
- data/sub/avm-eac_ruby_base1/locale/pt-BR.yaml +0 -8
- data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/sources/base_spec.rb +0 -7
- data/sub/avm-eac_ruby_base1/spec/rubocop_spec.rb +0 -3
- data/sub/avm-eac_ruby_base1/spec/spec_helper.rb +0 -4
- data/sub/eac_ruby_base0/Gemfile +0 -5
- data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +0 -21
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/application.rb +0 -87
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/application_xdg.rb +0 -34
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +0 -5
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +0 -31
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +0 -10
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +0 -4
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +0 -5
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +0 -5
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +0 -4
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/rspec/setup.rb +0 -14
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/rspec.rb +0 -9
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +0 -92
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +0 -42
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +0 -52
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/input.rb +0 -36
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +0 -58
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +0 -9
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +0 -5
- data/sub/eac_ruby_base0/lib/eac_ruby_base0.rb +0 -7
- data/sub/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb +0 -42
- data/sub/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +0 -81
- data/sub/eac_ruby_base0/spec/rubocop_spec.rb +0 -3
- data/sub/eac_ruby_base0/spec/spec_helper.rb +0 -4
- data/sub/eac_ruby_gems_utils/Gemfile +0 -5
- data/sub/eac_ruby_gems_utils/LICENCE +0 -16
- data/sub/eac_ruby_gems_utils/README.rdoc +0 -3
- data/sub/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +0 -31
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb +0 -33
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +0 -41
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +0 -97
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +0 -57
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/minitest.rb +0 -25
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +0 -48
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +0 -25
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +0 -84
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/rspec.rb +0 -21
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests.rb +0 -9
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +0 -5
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils.rb +0 -7
- data/sub/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +0 -3
- data/sub/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +0 -14
- data/sub/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +0 -7
- data/sub/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem_spec.rb +0 -20
- data/sub/eac_ruby_gems_utils/spec/spec_helper.rb +0 -4
- data/sub/eac_ruby_gems_utils/spec/support/mygem/Gemfile +0 -5
- data/sub/eac_ruby_gems_utils/spec/support/mygem/Gemfile.lock +0 -19
- data/sub/eac_ruby_gems_utils/spec/support/mygem/Rakefile +0 -14
- data/sub/eac_ruby_gems_utils/spec/support/mygem/exe/myrunner +0 -5
- data/sub/eac_ruby_gems_utils/spec/support/mygem/lib/mygem/version.rb +0 -5
- data/sub/eac_ruby_gems_utils/spec/support/mygem/lib/mygem.rb +0 -5
- data/sub/eac_ruby_gems_utils/spec/support/mygem/mygem.gemspec +0 -16
@@ -1,107 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/object/blank'
|
4
|
-
require 'eac_ruby_utils/simple_cache'
|
5
|
-
|
6
|
-
module Avm
|
7
|
-
module Data
|
8
|
-
class Rotate
|
9
|
-
include ::EacRubyUtils::SimpleCache
|
10
|
-
|
11
|
-
attr_reader :options, :source_path
|
12
|
-
|
13
|
-
def initialize(source_path, options = {})
|
14
|
-
@source_path = source_path
|
15
|
-
@options = options
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
validate_msg = validate
|
20
|
-
return validate_msg if validate_msg.present?
|
21
|
-
|
22
|
-
::FileUtils.mv(source_path, target_path)
|
23
|
-
check_space_limit
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def space_limit
|
28
|
-
r = options[:space_limit].try(:to_i)
|
29
|
-
return r if r.present? && r.positive?
|
30
|
-
|
31
|
-
r
|
32
|
-
end
|
33
|
-
|
34
|
-
def space_used
|
35
|
-
rotated_files.inject(0) { |a, e| a + ::File.size(e) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def rotated_files
|
39
|
-
::Dir["#{dirname}/#{source_basename_without_extension}*#{source_extension}"]
|
40
|
-
end
|
41
|
-
|
42
|
-
def oldest_rotated_file
|
43
|
-
rotated_files.min_by { |file| [::File.mtime(file)] }
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def check_space_limit
|
49
|
-
return unless space_limit
|
50
|
-
|
51
|
-
while space_used > space_limit
|
52
|
-
file = oldest_rotated_file
|
53
|
-
unless file
|
54
|
-
raise 'oldest_rotated_file returned nil ' \
|
55
|
-
"(Limit: #{space_limit}, used: #{space_used})"
|
56
|
-
end
|
57
|
-
::File.delete(file)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def validate
|
62
|
-
return "Source file \"#{source_path}\" does not exist" unless ::File.exist?(source_path)
|
63
|
-
return "File \"#{source_path}\" is already rotated" if source_rotated?
|
64
|
-
|
65
|
-
nil
|
66
|
-
end
|
67
|
-
|
68
|
-
def source_rotated?
|
69
|
-
source_basename_without_extension.match(/[PN]\d{4}\z/)
|
70
|
-
end
|
71
|
-
|
72
|
-
def source_extension_uncached
|
73
|
-
file_extension(::File.basename(source_path))
|
74
|
-
end
|
75
|
-
|
76
|
-
def source_basename_without_extension
|
77
|
-
::File.basename(source_path, source_extension)
|
78
|
-
end
|
79
|
-
|
80
|
-
def target_path_uncached
|
81
|
-
::File.join(dirname, target_basename)
|
82
|
-
end
|
83
|
-
|
84
|
-
def dirname
|
85
|
-
::File.dirname(source_path)
|
86
|
-
end
|
87
|
-
|
88
|
-
def target_basename
|
89
|
-
source_basename_without_extension + target_suffix + source_extension
|
90
|
-
end
|
91
|
-
|
92
|
-
def target_suffix
|
93
|
-
return '_UNKNOWN_MTIME' unless ::File.exist?(source_path)
|
94
|
-
|
95
|
-
t = ::File.mtime(source_path)
|
96
|
-
t.strftime('_%Y-%m-%d_%H-%M-%S_') + t.strftime('%z').gsub(/\A\+/, 'P').gsub(/\A\-/, 'N')
|
97
|
-
end
|
98
|
-
|
99
|
-
def file_extension(basename)
|
100
|
-
extension = ::File.extname(basename)
|
101
|
-
return '' if extension.blank?
|
102
|
-
|
103
|
-
file_extension(::File.basename(basename, extension)) + extension
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'active_support/callbacks'
|
5
|
-
|
6
|
-
module Avm
|
7
|
-
module Data
|
8
|
-
class Unit
|
9
|
-
include ::ActiveSupport::Callbacks
|
10
|
-
|
11
|
-
define_callbacks :dump, :load
|
12
|
-
enable_speaker
|
13
|
-
|
14
|
-
%w[dump load].each do |action|
|
15
|
-
method_name = "#{action}_command"
|
16
|
-
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
17
|
-
# Should be overrided.
|
18
|
-
# @return [EacRubyUtils::Envs::Command]
|
19
|
-
def #{method_name}
|
20
|
-
fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
|
21
|
-
end
|
22
|
-
CODE
|
23
|
-
|
24
|
-
# Callbacks
|
25
|
-
%w[before after].each do |callback|
|
26
|
-
method = "#{callback}_#{action}"
|
27
|
-
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
28
|
-
def self.#{method}(callback_method = nil, &block)
|
29
|
-
if callback_method
|
30
|
-
set_callback :#{action}, :#{callback}, callback_method
|
31
|
-
else
|
32
|
-
set_callback :#{action}, :#{callback}, &block
|
33
|
-
end
|
34
|
-
self
|
35
|
-
end
|
36
|
-
|
37
|
-
def #{method}(callback_method = nil, &block)
|
38
|
-
singleton_class.#{method}(callback_method, &block)
|
39
|
-
self
|
40
|
-
end
|
41
|
-
CODE
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def extension
|
46
|
-
singleton_class.const_get('EXTENSION')
|
47
|
-
rescue NameError
|
48
|
-
''
|
49
|
-
end
|
50
|
-
|
51
|
-
def name
|
52
|
-
self.class
|
53
|
-
end
|
54
|
-
|
55
|
-
def load_from_directory(directory, identifier)
|
56
|
-
load(unit_on_directory_path(directory, identifier))
|
57
|
-
end
|
58
|
-
|
59
|
-
def dump_to_directory(directory, identifier)
|
60
|
-
dump(unit_on_directory_path(directory, identifier))
|
61
|
-
end
|
62
|
-
|
63
|
-
def dump(data_path)
|
64
|
-
run_callbacks :dump do
|
65
|
-
infom "Dumping unit \"#{name}\" to \"#{data_path}\"..."
|
66
|
-
do_dump(data_path)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def load(data_path)
|
71
|
-
run_callbacks :load do
|
72
|
-
infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
|
73
|
-
do_load(data_path)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
protected
|
78
|
-
|
79
|
-
def do_dump(data_path)
|
80
|
-
dump_command.execute!(output_file: data_path)
|
81
|
-
end
|
82
|
-
|
83
|
-
def do_load(data_path)
|
84
|
-
load_command.execute!(input_file: data_path)
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def unit_on_directory_path(directory, identifier)
|
90
|
-
::File.join(directory, "#{identifier}#{extension}")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_docker/executables'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module Avm
|
7
|
-
module Docker
|
8
|
-
class Container
|
9
|
-
enable_speaker
|
10
|
-
common_constructor :instance
|
11
|
-
|
12
|
-
def remove
|
13
|
-
::EacDocker::Executables.docker.command.append(
|
14
|
-
['rm', '--force', instance.docker_container_name]
|
15
|
-
).system!
|
16
|
-
end
|
17
|
-
|
18
|
-
def run(options = {})
|
19
|
-
infov 'Container name', instance.docker_container_name
|
20
|
-
infov 'Container exist?', instance.docker_container_exist?
|
21
|
-
remove if options[:clear] && instance.docker_container_exist?
|
22
|
-
if instance.docker_container_exist?
|
23
|
-
run_start
|
24
|
-
else
|
25
|
-
run_run(options)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def run_run(options)
|
30
|
-
infom "\"docker run #{instance.docker_container_name}...\""
|
31
|
-
::EacDocker::Executables.docker.command.append(run_run_arguments(options)).system!
|
32
|
-
end
|
33
|
-
|
34
|
-
def run_start
|
35
|
-
infom "\"docker start #{instance.docker_container_name}...\""
|
36
|
-
::EacDocker::Executables.docker.command.append(run_start_arguments).system!
|
37
|
-
end
|
38
|
-
|
39
|
-
def run_run_arguments(options)
|
40
|
-
entrypoint_args = options[:entrypoint_args].if_present([])
|
41
|
-
['run', '-it', '--name', instance.docker_container_name] + instance.docker_run_arguments +
|
42
|
-
[instance.docker_image.tag] + entrypoint_args
|
43
|
-
end
|
44
|
-
|
45
|
-
def run_start_arguments
|
46
|
-
['start', '-ai', instance.docker_container_name]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/version'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
require 'eac_docker/images/templatized'
|
6
|
-
|
7
|
-
module Avm
|
8
|
-
module Docker
|
9
|
-
class Image < ::EacDocker::Images::Templatized
|
10
|
-
attr_reader :registry
|
11
|
-
attr_accessor :snapshot
|
12
|
-
attr_accessor :version
|
13
|
-
|
14
|
-
def initialize(registry)
|
15
|
-
@registry = registry
|
16
|
-
self.snapshot = true
|
17
|
-
self.version = true
|
18
|
-
end
|
19
|
-
|
20
|
-
def build(extra_args = [])
|
21
|
-
nyi "Extra args: #{extra_args}" if extra_args.any?
|
22
|
-
|
23
|
-
provide
|
24
|
-
end
|
25
|
-
|
26
|
-
def generator_version
|
27
|
-
::Avm::VERSION
|
28
|
-
end
|
29
|
-
|
30
|
-
def push
|
31
|
-
::EacDocker::Executables.docker.command.append(['push', tag]).system!
|
32
|
-
end
|
33
|
-
|
34
|
-
def read_entry(path, options = {})
|
35
|
-
method = path.gsub('.', '_')
|
36
|
-
return send(method) if respond_to?(path, true)
|
37
|
-
return instance.read_entry(path, options) if respond_to?(:instance)
|
38
|
-
|
39
|
-
raise "Method \"#{method}\" not found for entry \"#{path}\""
|
40
|
-
end
|
41
|
-
|
42
|
-
def run(instance)
|
43
|
-
run_run(instance) if container_exist?(instance)
|
44
|
-
end
|
45
|
-
|
46
|
-
def tag
|
47
|
-
r = tag_name
|
48
|
-
r += ":#{tag_version}" if tag_version.present?
|
49
|
-
r
|
50
|
-
end
|
51
|
-
|
52
|
-
def tag_name
|
53
|
-
return registry.name if registry.name.present?
|
54
|
-
|
55
|
-
raise 'Registry name is blank'
|
56
|
-
end
|
57
|
-
|
58
|
-
def tag_version
|
59
|
-
[tag_version_version, stereotype_tag].reject(&:blank?).join('_')
|
60
|
-
end
|
61
|
-
|
62
|
-
def tag_version_version
|
63
|
-
return nil unless version
|
64
|
-
|
65
|
-
r = generator_version
|
66
|
-
r += '-snapshot' if snapshot
|
67
|
-
r
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_docker/registry'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module Avm
|
7
|
-
module Docker
|
8
|
-
class Runner
|
9
|
-
DOCKER_DEFAULT_REGISTRY_METHOD = :docker_default_registry
|
10
|
-
|
11
|
-
enable_speaker
|
12
|
-
enable_simple_cache
|
13
|
-
|
14
|
-
runner_with :help do
|
15
|
-
desc 'Manipulate Docker images.'
|
16
|
-
bool_opt '-I', '--image-name', 'Output image name.'
|
17
|
-
arg_opt '-n', '--registry-name', 'Docker registry\'s name.'
|
18
|
-
bool_opt '-p', '--push', 'Push the image to Docker registry.'
|
19
|
-
bool_opt '-r', '--run', 'Run or start a container with builded image.'
|
20
|
-
arg_opt '-B', '--build-arg', 'Argument for "docker build".', repeat: true
|
21
|
-
arg_opt '-E', '--entrypoint-arg', 'Argument for entrypoint on "docker run"', repeat: true
|
22
|
-
bool_opt '-c', '--clear', 'Remove container if exist before run.'
|
23
|
-
bool_opt '-S', '--no-snapshot', 'Does not add "-snapshot" to image tag.'
|
24
|
-
bool_opt '-V', '--no-version', 'Does not add version to image tag.'
|
25
|
-
end
|
26
|
-
|
27
|
-
def run
|
28
|
-
setup
|
29
|
-
banner
|
30
|
-
build
|
31
|
-
output_image_name
|
32
|
-
push
|
33
|
-
container_run
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def setup
|
39
|
-
instance.docker_image_options = {
|
40
|
-
registry: registry,
|
41
|
-
snapshot: snapshot?,
|
42
|
-
version: version?
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
def banner
|
47
|
-
infov 'Registry name', registry
|
48
|
-
infov 'Version?', version?
|
49
|
-
infov 'Snapshot?', snapshot?
|
50
|
-
infov 'Image name', docker_image.tag
|
51
|
-
infov 'Build arguments', build_args
|
52
|
-
infov 'Entrypoint arguments', entrypoint_args
|
53
|
-
end
|
54
|
-
|
55
|
-
def build
|
56
|
-
docker_image.build(build_args)
|
57
|
-
success 'Docker image builded'
|
58
|
-
end
|
59
|
-
|
60
|
-
def build_args
|
61
|
-
parsed.build_arg
|
62
|
-
end
|
63
|
-
|
64
|
-
def docker_container
|
65
|
-
instance.docker_container
|
66
|
-
end
|
67
|
-
|
68
|
-
def docker_image
|
69
|
-
instance.docker_image
|
70
|
-
end
|
71
|
-
|
72
|
-
def entrypoint_args
|
73
|
-
parsed.entrypoint_arg
|
74
|
-
end
|
75
|
-
|
76
|
-
def push
|
77
|
-
docker_image.push if parsed.push?
|
78
|
-
end
|
79
|
-
|
80
|
-
def container_run
|
81
|
-
return unless parsed.run?
|
82
|
-
|
83
|
-
docker_container.run(
|
84
|
-
entrypoint_args: entrypoint_args,
|
85
|
-
clear: parsed.clear?
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
|
-
def output_image_name
|
90
|
-
return unless parsed.image_name
|
91
|
-
|
92
|
-
out(docker_image.tag.to_s.strip + "\n")
|
93
|
-
end
|
94
|
-
|
95
|
-
def registry_uncached
|
96
|
-
registry_from_option || registry_from_instance || registry_from_default ||
|
97
|
-
fatal_error('No registry defined')
|
98
|
-
end
|
99
|
-
|
100
|
-
def registry_from_option
|
101
|
-
parsed.registry_name.if_present { |v| ::EacDocker::Registry.new(v) }
|
102
|
-
end
|
103
|
-
|
104
|
-
def registry_from_instance
|
105
|
-
instance.docker_registry_optional.if_present { |v| ::EacDocker::Registry.new(v) }
|
106
|
-
end
|
107
|
-
|
108
|
-
def registry_from_default
|
109
|
-
if_respond(DOCKER_DEFAULT_REGISTRY_METHOD, nil)
|
110
|
-
end
|
111
|
-
|
112
|
-
def snapshot?
|
113
|
-
!parsed.no_snapshot?
|
114
|
-
end
|
115
|
-
|
116
|
-
def version?
|
117
|
-
!parsed.no_version?
|
118
|
-
end
|
119
|
-
|
120
|
-
def instance
|
121
|
-
runner_context.call(:instance)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
data/sub/avm/lib/avm/docker.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/envs'
|
4
|
-
require 'eac_ruby_utils/simple_cache'
|
5
|
-
|
6
|
-
module Avm
|
7
|
-
module Executables
|
8
|
-
class << self
|
9
|
-
include ::EacRubyUtils::SimpleCache
|
10
|
-
|
11
|
-
def env
|
12
|
-
::EacRubyUtils::Envs.local
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
%w[file git js-beautify latex php-cs-fixer tidy yapf xdg-open].each do |program|
|
18
|
-
define_method(program.underscore + '_uncached') do
|
19
|
-
env.executable(program, '--version')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/instances/entries'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Instances
|
7
|
-
class Application
|
8
|
-
include ::Avm::Instances::Entries
|
9
|
-
|
10
|
-
attr_reader :id
|
11
|
-
|
12
|
-
def initialize(id)
|
13
|
-
@id = id.to_s
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_s
|
17
|
-
id
|
18
|
-
end
|
19
|
-
|
20
|
-
def instance(suffix)
|
21
|
-
::Avm::Instances::Base.new(self, suffix)
|
22
|
-
end
|
23
|
-
|
24
|
-
def name
|
25
|
-
entry(::Avm::Instances::EntryKeys::NAME).read
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Avm
|
4
|
-
module Instances
|
5
|
-
class Base
|
6
|
-
module AutoValues
|
7
|
-
module Access
|
8
|
-
def auto_access
|
9
|
-
read_entry_optional('ssh.url').present? ? 'ssh' : 'local'
|
10
|
-
end
|
11
|
-
|
12
|
-
def auto_ssh_hostname
|
13
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.hostname')
|
14
|
-
end
|
15
|
-
|
16
|
-
def auto_ssh_port
|
17
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.port') || 22
|
18
|
-
end
|
19
|
-
|
20
|
-
def auto_ssh_username
|
21
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.username')
|
22
|
-
end
|
23
|
-
|
24
|
-
def auto_ssh_url
|
25
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.url') ||
|
26
|
-
auto_ssh_url_by_parts
|
27
|
-
end
|
28
|
-
|
29
|
-
def auto_ssh_url_by_parts
|
30
|
-
read_entry_optional('ssh.hostname').if_present do |a|
|
31
|
-
a = read_entry_optional('ssh.username').if_present(a) { |v| "#{v}@#{a}" }
|
32
|
-
a = read_entry_optional('ssh.port').if_present(a) { |v| "#{a}:#{v}" }
|
33
|
-
"ssh://#{a}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Avm
|
4
|
-
module Instances
|
5
|
-
class Base
|
6
|
-
module AutoValues
|
7
|
-
module Admin
|
8
|
-
def auto_admin_email
|
9
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'admin.email')
|
10
|
-
end
|
11
|
-
|
12
|
-
def auto_admin_name
|
13
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'admin.name')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,26 +0,0 @@
|
|
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::Instance
|
13
|
-
.default
|
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
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'avm/instances/entry_keys'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Instances
|
7
|
-
class Base
|
8
|
-
module AutoValues
|
9
|
-
module Database
|
10
|
-
DEFAULT_EXTRA = ''
|
11
|
-
DEFAULT_HOSTNAME = '127.0.0.1'
|
12
|
-
DEFAULT_LIMIT = 5
|
13
|
-
DEFAULT_PORTS = {
|
14
|
-
'postgresql' => 5432,
|
15
|
-
'mysql' => 3306,
|
16
|
-
'oracle' => 1521,
|
17
|
-
'sqlserver' => 1433
|
18
|
-
}.freeze
|
19
|
-
DEFAULT_SYSTEM = 'postgresql'
|
20
|
-
DEFAULT_TIMEOUT = 5000
|
21
|
-
|
22
|
-
def auto_database_extra
|
23
|
-
database_auto_common('hostname') || DEFAULT_EXTRA
|
24
|
-
end
|
25
|
-
|
26
|
-
def auto_database_name
|
27
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::DATABASE_ID,
|
28
|
-
::Avm::Instances::EntryKeys::DATABASE_NAME) || id
|
29
|
-
end
|
30
|
-
|
31
|
-
def auto_database_hostname
|
32
|
-
database_auto_common('hostname') || DEFAULT_HOSTNAME
|
33
|
-
end
|
34
|
-
|
35
|
-
def auto_database_limit
|
36
|
-
database_auto_common('limit') || DEFAULT_LIMIT
|
37
|
-
end
|
38
|
-
|
39
|
-
def auto_database_password
|
40
|
-
database_auto_common('password') || id
|
41
|
-
end
|
42
|
-
|
43
|
-
def auto_database_port
|
44
|
-
database_auto_common('port') || database_port_by_system
|
45
|
-
end
|
46
|
-
|
47
|
-
def auto_database_username
|
48
|
-
database_auto_common('username') || id
|
49
|
-
end
|
50
|
-
|
51
|
-
def auto_database_system
|
52
|
-
database_auto_common('system') || DEFAULT_SYSTEM
|
53
|
-
end
|
54
|
-
|
55
|
-
def auto_database_timeout
|
56
|
-
database_auto_common('timeout') || DEFAULT_TIMEOUT
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def database_auto_common(suffix)
|
62
|
-
database_key = ::Avm::Instances::EntryKeys.const_get("database_#{suffix}".upcase)
|
63
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::DATABASE_ID, database_key) ||
|
64
|
-
inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, database_key)
|
65
|
-
end
|
66
|
-
|
67
|
-
def database_port_by_system
|
68
|
-
read_entry_optional(::Avm::Instances::EntryKeys::DATABASE_SYSTEM).if_present do |v|
|
69
|
-
DEFAULT_PORTS.fetch(v)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|