avm 0.0.0 → 0.3.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/docker/container.rb +50 -0
- data/lib/avm/docker/image.rb +71 -0
- data/lib/avm/docker/runner.rb +117 -0
- data/lib/avm/docker.rb +9 -0
- data/lib/avm/executables.rb +24 -0
- data/lib/avm/files/appendable/file_content.rb +24 -0
- data/lib/avm/files/appendable/plain_directory.rb +25 -0
- data/lib/avm/files/appendable/resource_base.rb +13 -0
- data/lib/avm/files/appendable/tar_output_command.rb +26 -0
- data/lib/avm/files/appendable/templatized_directory.rb +29 -0
- data/lib/avm/files/appendable.rb +55 -0
- data/lib/avm/files/appender.rb +11 -0
- data/lib/avm/files/deploy.rb +71 -0
- data/lib/avm/files/formatter/formats/base.rb +62 -0
- data/lib/avm/files/formatter/formats/generic_plain.rb +34 -0
- data/lib/avm/files/formatter/formats/html.rb +45 -0
- data/lib/avm/files/formatter/formats/javascript.rb +23 -0
- data/lib/avm/files/formatter/formats/json.rb +27 -0
- data/lib/avm/files/formatter/formats/php.rb +21 -0
- data/lib/avm/files/formatter/formats/python.rb +21 -0
- data/lib/avm/files/formatter/formats/ruby.rb +22 -0
- data/lib/avm/files/formatter/formats/xml.rb +27 -0
- data/lib/avm/files/formatter/formats.rb +13 -0
- data/lib/avm/files/formatter/utf8_assert.rb +72 -0
- data/lib/avm/files/formatter.rb +90 -0
- data/lib/avm/files/info.rb +24 -0
- data/lib/avm/files/rotate.rb +107 -0
- data/lib/avm/files.rb +9 -0
- data/lib/avm/git/auto_commit/commit_info.rb +23 -0
- data/lib/avm/git/auto_commit/rules/base.rb +39 -0
- data/lib/avm/git/auto_commit/rules/last.rb +19 -0
- data/lib/avm/git/auto_commit/rules/manual.rb +45 -0
- data/lib/avm/git/auto_commit/rules/new.rb +24 -0
- data/lib/avm/git/auto_commit/rules/nth.rb +31 -0
- data/lib/avm/git/auto_commit/rules/unique.rb +21 -0
- data/lib/avm/git/auto_commit/rules.rb +31 -0
- data/lib/avm/git/auto_commit_path/ruby.rb +20 -0
- data/lib/avm/git/auto_commit_path.rb +28 -0
- data/lib/avm/git/commit/class_methods.rb +31 -0
- data/lib/avm/git/commit/deploy.rb +38 -0
- data/lib/avm/git/commit/deploy_methods.rb +19 -0
- data/lib/avm/git/commit/diff_tree_line.rb +32 -0
- data/lib/avm/git/commit/file.rb +46 -0
- data/lib/avm/git/commit.rb +59 -0
- data/lib/avm/git/file_auto_fixup.rb +83 -0
- data/lib/avm/git/issue/complete/commits.rb +42 -0
- data/lib/avm/git/issue/complete/git_subrepos.rb +23 -0
- data/lib/avm/git/issue/complete/local_branch.rb +54 -0
- data/lib/avm/git/issue/complete/local_tag.rb +39 -0
- data/lib/avm/git/issue/complete/push.rb +54 -0
- data/lib/avm/git/issue/complete/remote.rb +33 -0
- data/lib/avm/git/issue/complete/test.rb +45 -0
- data/lib/avm/git/issue/complete/tracker.rb +28 -0
- data/lib/avm/git/issue/complete/validation.rb +31 -0
- data/lib/avm/git/issue/complete/validations.rb +53 -0
- data/lib/avm/git/issue/complete/working_tree.rb +19 -0
- data/lib/avm/git/issue/complete.rb +51 -0
- data/lib/avm/git/issue/deliver.rb +56 -0
- data/lib/avm/git/issue.rb +11 -0
- data/lib/avm/git/organize/reference_update.rb +34 -0
- data/lib/avm/git/organize/repository.rb +76 -0
- data/lib/avm/git/organize.rb +11 -0
- data/lib/avm/git/revision_test.rb +106 -0
- data/lib/avm/git/subrepo_check/parent.rb +51 -0
- data/lib/avm/git/subrepo_check/remote.rb +89 -0
- data/lib/avm/git/subrepo_check/show_result.rb +32 -0
- data/lib/avm/git/subrepo_check.rb +38 -0
- data/lib/avm/git/subrepo_checks.rb +59 -0
- data/lib/avm/git.rb +10 -0
- data/lib/avm/instances/docker_image.rb +15 -0
- data/lib/avm/result.rb +86 -0
- data/lib/avm/version.rb +1 -1
- data/lib/avm/version_number.rb +45 -0
- metadata +143 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 280fbe10e4f6675e6477b280f96ffb9bd5caf5df609ff08bec8cfe8600dada5a
|
4
|
+
data.tar.gz: a84ce459a88b027da9e777de1113a43d0606b5da74735e4201910cb8b24d492e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a331ef08d2d6323b65655c2dda06f43c6a2c28102c070ffa73c32b190b1bd257eddf1ff1ea5809c52d983fc4669e61dffd128a91345ac151948a6b79f5cafbe
|
7
|
+
data.tar.gz: a43e4b01aaa402821e241cdf1d95d184b165f9b4322bae204a99b627de28275e239c4ac45197b0c25e32d0903033461725cf57256cd7a7f79030ed48f28e1879
|
@@ -0,0 +1,50 @@
|
|
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
|
@@ -0,0 +1,71 @@
|
|
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
|
@@ -0,0 +1,117 @@
|
|
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
|
+
arg_opt '-n', '--registry-name', 'Docker registry\'s name.'
|
17
|
+
bool_opt '-p', '--push', 'Push the image to Docker registry.'
|
18
|
+
bool_opt '-r', '--run', 'Run or start a container with builded image.'
|
19
|
+
arg_opt '-B', '--build-arg', 'Argument for "docker build".', repeat: true
|
20
|
+
arg_opt '-E', '--entrypoint-arg', 'Argument for entrypoint on "docker run"', repeat: true
|
21
|
+
bool_opt '-c', '--clear', 'Remove container if exist before run.'
|
22
|
+
bool_opt '-S', '--no-snapshot', 'Does not add "-snapshot" to image tag.'
|
23
|
+
bool_opt '-V', '--no-version', 'Does not add version to image tag.'
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
setup
|
28
|
+
banner
|
29
|
+
build
|
30
|
+
push
|
31
|
+
container_run
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def setup
|
37
|
+
instance.docker_image_options = {
|
38
|
+
registry: registry,
|
39
|
+
snapshot: snapshot?,
|
40
|
+
version: version?
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def banner
|
45
|
+
infov 'Registry name', registry
|
46
|
+
infov 'Version?', version?
|
47
|
+
infov 'Snapshot?', snapshot?
|
48
|
+
infov 'Image name', docker_image.tag
|
49
|
+
infov 'Build arguments', build_args
|
50
|
+
infov 'Entrypoint arguments', entrypoint_args
|
51
|
+
end
|
52
|
+
|
53
|
+
def build
|
54
|
+
docker_image.build(build_args)
|
55
|
+
success 'Docker image builded'
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_args
|
59
|
+
parsed.build_arg
|
60
|
+
end
|
61
|
+
|
62
|
+
def docker_container
|
63
|
+
instance.docker_container
|
64
|
+
end
|
65
|
+
|
66
|
+
def docker_image
|
67
|
+
instance.docker_image
|
68
|
+
end
|
69
|
+
|
70
|
+
def entrypoint_args
|
71
|
+
parsed.entrypoint_arg
|
72
|
+
end
|
73
|
+
|
74
|
+
def push
|
75
|
+
docker_image.push if parsed.push?
|
76
|
+
end
|
77
|
+
|
78
|
+
def container_run
|
79
|
+
return unless parsed.run?
|
80
|
+
|
81
|
+
docker_container.run(
|
82
|
+
entrypoint_args: entrypoint_args,
|
83
|
+
clear: parsed.clear?
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def registry_uncached
|
88
|
+
registry_from_option || registry_from_instance || registry_from_default ||
|
89
|
+
fatal_error('No registry defined')
|
90
|
+
end
|
91
|
+
|
92
|
+
def registry_from_option
|
93
|
+
parsed.registry_name.if_present { |v| ::EacDocker::Registry.new(v) }
|
94
|
+
end
|
95
|
+
|
96
|
+
def registry_from_instance
|
97
|
+
instance.docker_registry_optional.if_present { |v| ::EacDocker::Registry.new(v) }
|
98
|
+
end
|
99
|
+
|
100
|
+
def registry_from_default
|
101
|
+
if_respond(DOCKER_DEFAULT_REGISTRY_METHOD, nil)
|
102
|
+
end
|
103
|
+
|
104
|
+
def snapshot?
|
105
|
+
!parsed.no_snapshot?
|
106
|
+
end
|
107
|
+
|
108
|
+
def version?
|
109
|
+
!parsed.no_version?
|
110
|
+
end
|
111
|
+
|
112
|
+
def instance
|
113
|
+
runner_context.call(:instance)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/lib/avm/docker.rb
ADDED
@@ -0,0 +1,24 @@
|
|
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
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/files/appendable/resource_base'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Files
|
8
|
+
module Appendable
|
9
|
+
class FileContent < ::Avm::Files::Appendable::ResourceBase
|
10
|
+
attr_reader :target_path, :content
|
11
|
+
|
12
|
+
def initialize(deploy, target_path, content)
|
13
|
+
super(deploy)
|
14
|
+
@target_path = target_path
|
15
|
+
@content = content
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_on(target_dir)
|
19
|
+
target_dir.join(target_path).write(content)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/files/appendable/resource_base'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Files
|
8
|
+
module Appendable
|
9
|
+
class PlainDirectory < ::Avm::Files::Appendable::ResourceBase
|
10
|
+
attr_reader :source_path
|
11
|
+
|
12
|
+
def initialize(appender, source_path)
|
13
|
+
super(appender)
|
14
|
+
@source_path = source_path.to_pathname
|
15
|
+
end
|
16
|
+
|
17
|
+
def write_on(target_dir)
|
18
|
+
raise "\"#{source_path}\" is not a directory" unless source_path.directory?
|
19
|
+
|
20
|
+
::FileUtils.cp_r("#{source_path}/.", target_dir.to_path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/envs'
|
5
|
+
require 'avm/files/appendable/resource_base'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Files
|
9
|
+
module Appendable
|
10
|
+
class TarOutputCommand < ::Avm::Files::Appendable::ResourceBase
|
11
|
+
attr_reader :command
|
12
|
+
|
13
|
+
def initialize(appender, command)
|
14
|
+
super(appender)
|
15
|
+
@command = command
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_on(target_dir)
|
19
|
+
command.pipe(
|
20
|
+
::EacRubyUtils::Envs.local.command('tar', '-xf', '-', '-C', target_dir)
|
21
|
+
).execute!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/files/appendable/resource_base'
|
5
|
+
require 'eac_templates/directory'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Files
|
9
|
+
module Appendable
|
10
|
+
class TemplatizedDirectory < ::Avm::Files::Appendable::ResourceBase
|
11
|
+
attr_reader :source_path
|
12
|
+
|
13
|
+
def initialize(appender, source_path)
|
14
|
+
super(appender)
|
15
|
+
@source_path = source_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_on(target_dir)
|
19
|
+
raise 'Variables source not set' if appender.variables_source.blank?
|
20
|
+
|
21
|
+
::EacTemplates::Directory.new(source_path).apply(
|
22
|
+
appender.variables_source,
|
23
|
+
target_dir
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Files
|
7
|
+
module Appendable
|
8
|
+
require_sub __FILE__
|
9
|
+
|
10
|
+
attr_reader :variables_source
|
11
|
+
|
12
|
+
def appended
|
13
|
+
@appended ||= []
|
14
|
+
end
|
15
|
+
|
16
|
+
def append_templatized_directories(directories)
|
17
|
+
directories.each { |directory| append_templatized_directory(directory) }
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def append_plain_directory(directory)
|
22
|
+
appended << ::Avm::Files::Appendable::PlainDirectory.new(self, directory)
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def append_tar_output_command(tar_command)
|
27
|
+
appended << ::Avm::Files::Appendable::TarOutputCommand.new(self, tar_command)
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
def append_templatized_directory(directory)
|
32
|
+
appended << ::Avm::Files::Appendable::TemplatizedDirectory.new(self, directory)
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def append_file_content(target_path, content)
|
37
|
+
appended << ::Avm::Files::Appendable::FileContent
|
38
|
+
.new(self, target_path, content)
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def variables_source_set(source)
|
43
|
+
@variables_source = source
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
def write_appended_on(target_dir)
|
48
|
+
target_dir = target_dir.to_pathname
|
49
|
+
raise "\"#{target_dir}\" is not a directory" unless target_dir.directory?
|
50
|
+
|
51
|
+
appended.each { |append| append.write_on(target_dir) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|