dapp 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/dapp +3 -3
- data/config/en/common.yml +19 -4
- data/config/en/net_status.yml +13 -4
- data/lib/dapp.rb +48 -16
- data/lib/dapp/application.rb +75 -40
- data/lib/dapp/application/path.rb +3 -2
- data/lib/dapp/application/stages.rb +59 -0
- data/lib/dapp/artifact.rb +22 -0
- data/lib/dapp/build/stage/after_install_artifact.rb +13 -0
- data/lib/dapp/build/stage/after_setup_artifact.rb +17 -0
- data/lib/dapp/build/stage/artifact_base.rb +80 -0
- data/lib/dapp/build/stage/artifact_default.rb +62 -0
- data/lib/dapp/build/stage/base.rb +47 -12
- data/lib/dapp/build/stage/before_install.rb +6 -5
- data/lib/dapp/build/stage/before_install_artifact.rb +13 -0
- data/lib/dapp/build/stage/before_setup.rb +7 -8
- data/lib/dapp/build/stage/before_setup_artifact.rb +13 -0
- data/lib/dapp/build/stage/build_artifact.rb +32 -0
- data/lib/dapp/build/stage/docker_instructions.rb +4 -22
- data/lib/dapp/build/stage/from.rb +7 -8
- data/lib/dapp/build/stage/ga_archive.rb +1 -1
- data/lib/dapp/build/stage/ga_archive_dependencies.rb +1 -1
- data/lib/dapp/build/stage/ga_artifact_patch.rb +21 -0
- data/lib/dapp/build/stage/ga_base.rb +6 -29
- data/lib/dapp/build/stage/ga_dependencies_base.rb +4 -13
- data/lib/dapp/build/stage/ga_latest_patch.rb +2 -2
- data/lib/dapp/build/stage/import_artifact.rb +69 -0
- data/lib/dapp/build/stage/install/ga_post_install_patch.rb +1 -1
- data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +1 -1
- data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +1 -7
- data/lib/dapp/build/stage/install/install.rb +12 -7
- data/lib/dapp/build/stage/mod/logging.rb +10 -7
- data/lib/dapp/build/stage/setup/chef_cookbooks.rb +3 -4
- data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +1 -1
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +2 -2
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +2 -8
- data/lib/dapp/build/stage/setup/setup.rb +12 -7
- data/lib/dapp/builder/base.rb +13 -1
- data/lib/dapp/builder/chef.rb +125 -79
- data/lib/dapp/builder/chef/cookbook_metadata.rb +1 -1
- data/lib/dapp/builder/shell.rb +2 -3
- data/lib/dapp/cli.rb +3 -3
- data/lib/dapp/cli/base.rb +0 -2
- data/lib/dapp/cli/bp.rb +0 -4
- data/lib/dapp/cli/build.rb +3 -7
- data/lib/dapp/cli/cleanup.rb +0 -2
- data/lib/dapp/cli/list.rb +0 -2
- data/lib/dapp/cli/mrproper.rb +22 -0
- data/lib/dapp/cli/push.rb +4 -3
- data/lib/dapp/cli/run.rb +0 -2
- data/lib/dapp/cli/spush.rb +0 -2
- data/lib/dapp/cli/stage_image.rb +24 -0
- data/lib/dapp/cli/stages.rb +7 -5
- data/lib/dapp/cli/stages/cleanup_local.rb +28 -0
- data/lib/dapp/cli/stages/cleanup_repo.rb +24 -0
- data/lib/dapp/cli/stages/{flush.rb → flush_local.rb} +4 -6
- data/lib/dapp/cli/stages/{cleanup.rb → flush_repo.rb} +4 -6
- data/lib/dapp/cli/stages/pull.rb +28 -0
- data/lib/dapp/cli/stages/push.rb +24 -0
- data/lib/dapp/config/application.rb +185 -44
- data/lib/dapp/config/artifact.rb +10 -50
- data/lib/dapp/config/directive/artifact.rb +77 -0
- data/lib/dapp/config/directive/build_dir.rb +9 -0
- data/lib/dapp/config/directive/chef.rb +95 -0
- data/lib/dapp/config/directive/docker/artifact.rb +26 -0
- data/lib/dapp/config/directive/docker/base.rb +91 -0
- data/lib/dapp/config/directive/git_artifact.rb +59 -0
- data/lib/dapp/config/directive/shell/artifact.rb +38 -0
- data/lib/dapp/config/directive/shell/base.rb +85 -0
- data/lib/dapp/config/directive/tmp_dir.rb +36 -0
- data/lib/dapp/config/main.rb +1 -7
- data/lib/dapp/core_ext/hash.rb +21 -0
- data/lib/dapp/docker_registry/base.rb +60 -5
- data/lib/dapp/docker_registry/mod/request.rb +2 -14
- data/lib/dapp/git_artifact.rb +32 -23
- data/lib/dapp/git_repo/base.rb +1 -1
- data/lib/dapp/image/argument.rb +3 -3
- data/lib/dapp/image/docker.rb +13 -16
- data/lib/dapp/image/scratch.rb +29 -0
- data/lib/dapp/image/stage.rb +33 -23
- data/lib/dapp/lock/base.rb +18 -11
- data/lib/dapp/lock/file.rb +18 -16
- data/lib/dapp/prctl.rb +1 -0
- data/lib/dapp/project.rb +22 -9
- data/lib/dapp/project/command/bp.rb +2 -5
- data/lib/dapp/project/command/build.rb +1 -2
- data/lib/dapp/project/command/cleanup.rb +9 -7
- data/lib/dapp/project/command/common.rb +37 -12
- data/lib/dapp/project/command/mrproper.rb +57 -0
- data/lib/dapp/project/command/push.rb +8 -2
- data/lib/dapp/project/command/run.rb +1 -1
- data/lib/dapp/project/command/stage_image.rb +15 -0
- data/lib/dapp/project/command/stages/cleanup_local.rb +100 -0
- data/lib/dapp/project/command/stages/cleanup_repo.rb +65 -0
- data/lib/dapp/project/command/stages/common.rb +48 -0
- data/lib/dapp/project/command/stages/flush_local.rb +24 -0
- data/lib/dapp/project/command/stages/flush_repo.rb +22 -0
- data/lib/dapp/project/command/stages/pull.rb +26 -0
- data/lib/dapp/project/command/stages/push.rb +22 -0
- data/lib/dapp/project/dappfile.rb +3 -1
- data/lib/dapp/project/deps/base.rb +52 -0
- data/lib/dapp/project/deps/gitartifact.rb +36 -0
- data/lib/dapp/project/lock.rb +20 -13
- data/lib/dapp/project/logging/base.rb +20 -3
- data/lib/dapp/project/logging/i18n.rb +25 -0
- data/lib/dapp/project/logging/paint.rb +47 -0
- data/lib/dapp/project/logging/process.rb +17 -10
- data/lib/dapp/project/shellout/base.rb +74 -0
- data/lib/dapp/project/shellout/streaming.rb +49 -0
- data/lib/dapp/project/shellout/system.rb +72 -0
- data/lib/dapp/project/ssh_agent.rb +8 -9
- data/lib/dapp/version.rb +1 -1
- metadata +48 -17
- data/lib/dapp/build/stage/artifact.rb +0 -40
- data/lib/dapp/build/stage/mod/artifact.rb +0 -79
- data/lib/dapp/config/chef.rb +0 -51
- data/lib/dapp/config/docker.rb +0 -82
- data/lib/dapp/config/git_artifact.rb +0 -51
- data/lib/dapp/config/shell.rb +0 -64
- data/lib/dapp/helper/i18n.rb +0 -20
- data/lib/dapp/helper/paint.rb +0 -27
- data/lib/dapp/helper/shellout.rb +0 -63
- data/lib/dapp/helper/streaming.rb +0 -47
- data/lib/dapp/project/command/stages_cleanup.rb +0 -72
- data/lib/dapp/project/command/stages_flush.rb +0 -20
- data/lib/dapp/project/paint.rb +0 -16
data/lib/dapp/config/shell.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
module Config
|
3
|
-
# Shell
|
4
|
-
class Shell
|
5
|
-
attr_reader :_before_install, :_before_setup, :_install, :_setup
|
6
|
-
attr_reader :_before_install_cache_version, :_before_setup_cache_version, :_install_cache_version, :_setup_cache_version
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@_before_install = []
|
10
|
-
@_before_setup = []
|
11
|
-
@_install = []
|
12
|
-
@_setup = []
|
13
|
-
end
|
14
|
-
|
15
|
-
def before_install(*args, cache_version: nil)
|
16
|
-
@_before_install.concat(args)
|
17
|
-
@_before_install_cache_version = cache_version
|
18
|
-
end
|
19
|
-
|
20
|
-
def before_setup(*args, cache_version: nil)
|
21
|
-
@_before_setup.concat(args)
|
22
|
-
@_before_setup_cache_version = cache_version
|
23
|
-
end
|
24
|
-
|
25
|
-
def install(*args, cache_version: nil)
|
26
|
-
_install.concat(args)
|
27
|
-
@_install_cache_version = cache_version
|
28
|
-
end
|
29
|
-
|
30
|
-
def setup(*args, cache_version: nil)
|
31
|
-
_setup.concat(args)
|
32
|
-
@_setup_cache_version = cache_version
|
33
|
-
end
|
34
|
-
|
35
|
-
def reset_before_install
|
36
|
-
@_before_install = []
|
37
|
-
end
|
38
|
-
|
39
|
-
def reset_before_setup
|
40
|
-
@_before_setup = []
|
41
|
-
end
|
42
|
-
|
43
|
-
def reset_install
|
44
|
-
@_install = []
|
45
|
-
end
|
46
|
-
|
47
|
-
def reset_setup
|
48
|
-
@_setup = []
|
49
|
-
end
|
50
|
-
|
51
|
-
def reset_all
|
52
|
-
methods.tap { |arr| arr.delete(__method__) }.grep(/^reset_/).each(&method(:send))
|
53
|
-
end
|
54
|
-
|
55
|
-
def empty?
|
56
|
-
@_before_install.empty? && @_before_setup.empty? && @_install.empty? && @_setup.empty?
|
57
|
-
end
|
58
|
-
|
59
|
-
def clone
|
60
|
-
Marshal.load(Marshal.dump(self))
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/dapp/helper/i18n.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
module Helper
|
3
|
-
# I18n
|
4
|
-
module I18n
|
5
|
-
def self.initialize
|
6
|
-
::I18n.load_path << Dir[File.join(Dapp.root, 'config', '**', '*')].select { |path| File.file?(path) }
|
7
|
-
::I18n.reload!
|
8
|
-
::I18n.locale = :en
|
9
|
-
end
|
10
|
-
|
11
|
-
def t(context: nil, **desc)
|
12
|
-
code = desc[:code]
|
13
|
-
data = desc[:data] || {}
|
14
|
-
::I18n.t [:common, context, code].join('.'), [:common, code].join('.'), **data, raise: true
|
15
|
-
rescue ::I18n::MissingTranslationData => _e
|
16
|
-
raise ::NetStatus::Exception, code: :missing_translation, data: { code: code }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end # Helper
|
20
|
-
end # Dapp
|
data/lib/dapp/helper/paint.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
module Helper
|
3
|
-
# Paint
|
4
|
-
module Paint
|
5
|
-
FORMAT = {
|
6
|
-
step: [:yellow, :bold],
|
7
|
-
info: [:blue],
|
8
|
-
success: [:green, :bold],
|
9
|
-
warning: [:red, :bold],
|
10
|
-
secondary: [:white, :bold],
|
11
|
-
default: [:white]
|
12
|
-
}.freeze
|
13
|
-
|
14
|
-
def paint_style(name)
|
15
|
-
FORMAT[name].tap do |format|
|
16
|
-
raise if format.nil?
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def paint_string(object, style_name)
|
21
|
-
::Paint[::Paint.unpaint(object.to_s), *paint_style(style_name)]
|
22
|
-
end
|
23
|
-
end # Paint
|
24
|
-
end # Helper
|
25
|
-
end # Dapp
|
26
|
-
|
27
|
-
Dapp::Helper::Paint.extend Dapp::Helper::Paint
|
data/lib/dapp/helper/shellout.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
module Helper
|
3
|
-
# Shellout
|
4
|
-
module Shellout
|
5
|
-
include Streaming
|
6
|
-
|
7
|
-
def shellout(*args, log_verbose: false, **kwargs)
|
8
|
-
log_verbose = (log_verbose && cli_options[:log_verbose]) if defined? cli_options
|
9
|
-
kwargs[:live_stream] ||= STDOUT if log_verbose
|
10
|
-
|
11
|
-
env = nil
|
12
|
-
|
13
|
-
Shellout.default_env_keys.each do |env_key|
|
14
|
-
env_key = env_key.to_s.upcase
|
15
|
-
env ||= {}
|
16
|
-
env[env_key] = ENV[env_key]
|
17
|
-
end
|
18
|
-
|
19
|
-
param_env = (kwargs.delete(:env) || kwargs.delete(:environment))
|
20
|
-
param_env = param_env.map { |key, value| [key.to_s.upcase, value.to_s] }.to_h if param_env
|
21
|
-
|
22
|
-
env = (env || {}).merge(param_env) if param_env
|
23
|
-
kwargs[:env] = env if env
|
24
|
-
|
25
|
-
do_shellout = -> { ::Mixlib::ShellOut.new(*args, timeout: 3600, **kwargs).run_command }
|
26
|
-
if defined? ::Bundler
|
27
|
-
::Bundler.with_clean_env { do_shellout.call }
|
28
|
-
else
|
29
|
-
do_shellout.call
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def shellout!(*args, log_verbose: false, log_time: false, **kwargs)
|
34
|
-
stream = Stream.new
|
35
|
-
log_time = defined?(cli_options) ? cli_options[:log_time] : log_time
|
36
|
-
if log_verbose
|
37
|
-
kwargs[:live_stream] = Proxy::Base.new(stream, STDOUT, with_time: log_time)
|
38
|
-
else
|
39
|
-
kwargs[:live_stdout] = Proxy::Base.new(stream, with_time: log_time)
|
40
|
-
end
|
41
|
-
kwargs[:live_stderr] = Proxy::Error.new(stream, with_time: log_time)
|
42
|
-
shellout(*args, **kwargs).tap(&:error!)
|
43
|
-
rescue ::Mixlib::ShellOut::ShellCommandFailed => e
|
44
|
-
raise Error::Shellout, code: Trivia.class_to_lowercase(e.class),
|
45
|
-
data: { stream: stream.show }
|
46
|
-
end
|
47
|
-
|
48
|
-
def shellout_pack(command)
|
49
|
-
"eval $(echo #{Base64.strict_encode64(command)} | base64 --decode)"
|
50
|
-
end
|
51
|
-
|
52
|
-
class << self
|
53
|
-
def included(base)
|
54
|
-
base.extend(self)
|
55
|
-
end
|
56
|
-
|
57
|
-
def default_env_keys
|
58
|
-
@default_env_keys ||= []
|
59
|
-
end
|
60
|
-
end # << self
|
61
|
-
end
|
62
|
-
end # Helper
|
63
|
-
end # Dapp
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
module Helper
|
3
|
-
# Streaming
|
4
|
-
module Streaming
|
5
|
-
# Stream
|
6
|
-
class Stream
|
7
|
-
def buffer
|
8
|
-
@buffer ||= []
|
9
|
-
end
|
10
|
-
|
11
|
-
def <<(string)
|
12
|
-
buffer << string
|
13
|
-
end
|
14
|
-
|
15
|
-
def show
|
16
|
-
buffer.join.strip
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Proxy
|
21
|
-
module Proxy
|
22
|
-
# Base
|
23
|
-
class Base
|
24
|
-
def initialize(*streams, with_time: false)
|
25
|
-
@streams = streams
|
26
|
-
@with_time = with_time
|
27
|
-
end
|
28
|
-
|
29
|
-
def <<(str)
|
30
|
-
@streams.each { |s| s << format_string(str) }
|
31
|
-
end
|
32
|
-
|
33
|
-
def format_string(str)
|
34
|
-
str.lines.map { |l| "#{Project::Logging.log_time if @with_time}#{l.strip}\n" }.join
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Error
|
39
|
-
class Error < Base
|
40
|
-
def format_string(str)
|
41
|
-
"#{Paint.paint_string(super.strip, :warning)}\n"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end # Helper
|
47
|
-
end # Dapp
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
# Project
|
3
|
-
class Project
|
4
|
-
# Command
|
5
|
-
module Command
|
6
|
-
# StagesCleanup
|
7
|
-
module StagesCleanup
|
8
|
-
def stages_cleanup(repo)
|
9
|
-
repo_applications = repo_applications(repo)
|
10
|
-
build_configs.map(&:_basename).uniq.each do |basename|
|
11
|
-
lock("#{basename}.images") do
|
12
|
-
log(basename)
|
13
|
-
containers_flush(basename)
|
14
|
-
apps, stages = project_images(basename).partition { |_, image_id| repo_applications.values.include?(image_id) }
|
15
|
-
apps, stages = apps.to_h, stages.to_h
|
16
|
-
apps.each { |_, aiid| stages = clear_stages(aiid, stages) }
|
17
|
-
run_command(%(docker rmi #{stages.keys.join(' ')})) unless stages.keys.empty?
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def clear_stages(image_id, stages)
|
23
|
-
if image_exist?(image_id)
|
24
|
-
image_dapp_artifacts_label(image_id).each { |aiid| clear_stages(aiid, stages) }
|
25
|
-
iid = image_id
|
26
|
-
loop do
|
27
|
-
stages.delete_if { |_, siid| siid == iid }
|
28
|
-
break if (iid = image_parent(iid)).empty?
|
29
|
-
end
|
30
|
-
else
|
31
|
-
stages.delete_if { |_, siid| siid == image_id }
|
32
|
-
end
|
33
|
-
stages
|
34
|
-
end
|
35
|
-
|
36
|
-
protected
|
37
|
-
|
38
|
-
def registry(repo)
|
39
|
-
@registry ||= DockerRegistry.new(repo)
|
40
|
-
end
|
41
|
-
|
42
|
-
def repo_applications(repo)
|
43
|
-
@repo_apps ||= begin
|
44
|
-
registry = registry(repo)
|
45
|
-
registry.tags.select { |tag| !tag.start_with?('dappstage') }.map { |tag| [tag, registry.image_id_by_tag(tag)] }.to_h
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def project_images(basename)
|
50
|
-
shellout!(%(docker images --format "{{.Repository}}:{{.Tag}};{{.ID}}" --no-trunc #{stage_cache(basename)})).stdout.lines.map do |line|
|
51
|
-
line.strip.split(';')
|
52
|
-
end.to_h
|
53
|
-
end
|
54
|
-
|
55
|
-
def image_parent(image_id)
|
56
|
-
shellout!(%(docker inspect -f {{.Parent}} #{image_id})).stdout.strip
|
57
|
-
end
|
58
|
-
|
59
|
-
def image_dapp_artifacts_label(image_id)
|
60
|
-
Image::Docker.image_config_option(image_id: image_id, option: 'labels').select { |k, _v| k.start_with?('dapp-artifact') }.values
|
61
|
-
end
|
62
|
-
|
63
|
-
def image_exist?(image_id)
|
64
|
-
shellout!(%(docker inspect #{image_id}))
|
65
|
-
true
|
66
|
-
rescue Error::Shellout
|
67
|
-
false
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end # Project
|
72
|
-
end # Dapp
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
# Project
|
3
|
-
class Project
|
4
|
-
# Command
|
5
|
-
module Command
|
6
|
-
# StagesFlush
|
7
|
-
module StagesFlush
|
8
|
-
def stages_flush
|
9
|
-
build_configs.map(&:_basename).uniq.each do |basename|
|
10
|
-
lock("#{basename}.images") do
|
11
|
-
log(basename)
|
12
|
-
containers_flush(basename)
|
13
|
-
remove_images(%(docker images --format="{{.Repository}}:{{.Tag}}" #{stage_cache(basename)}))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end # Project
|
20
|
-
end # Dapp
|
data/lib/dapp/project/paint.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
# Project
|
3
|
-
class Project
|
4
|
-
# Paint
|
5
|
-
module Paint
|
6
|
-
def paint_initialize
|
7
|
-
::Paint.mode = case cli_options[:log_color]
|
8
|
-
when 'auto' then STDOUT.tty? ? 8 : 0
|
9
|
-
when 'on' then 8
|
10
|
-
when 'off' then 0
|
11
|
-
else raise
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end # Paint
|
15
|
-
end # Project
|
16
|
-
end # Dapp
|