dapp 0.22.5 → 0.22.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/en/net_status.yml +1 -1
- data/lib/dapp.rb +1 -0
- data/lib/dapp/cli/command/base.rb +2 -15
- data/lib/dapp/dapp.rb +17 -7
- data/lib/dapp/dapp/deps/base.rb +1 -1
- data/lib/dapp/dapp/deps/gitartifact.rb +1 -1
- data/lib/dapp/dapp/deps/toolchain.rb +1 -1
- data/lib/dapp/dapp/lock.rb +6 -16
- data/lib/dapp/dapp/logging/base.rb +4 -6
- data/lib/dapp/dapp/slug.rb +1 -1
- data/lib/dapp/dimg/builder/chef.rb +1 -1
- data/lib/dapp/dimg/cli/command/base.rb +4 -0
- data/lib/dapp/dimg/cli/command/dimg/push.rb +3 -1
- data/lib/dapp/dimg/cli/command/dimg/stages/pull.rb +3 -1
- data/lib/dapp/dimg/cli/command/dimg/stages/push.rb +3 -1
- data/lib/dapp/dimg/config/directive/dimg/instance_methods.rb +6 -2
- data/lib/dapp/dimg/config/directive/dimg_group.rb +11 -2
- data/lib/dapp/dimg/dapp/command/common.rb +6 -4
- data/lib/dapp/dimg/dapp/command/stages/cleanup_local.rb +7 -9
- data/lib/dapp/dimg/dapp/command/stages/common.rb +8 -20
- data/lib/dapp/dimg/dapp/command/stages/flush_local.rb +3 -5
- data/lib/dapp/dimg/docker_registry.rb +3 -1
- data/lib/dapp/dimg/docker_registry/base.rb +0 -3
- data/lib/dapp/dimg/docker_registry/base/authorization.rb +12 -8
- data/lib/dapp/dimg/docker_registry/dimg.rb +7 -3
- data/lib/dapp/dimg/lock/file.rb +4 -4
- data/lib/dapp/kube/cli/command/kube/deploy.rb +6 -10
- data/lib/dapp/kube/cli/command/kube/lint.rb +5 -10
- data/lib/dapp/kube/cli/command/kube/render.rb +5 -11
- data/lib/dapp/kube/dapp/command/lint.rb +3 -1
- data/lib/dapp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 657b2271dc5a641fcd90ed720470a81ce478f73a
|
4
|
+
data.tar.gz: 5b4201a16c7da7be4cdddc0b9b3a2a697c7e59b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ddad23ac4121cec7218dbaef4b2353710eef0d62bbe618cd07a25e89f1ea21b9b49e89e7282198f8a3d767cd8f85291fc854e38161c3bc05683443530ba09b4
|
7
|
+
data.tar.gz: bdc290374d797d1d5632226fa20e168c2f14350f988e60bc53c6e7966c9ff9795bc03bc863974cdff8136f24319ef5ea06223aace8f8b59f3e3067babbaa0093
|
data/config/en/net_status.yml
CHANGED
@@ -108,11 +108,11 @@ en:
|
|
108
108
|
builder_cookbook_not_found: "Dapp cookbook directory not found at %{path}"
|
109
109
|
berksfile_absolute_path_forbidden: "Absolute paths in Berksfile are not allowed (cookbook `%{cookbook}`, path: `%{path}`)"
|
110
110
|
registry:
|
111
|
-
no_such_dimg: 'Registry `%{registry}`: no such dimg in registry!'
|
112
111
|
authenticate_type_not_supported: 'Registry `%{registry}`: authenticate type is not supported!'
|
113
112
|
page_not_found: "Registry `%{registry}`: page `%{url}` not found!"
|
114
113
|
method_not_allowed: "Registry `%{registry}`: method `%{method}` not allowed (`%{url}`)!"
|
115
114
|
user_not_authorized: 'Registry `%{registry}`: user not authorized!'
|
115
|
+
registry_not_available: 'Registry `%{registry}`: not available!'
|
116
116
|
rugged:
|
117
117
|
git_repository_reference_error: "Git repo `%{name}`: %{message}!"
|
118
118
|
rugged_remote_error: "Remote git repo `%{url}`: `%{message}`!"
|
data/lib/dapp.rb
CHANGED
@@ -7,14 +7,6 @@ module Dapp
|
|
7
7
|
description: 'Change to directory',
|
8
8
|
on: :head
|
9
9
|
|
10
|
-
%w(run_dir build_dir deploy_dir).tap do |dirs|
|
11
|
-
dirs.each do |dir|
|
12
|
-
option dir.to_sym,
|
13
|
-
long: "--#{dir.gsub("_", "-")} PATH",
|
14
|
-
description: "Directory where reside: build cache, lock files for concurrent dapp operations (DIR/.dapp_build by default). Alias for #{(dirs - [dir]).map{|d| "--" + d.gsub("_", "-")}.join(", ")}."
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
10
|
option :name,
|
19
11
|
long: "--name NAME",
|
20
12
|
description: "Use custom dapp name. Chaging default name will cause full cache rebuild. By default dapp name is the last element of remote.origin.url from project git, or it is the name of the directory where Dappfile resides."
|
@@ -64,12 +56,12 @@ module Dapp
|
|
64
56
|
super()
|
65
57
|
end
|
66
58
|
|
67
|
-
def run_dapp_command(run_method, options: {}, log_running_time: true)
|
59
|
+
def run_dapp_command(run_method, options: {}, log_running_time: true, try_host_docker_login: false)
|
68
60
|
dapp = ::Dapp::Dapp.new(options: options)
|
69
61
|
|
70
62
|
log_dapp_running_time(dapp, ignore: !log_running_time) do
|
71
63
|
begin
|
72
|
-
|
64
|
+
dapp.try_host_docker_login if try_host_docker_login
|
73
65
|
|
74
66
|
if block_given?
|
75
67
|
yield dapp
|
@@ -97,11 +89,6 @@ module Dapp
|
|
97
89
|
raise
|
98
90
|
end
|
99
91
|
|
100
|
-
def before_dapp_run_command(dapp, &blk)
|
101
|
-
yield if block_given?
|
102
|
-
dapp.try_host_docker_login
|
103
|
-
end
|
104
|
-
|
105
92
|
def cli_options(**kwargs)
|
106
93
|
dirs = [config[:build_dir], config[:run_dir], config[:deploy_dir]]
|
107
94
|
if dirs.compact.size > 1
|
data/lib/dapp/dapp.rb
CHANGED
@@ -91,7 +91,8 @@ module Dapp
|
|
91
91
|
if option_build_dir
|
92
92
|
Pathname.new(option_build_dir)
|
93
93
|
else
|
94
|
-
|
94
|
+
dir = File.join(self.class.home_dir, "builds", self.name)
|
95
|
+
Pathname.new(dir)
|
95
96
|
end.expand_path.tap(&:mkpath)
|
96
97
|
end
|
97
98
|
make_path(@build_path, *path)
|
@@ -127,20 +128,21 @@ module Dapp
|
|
127
128
|
end
|
128
129
|
|
129
130
|
def try_host_docker_login
|
130
|
-
return if options[:without_registry]
|
131
131
|
return unless option_repo
|
132
132
|
|
133
133
|
validate_repo_name!(option_repo)
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
elsif ENV.key?('CI_JOB_TOKEN')
|
139
|
-
login.call('gitlab-ci-token', ENV['CI_JOB_TOKEN'])
|
135
|
+
if self.class.options_with_docker_credentials?
|
136
|
+
username, password = self.class.docker_credentials
|
137
|
+
shellout!("#{host_docker} login -u '#{username}' -p '#{password}' '#{option_repo}'")
|
140
138
|
end
|
141
139
|
end
|
142
140
|
|
143
141
|
class << self
|
142
|
+
def home_dir
|
143
|
+
File.join(Dir.home, ".dapp")
|
144
|
+
end
|
145
|
+
|
144
146
|
def options
|
145
147
|
@options ||= {}
|
146
148
|
end
|
@@ -182,6 +184,14 @@ module Dapp
|
|
182
184
|
(options.key?(:registry_username) && options.key?(:registry_password)) || ENV.key?('CI_JOB_TOKEN')
|
183
185
|
end
|
184
186
|
|
187
|
+
def docker_credentials
|
188
|
+
if options.key?(:registry_username) && options.key?(:registry_password)
|
189
|
+
[options[:registry_username], options[:registry_password]]
|
190
|
+
elsif ENV.key?('CI_JOB_TOKEN')
|
191
|
+
['gitlab-ci-token', ENV['CI_JOB_TOKEN']]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
185
195
|
def host_docker_tmp_config_dir
|
186
196
|
@host_docker_tmp_config_dir ||= Dir.mktmpdir('dapp-', tmp_base_dir)
|
187
197
|
end
|
data/lib/dapp/dapp/deps/base.rb
CHANGED
@@ -12,7 +12,7 @@ module Dapp
|
|
12
12
|
@base_container ||= begin
|
13
13
|
is_container_exist = proc{shellout("#{host_docker} inspect #{base_container_name}").exitstatus.zero?}
|
14
14
|
if !is_container_exist.call
|
15
|
-
lock("dappdeps.container.#{base_container_name}", default_timeout: 120
|
15
|
+
lock("dappdeps.container.#{base_container_name}", default_timeout: 120) do
|
16
16
|
if !is_container_exist.call
|
17
17
|
log_secondary_process(t(code: 'process.base_container_creating', data: {name: base_container_name}), short: true) do
|
18
18
|
shellout!(
|
@@ -12,7 +12,7 @@ module Dapp
|
|
12
12
|
@gitartifact_container ||= begin
|
13
13
|
is_container_exist = proc{shellout("#{host_docker} inspect #{gitartifact_container_name}").exitstatus.zero?}
|
14
14
|
if !is_container_exist.call
|
15
|
-
lock("dappdeps.container.#{gitartifact_container_name}", default_timeout: 120
|
15
|
+
lock("dappdeps.container.#{gitartifact_container_name}", default_timeout: 120) do
|
16
16
|
if !is_container_exist.call
|
17
17
|
log_secondary_process(t(code: 'process.gitartifact_container_creating', data: {name: gitartifact_container_name}), short: true) do
|
18
18
|
shellout!(
|
@@ -12,7 +12,7 @@ module Dapp
|
|
12
12
|
@toolchain_container ||= begin
|
13
13
|
is_container_exist = proc {shellout("#{host_docker} inspect #{toolchain_container_name}").exitstatus.zero?}
|
14
14
|
if !is_container_exist.call
|
15
|
-
lock("dappdeps.container.#{toolchain_container_name}", default_timeout: 300
|
15
|
+
lock("dappdeps.container.#{toolchain_container_name}", default_timeout: 300) do
|
16
16
|
if !is_container_exist.call
|
17
17
|
log_secondary_process(t(code: 'process.toolchain_container_creating', data: {name: toolchain_container_name}), short: true) do
|
18
18
|
shellout!(
|
data/lib/dapp/dapp/lock.rb
CHANGED
@@ -1,31 +1,21 @@
|
|
1
1
|
module Dapp
|
2
2
|
class Dapp
|
3
3
|
module Lock
|
4
|
-
def
|
5
|
-
|
6
|
-
when :dapp
|
7
|
-
build_path.join('locks')
|
8
|
-
when :global
|
9
|
-
Pathname.new("/tmp/dapp.global.locks").tap do |p|
|
10
|
-
FileUtils.mkdir_p p.to_s
|
11
|
-
end
|
12
|
-
else
|
13
|
-
raise
|
14
|
-
end
|
4
|
+
def locks_dir
|
5
|
+
File.join(self.class.home_dir, "locks")
|
15
6
|
end
|
16
7
|
|
17
|
-
def _lock(name
|
8
|
+
def _lock(name)
|
18
9
|
@_locks ||= {}
|
19
|
-
@_locks[
|
20
|
-
@_locks[type][name] ||= ::Dapp::Dimg::Lock::File.new(lock_path(type), name)
|
10
|
+
@_locks[name] ||= ::Dapp::Dimg::Lock::File.new(locks_dir, name)
|
21
11
|
end
|
22
12
|
|
23
|
-
def lock(name, *_args, default_timeout: 300,
|
13
|
+
def lock(name, *_args, default_timeout: 300, **kwargs, &blk)
|
24
14
|
if dry_run?
|
25
15
|
yield if block_given?
|
26
16
|
else
|
27
17
|
timeout = options[:lock_timeout] || default_timeout
|
28
|
-
_lock(name
|
18
|
+
_lock(name).synchronize(
|
29
19
|
timeout: timeout,
|
30
20
|
on_wait: proc do |&do_wait|
|
31
21
|
log_secondary_process(
|
@@ -84,6 +84,10 @@ module Dapp
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def log_time
|
87
|
+
self.class.log_time
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.log_time
|
87
91
|
"#{DateTime.now.strftime('%Y-%m-%dT%T%z')} "
|
88
92
|
end
|
89
93
|
|
@@ -117,12 +121,6 @@ module Dapp
|
|
117
121
|
end
|
118
122
|
end
|
119
123
|
|
120
|
-
class << self
|
121
|
-
def included(base)
|
122
|
-
base.extend(self)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
124
|
def service_stream
|
127
125
|
@@service_stream ||= begin
|
128
126
|
fd = IO.sysopen("/tmp/dapp-service.log", "a")
|
data/lib/dapp/dapp/slug.rb
CHANGED
@@ -3,7 +3,7 @@ module Dapp
|
|
3
3
|
module Slug
|
4
4
|
def consistent_uniq_slugify(s)
|
5
5
|
if should_be_slugged?(s)
|
6
|
-
consistent_uniq_slug_reg =~ s.slugify.squeeze('--')
|
6
|
+
consistent_uniq_slug_reg =~ s.gsub("/", "-").slugify.squeeze('--')
|
7
7
|
[].tap do |slug|
|
8
8
|
slug << Regexp.last_match(1) unless Regexp.last_match(1).nil?
|
9
9
|
slug << MurmurHash3::V32.str_hexdigest(s)
|
@@ -64,7 +64,7 @@ module Dapp
|
|
64
64
|
@chefdk_container ||= begin
|
65
65
|
is_container_exist = proc{dimg.dapp.shellout("#{dimg.dapp.host_docker} inspect #{chefdk_container_name}").exitstatus.zero?}
|
66
66
|
if !is_container_exist.call
|
67
|
-
dimg.dapp.lock("dappdeps.container.#{chefdk_container_name}", default_timeout: 120
|
67
|
+
dimg.dapp.lock("dappdeps.container.#{chefdk_container_name}", default_timeout: 120) do
|
68
68
|
if !is_container_exist.call
|
69
69
|
dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.chefdk_container_creating', data: {name: chefdk_container_name}), short: true) do
|
70
70
|
dimg.dapp.shellout!(
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Dapp::Dimg::CLI
|
2
2
|
module Command
|
3
3
|
class Base < ::Dapp::CLI::Command::Base
|
4
|
+
option :build_dir,
|
5
|
+
long: "--build-dir PATH",
|
6
|
+
description: "Directory where build cache stored ($HOME/.dapp/builds/<dapp name> by default)."
|
7
|
+
|
4
8
|
def run(argv = ARGV)
|
5
9
|
self.class.parse_options(self, argv)
|
6
10
|
run_dapp_command(run_method, options: cli_options(dimgs_patterns: cli_arguments))
|
@@ -59,7 +59,9 @@ BANNER
|
|
59
59
|
def run(argv = ARGV)
|
60
60
|
self.class.parse_options(self, argv)
|
61
61
|
repo = self.class.required_argument(self, 'repo')
|
62
|
-
run_dapp_command(run_method,
|
62
|
+
run_dapp_command(run_method,
|
63
|
+
options: cli_options(dimgs_patterns: cli_arguments, repo: repo),
|
64
|
+
try_host_docker_login: true)
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
@@ -25,7 +25,9 @@ BANNER
|
|
25
25
|
def run(argv = ARGV)
|
26
26
|
self.class.parse_options(self, argv)
|
27
27
|
repo = self.class.required_argument(self, 'repo')
|
28
|
-
run_dapp_command(:stages_pull,
|
28
|
+
run_dapp_command(:stages_pull,
|
29
|
+
options: cli_options(dimgs_patterns: cli_arguments, repo: repo),
|
30
|
+
try_host_docker_login: true)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -21,7 +21,9 @@ BANNER
|
|
21
21
|
def run(argv = ARGV)
|
22
22
|
self.class.parse_options(self, argv)
|
23
23
|
repo = self.class.required_argument(self, 'repo')
|
24
|
-
run_dapp_command(:stages_push,
|
24
|
+
run_dapp_command(:stages_push,
|
25
|
+
options: cli_options(dimgs_patterns: cli_arguments, repo: repo),
|
26
|
+
try_host_docker_login: true)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -24,7 +24,7 @@ module Dapp
|
|
24
24
|
|
25
25
|
def artifact(&blk)
|
26
26
|
pass_to(ArtifactGroup.new(dapp: dapp), :clone_to_artifact).tap do |artifact_group|
|
27
|
-
|
27
|
+
_context_artifact_groups << directive_eval(artifact_group, &blk)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -73,8 +73,12 @@ module Dapp
|
|
73
73
|
@_artifact_groups ||= []
|
74
74
|
end
|
75
75
|
|
76
|
+
def _context_artifact_groups
|
77
|
+
@_context_artifact_groups ||= []
|
78
|
+
end
|
79
|
+
|
76
80
|
def _artifact
|
77
|
-
_artifact_groups.map(&:_export).flatten
|
81
|
+
[_artifact_groups, _context_artifact_groups].flatten.map(&:_export).flatten
|
78
82
|
end
|
79
83
|
|
80
84
|
[:before, :after].each do |order|
|
@@ -39,11 +39,20 @@ module Dapp
|
|
39
39
|
protected
|
40
40
|
|
41
41
|
def before_dimg_eval(dimg)
|
42
|
-
|
42
|
+
before_eval_base(dimg)
|
43
43
|
end
|
44
44
|
|
45
45
|
def before_dimg_group_eval(dimg_group)
|
46
|
-
|
46
|
+
before_eval_base(dimg_group)
|
47
|
+
end
|
48
|
+
|
49
|
+
def before_eval_base(obj)
|
50
|
+
pass_to(obj)
|
51
|
+
pass_context_artifact_groups_to(obj)
|
52
|
+
end
|
53
|
+
|
54
|
+
def pass_context_artifact_groups_to(obj)
|
55
|
+
obj.instance_variable_set(:@_artifact_groups, [obj._artifact_groups, clone_variable(_context_artifact_groups)].flatten)
|
47
56
|
end
|
48
57
|
|
49
58
|
def check_dimg_directive_order(directive)
|
@@ -95,10 +95,8 @@ module Dapp
|
|
95
95
|
|
96
96
|
def check_user_containers!(images_ids)
|
97
97
|
return if images_ids.empty?
|
98
|
-
|
99
|
-
|
100
|
-
raise Error::Command, code: :user_containers_detected, data: { ids: res.stdout.strip } if res && !res.stdout.strip.empty? && !dry_run?
|
101
|
-
end
|
98
|
+
run_command(%(#{host_docker} ps -a -q #{images_ids.uniq.map { |image_id| "--filter=ancestor=#{image_id}" }.join(' ')} --no-trunc)).tap do |res|
|
99
|
+
raise Error::Command, code: :user_containers_detected, data: { ids: res.stdout.strip } if res && !res.stdout.strip.empty? && !dry_run?
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
@@ -150,6 +148,10 @@ module Dapp
|
|
150
148
|
log_step_with_indent(:'proper cache', &blk)
|
151
149
|
end
|
152
150
|
|
151
|
+
def log_proper_repo_cache(&blk)
|
152
|
+
log_step_with_indent(:'proper repo cache', &blk)
|
153
|
+
end
|
154
|
+
|
153
155
|
def one_dimg!
|
154
156
|
return if build_configs.one?
|
155
157
|
raise Error::Command, code: :command_unexpected_dimgs_number, data: { dimgs_names: build_configs.map(&:_name).join(' ') }
|
@@ -21,9 +21,7 @@ module Dapp
|
|
21
21
|
def proper_cache
|
22
22
|
log_proper_cache do
|
23
23
|
lock("#{name}.images") do
|
24
|
-
|
25
|
-
remove_project_images(dapp_project_images_ids.select { |image_id| !actual_cache_project_images_ids.include?(image_id) })
|
26
|
-
end
|
24
|
+
remove_project_images(dapp_project_images_ids.select { |image_id| !actual_cache_project_images_ids.include?(image_id) })
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -38,15 +36,15 @@ module Dapp
|
|
38
36
|
end
|
39
37
|
|
40
38
|
def stages_cleanup_by_repo
|
41
|
-
|
42
|
-
|
39
|
+
log_proper_repo_cache do
|
40
|
+
lock("#{name}.images") do
|
41
|
+
registry = dimg_registry(option_repo)
|
42
|
+
repo_dimgs = repo_detailed_dimgs_images(registry)
|
43
43
|
|
44
|
-
lock("#{name}.images") do
|
45
|
-
log_step_with_indent(name) do
|
46
44
|
dapp_project_dangling_images_flush
|
47
45
|
|
48
|
-
|
49
|
-
|
46
|
+
_, dimgstages = dapp_project_images.partition { |image| repo_dimgs.any? { |dimg| dimg[:id] == image[:id] } }
|
47
|
+
repo_dimgs.each { |repo_dimg| except_dapp_project_image_with_parents(repo_dimg[:parent], dimgstages) }
|
50
48
|
|
51
49
|
# Удаление только образов старше 2ч
|
52
50
|
dimgstages.delete_if do |dimgstage|
|
@@ -8,37 +8,25 @@ module Dapp
|
|
8
8
|
|
9
9
|
def repo_dimgs_images(registry)
|
10
10
|
[].tap do |dimgs_images|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
dimgs_images.concat(tags_to_repo_images(registry, tags, dimg_name))
|
19
|
-
end
|
11
|
+
{}.tap do |dimgs_tags|
|
12
|
+
dimgs_tags[nil] = registry.nameless_dimg_tags
|
13
|
+
dimgs_names.each do |dimg_name|
|
14
|
+
dimgs_tags[dimg_name] = registry.dimg_tags(dimg_name)
|
15
|
+
end unless nameless_dimg?
|
16
|
+
end.each do |dimg_name, tags|
|
17
|
+
dimgs_images.concat(tags_to_repo_images(registry, tags, dimg_name))
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
22
|
def repo_dimgstages_images(registry)
|
25
|
-
|
26
|
-
tags_to_repo_images(registry, registry.dimgstages_tags)
|
27
|
-
end
|
23
|
+
tags_to_repo_images(registry, registry.dimgstages_tags)
|
28
24
|
end
|
29
25
|
|
30
26
|
def tags_to_repo_images(registry, tags, dimg_name = nil)
|
31
27
|
tags.map { |tag| repo_image_format(registry, tag, dimg_name) }.compact
|
32
28
|
end
|
33
29
|
|
34
|
-
def with_registry_wrapper
|
35
|
-
yield
|
36
|
-
rescue Exception::Registry => e
|
37
|
-
raise unless e.net_status[:code] == :no_such_dimg
|
38
|
-
log_warning(desc: { code: :dimg_not_found_in_registry })
|
39
|
-
[]
|
40
|
-
end
|
41
|
-
|
42
30
|
def repo_image_format(registry, tag, dimg_name = nil)
|
43
31
|
if (id = registry.image_id(tag, dimg_name)).nil?
|
44
32
|
log_warning(desc: { code: 'tag_ignored', data: { tag: tag } })
|
@@ -6,11 +6,9 @@ module Dapp
|
|
6
6
|
module FlushLocal
|
7
7
|
def stages_flush_local
|
8
8
|
lock("#{name}.images") do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
remove_project_images(dapp_project_images_ids)
|
13
|
-
end
|
9
|
+
dapp_project_containers_flush
|
10
|
+
dapp_project_dangling_images_flush
|
11
|
+
remove_project_images(dapp_project_images_ids)
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -11,8 +11,10 @@ module Dapp
|
|
11
11
|
expected_hostname_url = [protocol, expected_hostname].join('://')
|
12
12
|
return Dimg.new(repo, expected_hostname_url, expected_repo_suffix) if hostname_exist?(expected_hostname_url)
|
13
13
|
end
|
14
|
+
raise Error::Registry, code: :registry_not_available, data: { registry: repo }
|
15
|
+
else
|
16
|
+
Default.new(repo, expected_repo_suffix)
|
14
17
|
end
|
15
|
-
Default.new(repo, File.join(*[expected_hostname, expected_repo_suffix].compact))
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.repo_name_format
|
@@ -19,9 +19,6 @@ module Dapp
|
|
19
19
|
|
20
20
|
def tags
|
21
21
|
api_request(repo_suffix, 'tags/list')['tags'] || []
|
22
|
-
rescue Error::Registry => e
|
23
|
-
raise Exception::Registry, code: :no_such_dimg, data: { registry: api_url } if e.net_status[:code] == :page_not_found
|
24
|
-
raise
|
25
22
|
end
|
26
23
|
|
27
24
|
def image_id(tag)
|
@@ -34,15 +34,19 @@ module Dapp
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def authorization_auth
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
r =
|
37
|
+
if ::Dapp::Dapp.options_with_docker_credentials?
|
38
|
+
Base64.strict_encode64(::Dapp::Dapp.docker_credentials.join(':'))
|
39
|
+
else
|
40
|
+
auths = auths_section_from_docker_config
|
41
|
+
r = repo
|
42
|
+
loop do
|
43
|
+
break unless r.include?('/') && !auths.keys.any? { |auth| auth.start_with?(r) }
|
44
|
+
r = chomp_name(r)
|
45
|
+
end
|
46
|
+
credential = (auths[r] || auths.find { |repo, _| repo == r })
|
47
|
+
user_not_authorized! if credential.nil?
|
48
|
+
credential['auth']
|
42
49
|
end
|
43
|
-
credential = (auths[r] || auths.find { |repo, _| repo == r })
|
44
|
-
user_not_authorized! if credential.nil?
|
45
|
-
credential['auth']
|
46
50
|
end
|
47
51
|
|
48
52
|
def auths_section_from_docker_config
|
@@ -8,15 +8,19 @@ module Dapp
|
|
8
8
|
|
9
9
|
def dimg_tags(dimg_name)
|
10
10
|
with_repo_suffix(dimg_name.to_s) { tags }
|
11
|
-
rescue Exception::Registry => e
|
12
|
-
raise unless e.net_status[:code] == :no_such_dimg
|
13
|
-
[]
|
14
11
|
end
|
15
12
|
|
16
13
|
def nameless_dimg_tags
|
17
14
|
tags.select { |tag| !tag.start_with?('dimgstage') }
|
18
15
|
end
|
19
16
|
|
17
|
+
def tags
|
18
|
+
super
|
19
|
+
rescue Error::Registry => e
|
20
|
+
raise unless e.net_status[:code] == :page_not_found
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
|
20
24
|
def image_id(tag, extra_repo_suffix = nil)
|
21
25
|
with_repo_suffix(extra_repo_suffix.to_s) { super(tag) }
|
22
26
|
end
|
data/lib/dapp/dimg/lock/file.rb
CHANGED
@@ -10,18 +10,18 @@ module Dapp
|
|
10
10
|
end
|
11
11
|
end # << self
|
12
12
|
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :locks_path
|
14
14
|
|
15
|
-
def initialize(
|
15
|
+
def initialize(locks_path, name)
|
16
16
|
super(name)
|
17
17
|
|
18
|
-
@
|
18
|
+
@locks_path = Pathname.new(locks_path).tap(&:mkpath)
|
19
19
|
end
|
20
20
|
|
21
21
|
protected
|
22
22
|
|
23
23
|
def lock_file_path
|
24
|
-
|
24
|
+
locks_path.join(MurmurHash3::V32.str_hexdigest(name))
|
25
25
|
end
|
26
26
|
|
27
27
|
def _do_lock(timeout, on_wait, readonly)
|
@@ -83,26 +83,22 @@ BANNER
|
|
83
83
|
|
84
84
|
def run(argv = ARGV)
|
85
85
|
self.class.parse_options(self, argv)
|
86
|
-
run_dapp_command(run_method, options: cli_options)
|
87
|
-
end
|
88
86
|
|
89
|
-
|
90
|
-
|
91
|
-
yield if block_given?
|
87
|
+
options = cli_options
|
88
|
+
options[:tag] = [*options.delete(:tag), *options.delete(:image_version)]
|
92
89
|
|
93
|
-
|
94
|
-
# значение по умолчанию из объекта dapp: dapp.name
|
90
|
+
run_dapp_command(nil, options: options) do |dapp|
|
95
91
|
repo = if not cli_arguments[0].nil?
|
96
92
|
self.class.required_argument(self, 'repo')
|
97
93
|
else
|
98
94
|
dapp.name
|
99
95
|
end
|
96
|
+
|
100
97
|
dapp.options[:repo] = repo
|
101
98
|
|
102
|
-
dapp.
|
103
|
-
end
|
99
|
+
dapp.public_send(run_method)
|
100
|
+
end
|
104
101
|
end
|
105
|
-
|
106
102
|
end
|
107
103
|
end
|
108
104
|
end
|
@@ -56,24 +56,19 @@ BANNER
|
|
56
56
|
|
57
57
|
def run(argv = ARGV)
|
58
58
|
self.class.parse_options(self, argv)
|
59
|
-
run_dapp_command(run_method, options: cli_options, log_running_time: false)
|
60
|
-
end
|
61
|
-
|
62
|
-
def before_dapp_run_command(dapp, &blk)
|
63
|
-
super(dapp) do
|
64
|
-
yield if block_given?
|
65
59
|
|
66
|
-
|
67
|
-
# значение по умолчанию из объекта dapp: dapp.name
|
60
|
+
run_dapp_command(nil, options: cli_options, log_running_time: false) do |dapp|
|
68
61
|
repo = if not cli_arguments[0].nil?
|
69
62
|
self.class.required_argument(self, 'repo')
|
70
63
|
else
|
71
64
|
dapp.name
|
72
65
|
end
|
66
|
+
|
73
67
|
dapp.options[:repo] = repo
|
74
|
-
end # super
|
75
|
-
end
|
76
68
|
|
69
|
+
dapp.public_send(run_method)
|
70
|
+
end
|
71
|
+
end
|
77
72
|
end
|
78
73
|
end
|
79
74
|
end
|
@@ -65,24 +65,18 @@ BANNER
|
|
65
65
|
|
66
66
|
def run(argv = ARGV)
|
67
67
|
self.class.parse_options(self, argv)
|
68
|
-
run_dapp_command(
|
69
|
-
end
|
70
|
-
|
71
|
-
def before_dapp_run_command(dapp, &blk)
|
72
|
-
super(dapp) do
|
73
|
-
yield if block_given?
|
74
|
-
|
75
|
-
# Опция repo определяется в данном хуке, чтобы установить
|
76
|
-
# значение по умолчанию из объекта dapp: dapp.name
|
68
|
+
run_dapp_command(nil, options: cli_options, log_running_time: false) do |dapp|
|
77
69
|
repo = if not cli_arguments[0].nil?
|
78
70
|
self.class.required_argument(self, 'repo')
|
79
71
|
else
|
80
72
|
dapp.name
|
81
73
|
end
|
74
|
+
|
82
75
|
dapp.options[:repo] = repo
|
83
|
-
end # super
|
84
|
-
end
|
85
76
|
|
77
|
+
dapp.public_send(run_method)
|
78
|
+
end
|
79
|
+
end
|
86
80
|
end
|
87
81
|
end
|
88
82
|
end
|
@@ -31,7 +31,9 @@ module Dapp
|
|
31
31
|
kube_check_helm_chart!
|
32
32
|
|
33
33
|
repo = option_repo
|
34
|
-
|
34
|
+
|
35
|
+
docker_tag = options[:docker_tag]
|
36
|
+
docker_tag = consistent_uniq_slugify(docker_tag) if docker_tag
|
35
37
|
|
36
38
|
with_kube_tmp_lint_chart_dir do
|
37
39
|
kube_copy_chart
|
data/lib/dapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|