dapp 0.22.6 → 0.22.7
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 +9 -5
- data/config/en/common.yml +2 -0
- data/config/en/net_status.yml +9 -12
- data/lib/dapp.rb +12 -47
- data/lib/dapp/cli/command/options/tag.rb +39 -0
- data/lib/dapp/config/directive/base.rb +2 -1
- data/lib/dapp/dapp.rb +6 -9
- data/lib/dapp/dapp/command/common.rb +9 -4
- data/lib/dapp/dapp/logging/i18n.rb +5 -1
- data/lib/dapp/dapp/logging/process.rb +2 -2
- data/lib/dapp/deployment/config/config.rb +5 -5
- data/lib/dapp/deployment/config/directive/expose.rb +1 -1
- data/lib/dapp/deployment/config/directive/namespace/instance_methods.rb +1 -1
- data/lib/dapp/deployment/error/app.rb +1 -1
- data/lib/dapp/deployment/error/{base.rb → default.rb} +1 -1
- data/lib/dapp/deployment/error/deployment.rb +1 -1
- data/lib/dapp/deployment/error/kubernetes.rb +1 -1
- data/lib/dapp/deployment/kubernetes.rb +3 -3
- data/lib/dapp/deployment/kubernetes/error.rb +4 -4
- data/lib/dapp/deployment/secret.rb +1 -1
- data/lib/dapp/dimg/cli/command/dimg.rb +2 -1
- data/lib/dapp/dimg/cli/command/dimg/build_context/export.rb +5 -0
- data/lib/dapp/dimg/cli/command/dimg/flush_local.rb +24 -0
- data/lib/dapp/dimg/cli/command/dimg/push.rb +2 -26
- data/lib/dapp/dimg/cli/command/dimg/stages/base.rb +2 -2
- data/lib/dapp/dimg/cli/command/dimg/tag.rb +11 -4
- data/lib/dapp/dimg/config/config.rb +1 -1
- data/lib/dapp/dimg/config/directive/artifact.rb +5 -5
- data/lib/dapp/dimg/config/directive/artifact_base.rb +5 -5
- data/lib/dapp/dimg/config/directive/dimg/instance_methods.rb +1 -1
- data/lib/dapp/dimg/config/directive/dimg/validation.rb +11 -13
- data/lib/dapp/dimg/config/directive/docker/artifact.rb +1 -1
- data/lib/dapp/dimg/config/directive/docker/base.rb +1 -1
- data/lib/dapp/dimg/config/directive/git_artifact_local.rb +19 -3
- data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +3 -1
- data/lib/dapp/dimg/config/directive/mount.rb +3 -3
- data/lib/dapp/dimg/dapp/command/build.rb +1 -1
- data/lib/dapp/dimg/dapp/command/build_context/export.rb +17 -13
- data/lib/dapp/dimg/dapp/command/build_context/import.rb +24 -17
- data/lib/dapp/dimg/dapp/command/cleanup_repo.rb +26 -33
- data/lib/dapp/dimg/dapp/command/common.rb +53 -56
- data/lib/dapp/dimg/dapp/command/flush_local.rb +18 -0
- data/lib/dapp/dimg/dapp/command/mrproper.rb +1 -1
- data/lib/dapp/dimg/dapp/command/push.rb +2 -8
- data/lib/dapp/dimg/dapp/command/spush.rb +2 -4
- data/lib/dapp/dimg/dapp/command/stages/cleanup_local.rb +41 -46
- data/lib/dapp/dimg/dapp/command/stages/cleanup_repo.rb +35 -39
- data/lib/dapp/dimg/dapp/command/stages/common.rb +13 -3
- data/lib/dapp/dimg/dapp/command/stages/flush_local.rb +1 -3
- data/lib/dapp/dimg/dapp/command/stages/flush_repo.rb +3 -3
- data/lib/dapp/dimg/dapp/command/stages/pull.rb +2 -12
- data/lib/dapp/dimg/dapp/command/stages/push.rb +2 -8
- data/lib/dapp/dimg/dapp/command/tag.rb +3 -6
- data/lib/dapp/dimg/dapp/dapp.rb +1 -0
- data/lib/dapp/dimg/dapp/dappfile.rb +11 -1
- data/lib/dapp/dimg/dimg.rb +39 -31
- data/lib/dapp/dimg/error/build.rb +1 -1
- data/lib/dapp/dimg/error/chef.rb +1 -5
- data/lib/dapp/dimg/error/{command.rb → default.rb} +1 -1
- data/lib/dapp/dimg/error/dimg.rb +1 -1
- data/lib/dapp/dimg/error/lock.rb +1 -1
- data/lib/dapp/dimg/error/registry.rb +1 -1
- data/lib/dapp/dimg/error/rugged.rb +1 -1
- data/lib/dapp/dimg/error/tar_writer.rb +1 -1
- data/lib/dapp/dimg/git_artifact.rb +3 -1
- data/lib/dapp/dimg/image/argument.rb +3 -1
- data/lib/dapp/dimg/image/dimg.rb +15 -0
- data/lib/dapp/dimg/image/stage.rb +0 -9
- data/lib/dapp/error/base.rb +1 -5
- data/lib/dapp/error/command.rb +5 -0
- data/lib/dapp/error/config.rb +5 -0
- data/lib/dapp/error/dapp.rb +1 -1
- data/lib/dapp/error/dappfile.rb +1 -1
- data/lib/dapp/error/default.rb +11 -0
- data/lib/dapp/error/mod/user.rb +11 -0
- data/lib/dapp/error/shellout.rb +1 -1
- data/lib/dapp/exception/base.rb +1 -1
- data/lib/dapp/helper/yaml.rb +3 -2
- data/lib/dapp/kube/cli/command/kube/deploy.rb +2 -26
- data/lib/dapp/kube/cli/command/kube/lint.rb +1 -26
- data/lib/dapp/kube/cli/command/kube/render.rb +2 -26
- data/lib/dapp/kube/cli/command/kube/secret_key_generate.rb +2 -2
- data/lib/dapp/kube/dapp/command/common.rb +19 -23
- data/lib/dapp/kube/dapp/command/deploy.rb +16 -9
- data/lib/dapp/kube/dapp/command/dismiss.rb +1 -1
- data/lib/dapp/kube/dapp/command/lint.rb +4 -10
- data/lib/dapp/kube/dapp/command/minikube_setup.rb +12 -18
- data/lib/dapp/kube/dapp/command/secret_edit.rb +2 -2
- data/lib/dapp/kube/error/{command.rb → default.rb} +1 -1
- data/lib/dapp/kube/error/kubernetes.rb +1 -1
- data/lib/dapp/kube/helm/release.rb +7 -33
- data/lib/dapp/kube/helm/values.rb +140 -0
- data/lib/dapp/kube/kubernetes/client.rb +9 -10
- data/lib/dapp/kube/kubernetes/client/error.rb +14 -8
- data/lib/dapp/kube/kubernetes/error.rb +15 -0
- data/lib/dapp/kube/kubernetes/manager/deployment.rb +2 -2
- data/lib/dapp/kube/secret.rb +1 -1
- data/lib/dapp/version.rb +1 -1
- metadata +15 -11
- data/lib/dapp/config/error/config.rb +0 -7
- data/lib/dapp/deployment/error/command.rb +0 -7
- data/lib/dapp/deployment/error/config.rb +0 -7
- data/lib/dapp/dimg/error/base.rb +0 -7
- data/lib/dapp/dimg/error/config.rb +0 -7
- data/lib/dapp/kube/error/base.rb +0 -11
|
@@ -14,7 +14,7 @@ module Dapp
|
|
|
14
14
|
def export_build_context_image_tar
|
|
15
15
|
lock("#{name}.images", readonly: true) do
|
|
16
16
|
context_images_names = build_configs.map do |config|
|
|
17
|
-
Dimg.new(config: config, dapp: self).tagged_images.map(&:name)
|
|
17
|
+
Dimg.new(config: config, dapp: self, ignore_git_fetch: true).tagged_images.map(&:name)
|
|
18
18
|
end.flatten
|
|
19
19
|
|
|
20
20
|
log_secondary_process(:images, short: true) do
|
|
@@ -25,18 +25,22 @@ module Dapp
|
|
|
25
25
|
|
|
26
26
|
def export_build_context_build_tar
|
|
27
27
|
log_secondary_process(:build_dir, short: true) do
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
if !!options[:use_system_tar]
|
|
29
|
+
shellout!("tar -C #{build_path} -cf #{build_context_build_tar} .")
|
|
30
|
+
else
|
|
31
|
+
tar_write(build_context_build_tar) do |tar|
|
|
32
|
+
Dir.glob(File.join(build_path, '**/*'), File::FNM_DOTMATCH).each do |path|
|
|
33
|
+
archive_file_path = path
|
|
34
|
+
.reverse
|
|
35
|
+
.chomp(build_path.to_s.reverse)
|
|
36
|
+
.chomp('/')
|
|
37
|
+
.reverse
|
|
38
|
+
if File.directory?(path)
|
|
39
|
+
tar.mkdir archive_file_path, File.stat(path).mode
|
|
40
|
+
else
|
|
41
|
+
tar.add_file archive_file_path, File.stat(path).mode do |tf|
|
|
42
|
+
tf.write File.read(path)
|
|
43
|
+
end
|
|
40
44
|
end
|
|
41
45
|
end
|
|
42
46
|
end
|
|
@@ -5,8 +5,8 @@ module Dapp
|
|
|
5
5
|
module BuildContext
|
|
6
6
|
module Import
|
|
7
7
|
def build_context_import
|
|
8
|
-
raise Error::Command, code: :context_directory_not_found,
|
|
9
|
-
|
|
8
|
+
raise ::Dapp::Error::Command, code: :context_directory_not_found,
|
|
9
|
+
data: { path: build_context_path } unless build_context_path.exist?
|
|
10
10
|
|
|
11
11
|
log_process(:'import context') do
|
|
12
12
|
import_build_context_build_tar
|
|
@@ -16,7 +16,7 @@ module Dapp
|
|
|
16
16
|
|
|
17
17
|
def import_build_context_image_tar
|
|
18
18
|
if build_context_images_tar.exist?
|
|
19
|
-
log_secondary_process(:images
|
|
19
|
+
log_secondary_process(:images) do
|
|
20
20
|
lock("#{name}.images") do
|
|
21
21
|
Image::Docker.load!(build_context_images_tar, verbose: true, quiet: log_quiet?)
|
|
22
22
|
end unless dry_run?
|
|
@@ -29,22 +29,29 @@ module Dapp
|
|
|
29
29
|
def import_build_context_build_tar
|
|
30
30
|
if build_context_build_tar.exist?
|
|
31
31
|
log_secondary_process(:build_dir, short: true) do
|
|
32
|
-
|
|
32
|
+
unless dry_run?
|
|
33
|
+
store_current_build_dir
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if !!options[:use_system_tar]
|
|
36
|
+
FileUtils.mkpath build_path
|
|
37
|
+
shellout!("tar -xf #{build_context_build_tar} -C #{build_path}")
|
|
38
|
+
else
|
|
39
|
+
tar_read(build_context_build_tar) do |tar|
|
|
40
|
+
tar.each_entry do |entry|
|
|
41
|
+
header = entry.header
|
|
42
|
+
path = File.join(build_path, entry.full_name)
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if entry.directory?
|
|
45
|
+
FileUtils.mkpath path, :mode => entry.header.mode
|
|
46
|
+
else
|
|
47
|
+
FileUtils.mkpath File.dirname(path)
|
|
48
|
+
File.write(path, entry.read)
|
|
49
|
+
File.chmod(header.mode, path)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
45
52
|
end
|
|
46
53
|
end
|
|
47
|
-
end
|
|
54
|
+
end
|
|
48
55
|
end
|
|
49
56
|
else
|
|
50
57
|
log_warning(desc: { code: :context_archive_not_found, data: { path: build_context_build_tar } })
|
|
@@ -53,8 +60,8 @@ module Dapp
|
|
|
53
60
|
|
|
54
61
|
def store_current_build_dir
|
|
55
62
|
return if build_path_empty?
|
|
56
|
-
raise Error::Command, code: :stored_build_dir_already_exist,
|
|
57
|
-
|
|
63
|
+
raise ::Dapp::Error::Command, code: :stored_build_dir_already_exist,
|
|
64
|
+
data: { path: "#{build_path}.old" } if File.exist?("#{build_path}.old")
|
|
58
65
|
FileUtils.mv(build_path, "#{build_path}.old")
|
|
59
66
|
end
|
|
60
67
|
|
|
@@ -8,16 +8,18 @@ module Dapp
|
|
|
8
8
|
|
|
9
9
|
def cleanup_repo
|
|
10
10
|
lock_repo(repo = option_repo) do
|
|
11
|
-
|
|
11
|
+
log_step_with_indent(repo) do
|
|
12
|
+
registry = dimg_registry(repo)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
cleanup_repo_by_nonexistent_git_primitive(registry, actual_detailed_dimgs_images_by_scheme(registry))
|
|
15
|
+
cleanup_repo_by_policies(registry, actual_detailed_dimgs_images_by_scheme(registry))
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
begin
|
|
18
|
+
repo_dimgs = repo_dimgs_images(registry)
|
|
19
|
+
repo_dimgstages = repo_dimgstages_images(registry)
|
|
20
|
+
repo_dimgstages_cleanup(registry, repo_dimgs, repo_dimgstages)
|
|
21
|
+
end if with_stages?
|
|
22
|
+
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
|
|
@@ -84,26 +86,25 @@ module Dapp
|
|
|
84
86
|
dimg
|
|
85
87
|
end
|
|
86
88
|
end
|
|
87
|
-
end
|
|
88
|
-
.sort_by { |dimg| dimg[:created_at] }
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
end
|
|
89
|
+
end.tap do |detailed_dimgs_images|
|
|
90
|
+
sorted_detailed_dimgs_images = detailed_dimgs_images.sort_by { |dimg| dimg[:created_at] }
|
|
91
|
+
expired_dimgs_images, not_expired_dimgs_images = sorted_detailed_dimgs_images.partition do |dimg_image|
|
|
92
|
+
dimg_image[:created_at] < DATE_POLICY
|
|
93
|
+
end
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
log_step_with_indent(:"date policy (before #{DateTime.strptime(DATE_POLICY.to_s, '%s')})") do
|
|
96
|
+
expired_dimgs_images.each { |dimg| delete_repo_image(registry, dimg) }
|
|
97
|
+
end
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
end
|
|
99
|
+
{}.tap do |images_by_dimg|
|
|
100
|
+
not_expired_dimgs_images.each { |dimg| (images_by_dimg[dimg[:dimg]] ||= []) << dimg }
|
|
101
|
+
images_by_dimg.each do |dimg, images|
|
|
102
|
+
log_step_with_indent(:"limit policy (> #{GIT_TAGS_LIMIT_POLICY}) (`#{dimg}`)") do
|
|
103
|
+
images[GIT_TAGS_LIMIT_POLICY..-1].each { |dimg| delete_repo_image(registry, dimg) }
|
|
104
|
+
end unless images[GIT_TAGS_LIMIT_POLICY..-1].nil?
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
+
end
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
def git_tag_by_consistent_git_tag(consistent_git_tag)
|
|
@@ -114,14 +115,6 @@ module Dapp
|
|
|
114
115
|
@git_consistent_tags ||= git_local_repo.tags.map { |t| [consistent_uniq_slugify(t), t] }.to_h
|
|
115
116
|
end
|
|
116
117
|
|
|
117
|
-
def repo_detailed_dimgs_images(registry)
|
|
118
|
-
repo_dimgs_images(registry).each do |dimg|
|
|
119
|
-
image_history = registry.image_history(dimg[:tag], dimg[:dimg])
|
|
120
|
-
dimg[:parent] = image_history['container_config']['Image']
|
|
121
|
-
dimg[:labels] = image_history['config']['Labels']
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
118
|
def deployed_docker_images
|
|
126
119
|
return [] if without_kube?
|
|
127
120
|
|
|
@@ -140,7 +133,7 @@ module Dapp
|
|
|
140
133
|
begin
|
|
141
134
|
namespaces = client.namespace_list(excon_parameters: {:connect_timeout => 30})
|
|
142
135
|
rescue Excon::Error::Timeout
|
|
143
|
-
raise
|
|
136
|
+
raise ::Dapp::Error::Default, code: :kube_connect_timeout
|
|
144
137
|
end
|
|
145
138
|
|
|
146
139
|
# get images from containers from pods from all namespaces.
|
|
@@ -5,74 +5,60 @@ module Dapp
|
|
|
5
5
|
module Common
|
|
6
6
|
protected
|
|
7
7
|
|
|
8
|
-
def
|
|
9
|
-
|
|
8
|
+
def dapp_project_dimgstages
|
|
9
|
+
dapp_project_images.select { |image| image[:dimgstage] }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
dapp_project_images.find { |img| [img[:name], img[:id]].include?(image_id_or_name) }[:inspect] ||= begin
|
|
16
|
-
cmd = shellout!("#{::Dapp::Dapp.host_docker} inspect --type=image #{image_id_or_name}")
|
|
17
|
-
Array(JSON.parse(cmd.stdout.strip)).first || {}
|
|
18
|
-
end
|
|
12
|
+
def dapp_project_dimgs
|
|
13
|
+
dapp_project_images.select { |image| image[:dimg] }
|
|
19
14
|
end
|
|
20
15
|
|
|
21
|
-
def
|
|
22
|
-
dapp_project_images.
|
|
16
|
+
def dapp_project_image_by_id(image_id)
|
|
17
|
+
dapp_project_images.find { |image| image[:id] == image_id }
|
|
23
18
|
end
|
|
24
19
|
|
|
25
|
-
def
|
|
26
|
-
|
|
20
|
+
def dapp_project_image_labels(image)
|
|
21
|
+
dapp_project_image_inspect(image)['Config']['Labels']
|
|
27
22
|
end
|
|
28
23
|
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
image[:name] == '<none>:<none>'
|
|
24
|
+
def dapp_project_image_inspect(image)
|
|
25
|
+
image[:inspect] ||= begin
|
|
26
|
+
cmd = shellout!("#{::Dapp::Dapp.host_docker} inspect --type=image #{image[:id]}")
|
|
27
|
+
Array(JSON.parse(cmd.stdout.strip)).first || {}
|
|
28
|
+
end
|
|
35
29
|
end
|
|
36
30
|
|
|
37
31
|
def dapp_project_images
|
|
38
32
|
@dapp_project_images ||= [].tap do |images|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.lines
|
|
42
|
-
.map(&:strip)
|
|
43
|
-
.each do |l|
|
|
44
|
-
id, name, created_at = l.split(';')
|
|
45
|
-
images << { id: id, name: name, created_at: Time.parse(created_at) }
|
|
46
|
-
end
|
|
33
|
+
images.concat prepare_docker_images(stage_cache, dimgstage: true)
|
|
34
|
+
images.concat prepare_docker_images('-f label=dapp-dimg=true', dimg: true)
|
|
47
35
|
end
|
|
48
36
|
end
|
|
49
37
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
def prepare_docker_images(extra_args, **extra_fields)
|
|
39
|
+
[].tap do |images|
|
|
40
|
+
shellout!(%(#{host_docker} images --format="{{.ID}};{{.Repository}}:{{.Tag}};{{.CreatedAt}}" -f "dangling=false" -f "label=dapp=#{name}" --no-trunc #{extra_args}))
|
|
41
|
+
.stdout
|
|
42
|
+
.lines
|
|
43
|
+
.map(&:strip)
|
|
44
|
+
.each do |l|
|
|
45
|
+
id, name, created_at = l.split(';')
|
|
46
|
+
images << { id: id, name: name, created_at: Time.parse(created_at), **extra_fields }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
56
49
|
end
|
|
57
50
|
|
|
58
|
-
def remove_project_images(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
remove_images(images_ids_or_names)
|
|
51
|
+
def remove_project_images(project_images)
|
|
52
|
+
update_project_images_cache(project_images)
|
|
53
|
+
remove_images(project_images_to_delete(project_images))
|
|
62
54
|
end
|
|
63
55
|
|
|
64
|
-
def
|
|
65
|
-
dapp_project_images.delete_if
|
|
66
|
-
images_ids_or_names.include?(img[:id]) || images_ids_or_names.include?(img[:name])
|
|
67
|
-
end
|
|
56
|
+
def update_project_images_cache(project_images)
|
|
57
|
+
dapp_project_images.delete_if { |image| project_images.include?(image) }
|
|
68
58
|
end
|
|
69
59
|
|
|
70
|
-
def
|
|
71
|
-
|
|
72
|
-
if images_ids_or_names.include?(image[:id]) || images_ids_or_names.include?(image[:name])
|
|
73
|
-
images << (project_dangling_image?(image) ? image[:id] : image[:name])
|
|
74
|
-
end
|
|
75
|
-
end
|
|
60
|
+
def project_images_to_delete(project_images)
|
|
61
|
+
project_images.map { |image| image[:dangling] ? image[:id] : image[:name] }
|
|
76
62
|
end
|
|
77
63
|
|
|
78
64
|
def dapp_containers_flush
|
|
@@ -96,7 +82,7 @@ module Dapp
|
|
|
96
82
|
def check_user_containers!(images_ids)
|
|
97
83
|
return if images_ids.empty?
|
|
98
84
|
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?
|
|
85
|
+
raise ::Dapp::Error::Command, code: :user_containers_detected, data: { ids: res.stdout.strip } if res && !res.stdout.strip.empty? && !dry_run?
|
|
100
86
|
end
|
|
101
87
|
end
|
|
102
88
|
|
|
@@ -124,20 +110,32 @@ module Dapp
|
|
|
124
110
|
shellout!(cmd) unless dry_run?
|
|
125
111
|
end
|
|
126
112
|
|
|
113
|
+
def dimg_import_export_base(should_be_built: true)
|
|
114
|
+
repo = option_repo
|
|
115
|
+
validate_repo_name!(repo)
|
|
116
|
+
build_configs.each do |config|
|
|
117
|
+
log_dimg_name_with_indent(config) do
|
|
118
|
+
Dimg.new(config: config, dapp: self, ignore_git_fetch: true, should_be_built: should_be_built).tap do |dimg|
|
|
119
|
+
yield dimg
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
127
125
|
def container_name_prefix
|
|
128
126
|
name
|
|
129
127
|
end
|
|
130
128
|
|
|
131
129
|
def validate_repo_name!(repo)
|
|
132
|
-
raise Error::Command, code: :repo_name_incorrect, data: { name: repo } unless ::Dapp::Dimg::DockerRegistry.repo_name?(repo)
|
|
130
|
+
raise ::Dapp::Error::Command, code: :repo_name_incorrect, data: { name: repo } unless ::Dapp::Dimg::DockerRegistry.repo_name?(repo)
|
|
133
131
|
end
|
|
134
132
|
|
|
135
133
|
def validate_image_name!(image)
|
|
136
|
-
raise Error::Command, code: :image_name_incorrect, data: { name: image } unless ::Dapp::Dimg::Image::Docker.image_name?(image)
|
|
134
|
+
raise ::Dapp::Error::Command, code: :image_name_incorrect, data: { name: image } unless ::Dapp::Dimg::Image::Docker.image_name?(image)
|
|
137
135
|
end
|
|
138
136
|
|
|
139
137
|
def validate_tag_name!(tag)
|
|
140
|
-
raise Error::Command, code: :tag_name_incorrect, data: { name: tag } unless ::Dapp::Dimg::Image::Docker.tag?(tag)
|
|
138
|
+
raise ::Dapp::Error::Command, code: :tag_name_incorrect, data: { name: tag } unless ::Dapp::Dimg::Image::Docker.tag?(tag)
|
|
141
139
|
end
|
|
142
140
|
|
|
143
141
|
def proper_cache_version?
|
|
@@ -152,11 +150,6 @@ module Dapp
|
|
|
152
150
|
log_step_with_indent(:'proper repo cache', &blk)
|
|
153
151
|
end
|
|
154
152
|
|
|
155
|
-
def one_dimg!
|
|
156
|
-
return if build_configs.one?
|
|
157
|
-
raise Error::Command, code: :command_unexpected_dimgs_number, data: { dimgs_names: build_configs.map(&:_name).join(' ') }
|
|
158
|
-
end
|
|
159
|
-
|
|
160
153
|
def push_format(dimg_name)
|
|
161
154
|
if dimg_name.nil?
|
|
162
155
|
spush_format
|
|
@@ -169,6 +162,10 @@ module Dapp
|
|
|
169
162
|
'%{repo}:%{tag}'
|
|
170
163
|
end
|
|
171
164
|
|
|
165
|
+
def dimgstage_push_format
|
|
166
|
+
'%{repo}:dimgstage-%{signature}'
|
|
167
|
+
end
|
|
168
|
+
|
|
172
169
|
def with_stages?
|
|
173
170
|
!!options[:with_stages]
|
|
174
171
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Dapp
|
|
2
|
+
module Dimg
|
|
3
|
+
module Dapp
|
|
4
|
+
module Command
|
|
5
|
+
module FlushLocal
|
|
6
|
+
def flush_local
|
|
7
|
+
lock("#{name}.images") do
|
|
8
|
+
log_step_with_indent(:flush) do
|
|
9
|
+
remove_project_images(dapp_project_dimgs)
|
|
10
|
+
stages_flush_local if with_stages?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end # Dimg
|
|
18
|
+
end # Dapp
|
|
@@ -6,7 +6,7 @@ module Dapp
|
|
|
6
6
|
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
|
7
7
|
def mrproper
|
|
8
8
|
log_step_with_indent(:mrproper) do
|
|
9
|
-
raise Error::Command, code: :mrproper_required_option if mrproper_command_without_any_option?
|
|
9
|
+
raise ::Dapp::Error::Command, code: :mrproper_required_option if mrproper_command_without_any_option?
|
|
10
10
|
|
|
11
11
|
if proper_all?
|
|
12
12
|
proper_all
|
|
@@ -6,15 +6,9 @@ module Dapp
|
|
|
6
6
|
def push
|
|
7
7
|
#require 'ruby-prof'
|
|
8
8
|
#RubyProf.start
|
|
9
|
-
repo = option_repo
|
|
10
|
-
validate_repo_name!(repo)
|
|
11
9
|
log_step_with_indent(:stages) { stages_push } if with_stages?
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Dimg.new(config: config, dapp: self, ignore_git_fetch: true, should_be_built: true).tap do |dimg|
|
|
15
|
-
dimg.export!(repo, format: push_format(config._name))
|
|
16
|
-
end
|
|
17
|
-
end
|
|
10
|
+
dimg_import_export_base do |dimg|
|
|
11
|
+
dimg.export!(option_repo, format: push_format(dimg.config._name))
|
|
18
12
|
end
|
|
19
13
|
# FIXME: rework images cache, then profile
|
|
20
14
|
#result = RubyProf.stop
|
|
@@ -4,11 +4,9 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module Spush
|
|
6
6
|
def spush
|
|
7
|
-
repo = option_repo
|
|
8
|
-
validate_repo_name!(repo)
|
|
9
7
|
one_dimg!
|
|
10
|
-
|
|
11
|
-
dimg.export!(
|
|
8
|
+
dimg_import_export_base do |dimg|
|
|
9
|
+
dimg.export!(option_repo, format: spush_format)
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
12
|
end
|