avm-tools 0.59.0 → 0.62.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/cached_download.rb +39 -0
- data/lib/avm/eac_redmine_base0/core_update.rb +110 -0
- data/lib/avm/eac_redmine_base0/data_unit.rb +27 -0
- data/lib/avm/eac_redmine_base0/deploy.rb +36 -0
- data/lib/avm/eac_redmine_base0/instance.rb +38 -0
- data/lib/avm/launcher/context/instance_manager.rb +76 -0
- data/lib/avm/launcher/context/instance_manager/cached_instance.rb +37 -0
- data/lib/avm/launcher/context/instance_manager/cached_instances.rb +35 -0
- data/lib/avm/launcher/errors/base.rb +10 -0
- data/lib/avm/launcher/errors/non_project.rb +15 -0
- data/lib/avm/launcher/instances/base.rb +94 -0
- data/lib/avm/launcher/instances/base/cache.rb +43 -0
- data/lib/avm/local_projects/instance.rb +8 -1
- data/lib/avm/local_projects/jobs/update.rb +29 -0
- data/lib/avm/projects/stereotype.rb +17 -10
- data/lib/avm/projects/stereotypes/git/local_project_mixin.rb +19 -0
- data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +5 -4
- data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +19 -0
- data/lib/avm/projects/stereotypes/ruby_gem/update.rb +59 -0
- data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +3 -1
- data/lib/avm/sync.rb +94 -0
- data/lib/avm/tools/runner/eac_redmine_base0.rb +2 -2
- data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +67 -0
- data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +1 -1
- data/lib/avm/tools/runner/git/issue.rb +43 -4
- data/lib/avm/tools/runner/local_project.rb +1 -1
- data/lib/avm/tools/runner/local_project/update.rb +26 -0
- data/lib/avm/tools/version.rb +1 -1
- data/lib/eac_launcher/context.rb +2 -2
- data/lib/eac_launcher/context/instance_discovery.rb +2 -2
- data/lib/eac_launcher/git/base/dirty_files.rb +5 -14
- data/lib/eac_launcher/git/sub_warp_base.rb +3 -2
- data/lib/eac_launcher/instances.rb +2 -2
- data/lib/eac_launcher/instances/error.rb +7 -3
- data/lib/eac_launcher/paths/logical.rb +2 -2
- data/lib/eac_launcher/publish/base.rb +2 -2
- data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/install.sh.template +0 -0
- data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/secrets.yml +0 -0
- data/vendor/eac_git/lib/eac_git/local.rb +1 -1
- data/vendor/eac_git/lib/eac_git/local/dirty_files.rb +38 -0
- data/vendor/eac_git/lib/eac_git/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +2 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +2 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +2 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +5 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +8 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- metadata +25 -11
- data/lib/avm/stereotypes/eac_redmine_base0/data_unit.rb +0 -29
- data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +0 -38
- data/lib/avm/stereotypes/eac_redmine_base0/instance.rb +0 -40
- data/lib/eac_launcher/context/instance_manager.rb +0 -94
- data/lib/eac_launcher/instances/base.rb +0 -91
- data/lib/eac_launcher/instances/base/cache.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 023b291269b46cb2a272642eac7febb8cbecd15429aeae61435260d0977c0958
|
4
|
+
data.tar.gz: 4ff8f6c8c50ad54a5f7b84be35780e7a221608c7e955a0cb2e241b6f31aa88e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df68926e69e0e8912f73e452fd50b218909620040eb2a69a0695ddce9542f8616e881cd455248df8a9cb89028f6ad9ff9d66aa204c7c79ba0559d317779c2e56
|
7
|
+
data.tar.gz: 155dbcdd721e28b5d4cd021ddb25f35daf4b4f26c2b530cb5ba21377c72ee7a0329a5149831a6031d0c7cfd12e777254b251954774ea7eb9e317b7d57f034f10
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/fs_cache'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
class CachedDownload
|
8
|
+
attr_reader :url, :fs_cache
|
9
|
+
|
10
|
+
def initialize(url, parent_fs_cache = nil)
|
11
|
+
@url = url
|
12
|
+
@fs_cache = (parent_fs_cache || ::Avm.fs_cache).child(url.parameterize)
|
13
|
+
end
|
14
|
+
|
15
|
+
def assert
|
16
|
+
download unless fs_cache.cached?
|
17
|
+
end
|
18
|
+
|
19
|
+
def download
|
20
|
+
::EacRubyUtils::Fs::Temp.on_file do |temp|
|
21
|
+
download_to(temp)
|
22
|
+
fs_cache.content_path.to_pathname.dirname.mkpath
|
23
|
+
::FileUtils.mv(temp.to_path, fs_cache.content_path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def path
|
28
|
+
@path ||= fs_cache.content_path.to_pathname
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def download_to(local_file)
|
34
|
+
::URI.parse(url).open do |remote|
|
35
|
+
local_file.open('wb') { |handle| handle.write(remote.read) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_redmine_base0/core_update'
|
4
|
+
require 'avm/cached_download'
|
5
|
+
require 'avm/sync'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module EacRedmineBase0
|
10
|
+
class CoreUpdate
|
11
|
+
enable_console_speaker
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :instance, :version, :url
|
14
|
+
|
15
|
+
GITIGNORE_ADD = %w[/public/assets/**/* /config/install.sh /log/**/*].freeze
|
16
|
+
GITIGNORE_DEL = %w[/Gemfile.lock /plugins/* /public/themes/*].freeze
|
17
|
+
TARGET_KEEP = %w[/Gemfile.lock].freeze
|
18
|
+
|
19
|
+
def run
|
20
|
+
::EacRubyUtils::Fs::Temp.on_directory do |dir|
|
21
|
+
@tempdir = dir
|
22
|
+
assert_source_package
|
23
|
+
extract_package_to_tempdir
|
24
|
+
sync_content
|
25
|
+
change_git_ignore
|
26
|
+
validate_empty_dir
|
27
|
+
end
|
28
|
+
git_commit
|
29
|
+
success 'Done!'
|
30
|
+
end
|
31
|
+
|
32
|
+
def assert_source_package
|
33
|
+
infom 'Asserting source package...'
|
34
|
+
source_package.assert
|
35
|
+
infov 'Package cache path', source_package.path
|
36
|
+
infov 'Package size', source_package.path.size
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :tempdir
|
42
|
+
|
43
|
+
def change_git_ignore
|
44
|
+
file = target_path.join('.gitignore')
|
45
|
+
file.write(
|
46
|
+
(file.read.each_line.map(&:strip).reject { |line| GITIGNORE_DEL.include?(line) } +
|
47
|
+
['', '#eac_redmine_base0'] + GITIGNORE_ADD).map { |line| "#{line}\n" }.join
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def extract_package_to_tempdir
|
52
|
+
infom "Extracting package to tempdir #{tempdir}..."
|
53
|
+
::EacRubyUtils::Envs.local.command(
|
54
|
+
'tar', '-xf', source_package.path.to_path, '-C', tempdir.to_path,
|
55
|
+
'--strip-components', '1'
|
56
|
+
).execute!
|
57
|
+
end
|
58
|
+
|
59
|
+
def git_commit
|
60
|
+
if git_repo.dirty?
|
61
|
+
infom 'Git commiting...'
|
62
|
+
git_repo.command('add', '--', target_path).execute!
|
63
|
+
git_repo.command('commit', '-m', git_commit_message, '--', target_path).execute!
|
64
|
+
else
|
65
|
+
infom 'Nothing to commit'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def git_commit_message
|
70
|
+
"Core: update to #{version}."
|
71
|
+
end
|
72
|
+
|
73
|
+
def git_repo_uncached
|
74
|
+
::EacGit::Local.new(target_path)
|
75
|
+
end
|
76
|
+
|
77
|
+
def sync_content
|
78
|
+
::Avm::Sync.new(source_path, target_path)
|
79
|
+
.add_exclude('/*').add_includes(*target_files_to_remove).move_mode(true).run
|
80
|
+
end
|
81
|
+
|
82
|
+
def source_package_uncached
|
83
|
+
::Avm::CachedDownload.new(url, ::Avm.fs_cache.child('eac_redmine_base0', 'core_update'))
|
84
|
+
end
|
85
|
+
|
86
|
+
def validate_empty_dir
|
87
|
+
if source_path.children.empty?
|
88
|
+
infom 'No content left in source directory'
|
89
|
+
else
|
90
|
+
fatal_error 'Found entries in source directory: ' +
|
91
|
+
source_path.children.map { |c| c.basename.to_path }.join(', ')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def source_path_uncached
|
96
|
+
::Pathname.new(tempdir.to_path)
|
97
|
+
end
|
98
|
+
|
99
|
+
def target_files_to_remove
|
100
|
+
git_repo.command('ls-files').execute!
|
101
|
+
.each_line.map { |v| "/#{v.strip}" }
|
102
|
+
.without(*TARGET_KEEP)
|
103
|
+
end
|
104
|
+
|
105
|
+
def target_path_uncached
|
106
|
+
instance.read_entry('fs_path').to_pathname
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/data/instance/unit'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'open-uri'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module EacRedmineBase0
|
9
|
+
class DataUnit < ::Avm::Data::Instance::Unit
|
10
|
+
common_constructor :instance
|
11
|
+
|
12
|
+
EXTENSION = '.tar'
|
13
|
+
|
14
|
+
def do_dump(data_path)
|
15
|
+
::File.open(data_path, 'wb') do |file|
|
16
|
+
file << URI.parse(export_url).read
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def export_url
|
21
|
+
uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + '/backup/export'
|
22
|
+
uri.query_values = { key: instance.read_entry('admin.api_key') }
|
23
|
+
uri.to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/stereotypes/eac_webapp_base0/deploy'
|
4
|
+
require 'eac_ruby_utils/ruby'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module EacRedmineBase0
|
8
|
+
class Deploy < ::Avm::Stereotypes::EacWebappBase0::Deploy
|
9
|
+
set_callback :assert_instance_branch, :after, :run_installer
|
10
|
+
|
11
|
+
def run_installer
|
12
|
+
infom 'Running installer'
|
13
|
+
::EacRubyUtils::Ruby.on_clean_environment do
|
14
|
+
installer_command.system!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def installer_command
|
19
|
+
instance.host_env.command(installer_path, install_task)
|
20
|
+
end
|
21
|
+
|
22
|
+
def installer_path
|
23
|
+
::File.join(instance.read_entry(:fs_path), 'plugins', 'redmine_installer', 'installer',
|
24
|
+
'run.sh')
|
25
|
+
end
|
26
|
+
|
27
|
+
def install_task
|
28
|
+
if instance.read_entry_optional('web.path').present?
|
29
|
+
'redmine_as_apache_path'
|
30
|
+
else
|
31
|
+
'redmine_as_apache_base'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_redmine_base0/data_unit'
|
4
|
+
require 'avm/stereotypes/eac_ubuntu_base0/docker_image'
|
5
|
+
require 'avm/stereotypes/eac_webapp_base0/instance'
|
6
|
+
require 'avm/stereotypes/rails/instance'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module EacRedmineBase0
|
10
|
+
class Instance < ::Avm::Stereotypes::EacWebappBase0::Instance
|
11
|
+
include ::Avm::Stereotypes::Rails::Instance
|
12
|
+
|
13
|
+
FILES_UNITS = { files: 'files' }.freeze
|
14
|
+
|
15
|
+
def docker_image_class
|
16
|
+
::Avm::Stereotypes::EacUbuntuBase0::DockerImage
|
17
|
+
end
|
18
|
+
|
19
|
+
def docker_run_arguments
|
20
|
+
[
|
21
|
+
'--volume', "#{read_entry(:fs_path)}:/home/myuser/eac_redmine_base0",
|
22
|
+
'--publish', "#{read_entry(:ssh_port)}:22",
|
23
|
+
'--publish', "#{read_entry(:http_port)}:80",
|
24
|
+
'--publish', "#{read_entry(:https_port)}:443"
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def data_package
|
29
|
+
@data_package ||= ::Avm::Data::Instance::Package.new(
|
30
|
+
self,
|
31
|
+
units: {
|
32
|
+
all: ::Avm::EacRedmineBase0::DataUnit.new(self)
|
33
|
+
}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_launcher/publish/check_result'
|
5
|
+
require('yaml')
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Launcher
|
9
|
+
class Context
|
10
|
+
class InstanceManager
|
11
|
+
require_sub __FILE__
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :context
|
14
|
+
|
15
|
+
def publish_state_set(instance, stereotype_name, check_status)
|
16
|
+
data = cached_instances_file_content_uncached
|
17
|
+
data[instance.logical] ||= {}
|
18
|
+
data[instance.logical][:publish_state] ||= {}
|
19
|
+
data[instance.logical][:publish_state][stereotype_name] = check_status
|
20
|
+
write_cache_file(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def pending_instances
|
24
|
+
instances.select { |instance| pending_instance?(instance) }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def instances_uncached
|
30
|
+
(cached_instances || search_instances).select(&:included?)
|
31
|
+
end
|
32
|
+
|
33
|
+
def search_instances
|
34
|
+
cache_instances(::EacLauncher::Context::InstanceDiscovery.new(context).instances)
|
35
|
+
end
|
36
|
+
|
37
|
+
def cached_instances
|
38
|
+
return nil if context.recache
|
39
|
+
return nil unless cached_instances_file_content
|
40
|
+
|
41
|
+
CachedInstances.new(self, cached_instances_file_content).instances
|
42
|
+
end
|
43
|
+
|
44
|
+
def cached_instances_file_content_uncached
|
45
|
+
r = YAML.load_file(cache_file_path)
|
46
|
+
r.is_a?(::Hash) ? r : nil
|
47
|
+
rescue Errno::ENOENT
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def cache_instances(instances)
|
52
|
+
write_cache_file(Hash[instances.map { |i| [i.logical, i.to_h] }])
|
53
|
+
instances
|
54
|
+
end
|
55
|
+
|
56
|
+
def write_cache_file(data)
|
57
|
+
::File.write(cache_file_path, data.to_yaml)
|
58
|
+
end
|
59
|
+
|
60
|
+
def cache_file_path
|
61
|
+
::File.join(context.cache_root, 'instances.yml')
|
62
|
+
end
|
63
|
+
|
64
|
+
def pending_instance?(instance)
|
65
|
+
data = cached_instances_file_content
|
66
|
+
return false unless data[instance.logical]
|
67
|
+
return false unless data[instance.logical][:publish_state].is_a?(Hash)
|
68
|
+
|
69
|
+
data[instance.logical][:publish_state].any? do |_k, v|
|
70
|
+
::EacLauncher::Publish::CheckResult.pending_status?(v)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/instances/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
class Context
|
9
|
+
class InstanceManager
|
10
|
+
class CachedInstance
|
11
|
+
enable_console_speaker
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :cached_instances, :data
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def instance_uncached
|
18
|
+
::Avm::Launcher::Instances::Base.instanciate(path, parent_instance)
|
19
|
+
rescue ::Avm::Launcher::Errors::NonProject
|
20
|
+
warn "Cached instance \"#{data[:logical]}\" not found"
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def parent_instance_uncached
|
25
|
+
data[:parent]
|
26
|
+
.if_present { |v| cached_instances.by_logical_path(v) }
|
27
|
+
.if_present(&:instance)
|
28
|
+
end
|
29
|
+
|
30
|
+
def path_uncached
|
31
|
+
::EacLauncher::Paths::Logical.from_h(cached_instances.context, data)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/context/instance_manager/cached_instance'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
class Context
|
9
|
+
class InstanceManager
|
10
|
+
class CachedInstances
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :context, :content
|
13
|
+
|
14
|
+
def instances
|
15
|
+
content.keys.map { |k| by_logical_path(k).instance }.reject(&:blank?)
|
16
|
+
end
|
17
|
+
|
18
|
+
def by_logical_path(key)
|
19
|
+
cached_instances[key].if_blank do
|
20
|
+
cached_instances[key] = ::Avm::Launcher::Context::InstanceManager::CachedInstance.new(
|
21
|
+
self, content.fetch(key)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def cached_instances_uncached
|
29
|
+
{}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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
|