dapp 0.22.6 → 0.22.7
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -6,9 +6,7 @@ module Dapp
|
|
6
6
|
module CleanupLocal
|
7
7
|
def stages_cleanup_local
|
8
8
|
lock_repo(option_repo, readonly: true) do
|
9
|
-
raise Error::Command, code: :stages_cleanup_required_option unless stages_cleanup_option?
|
10
|
-
|
11
|
-
dapp_project_containers_flush
|
9
|
+
raise ::Dapp::Error::Command, code: :stages_cleanup_required_option unless stages_cleanup_option?
|
12
10
|
|
13
11
|
proper_cache if proper_cache_version?
|
14
12
|
stages_cleanup_by_repo if proper_repo_cache?
|
@@ -21,18 +19,13 @@ module Dapp
|
|
21
19
|
def proper_cache
|
22
20
|
log_proper_cache do
|
23
21
|
lock("#{name}.images") do
|
24
|
-
remove_project_images(
|
22
|
+
remove_project_images(dapp_project_dimgstages - actual_cache_project_dimgstages)
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
def
|
30
|
-
@actual_cache_project_images_ids ||=
|
31
|
-
shellout!(%(#{host_docker} images -f "label=dapp" -f "label=dapp-cache-version=#{::Dapp::BUILD_CACHE_VERSION}" -q --no-trunc #{stage_cache}))
|
32
|
-
.stdout
|
33
|
-
.lines
|
34
|
-
.map(&:strip)
|
35
|
-
end
|
27
|
+
def actual_cache_project_dimgstages
|
28
|
+
@actual_cache_project_images_ids ||= prepare_docker_images("-f \"label=dapp-cache-version=#{::Dapp::BUILD_CACHE_VERSION}\" #{stage_cache}")
|
36
29
|
end
|
37
30
|
|
38
31
|
def stages_cleanup_by_repo
|
@@ -40,74 +33,76 @@ module Dapp
|
|
40
33
|
lock("#{name}.images") do
|
41
34
|
registry = dimg_registry(option_repo)
|
42
35
|
repo_dimgs = repo_detailed_dimgs_images(registry)
|
36
|
+
dimgstages = clone_dapp_project_dimgstages
|
43
37
|
|
44
|
-
|
45
|
-
|
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) }
|
38
|
+
repo_dimgs.each { |repo_dimg| except_image_id_with_parents(repo_dimg[:parent], dimgstages) }
|
48
39
|
|
49
40
|
# Удаление только образов старше 2ч
|
50
41
|
dimgstages.delete_if do |dimgstage|
|
51
42
|
Time.now - dimgstage[:created_at] < 2*60*60
|
52
43
|
end
|
53
44
|
|
54
|
-
remove_project_images(dimgstages
|
45
|
+
remove_project_images(dimgstages)
|
55
46
|
end
|
56
47
|
end
|
57
48
|
end
|
58
49
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
50
|
+
def clone_dapp_project_dimgstages
|
51
|
+
Marshal.load(Marshal.dump(dapp_project_dimgstages))
|
52
|
+
end
|
53
|
+
|
54
|
+
def except_image_id_with_parents(image_id, dimgstages)
|
55
|
+
return unless (project_image = dapp_project_image_by_id(image_id))
|
56
|
+
except_dapp_project_image_with_parents(project_image, dimgstages)
|
57
|
+
end
|
58
|
+
|
59
|
+
def except_dapp_project_image_with_parents(image, dimgstages)
|
60
|
+
dapp_project_image_artifacts_ids_in_labels(image).each { |aiid| except_image_id_with_parents(aiid, dimgstages) }
|
61
|
+
i = image
|
62
|
+
loop do
|
63
|
+
dimgstages.delete_if { |dimgstage| dimgstage == i }
|
64
|
+
break if (i = dapp_project_image_parent(i)).nil?
|
69
65
|
end
|
70
66
|
end
|
71
67
|
|
72
|
-
def dapp_project_image_artifacts_ids_in_labels(
|
73
|
-
select_dapp_artifacts_ids(dapp_project_image_labels(
|
68
|
+
def dapp_project_image_artifacts_ids_in_labels(image)
|
69
|
+
select_dapp_artifacts_ids(dapp_project_image_labels(image))
|
74
70
|
end
|
75
71
|
|
76
72
|
def proper_git_commit
|
77
73
|
log_proper_git_commit do
|
78
74
|
lock("#{name}.images") do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
dapp_project_images_ids.each do |image_id|
|
83
|
-
dapp_project_image_labels(image_id).each do |repo_name, commit|
|
75
|
+
unproper_images = []
|
76
|
+
dapp_project_dimgstages.each do |dimgstage|
|
77
|
+
dapp_project_image_labels(dimgstage).each do |repo_name, commit|
|
84
78
|
next if (repo = dapp_git_repositories[repo_name]).nil?
|
85
|
-
|
79
|
+
unproper_images.concat(dapp_project_image_with_children(dimgstage)) unless repo.commit_exists?(commit)
|
86
80
|
end
|
87
81
|
end
|
88
|
-
remove_project_images(
|
82
|
+
remove_project_images(unproper_images)
|
89
83
|
end
|
90
84
|
end
|
91
85
|
end
|
92
86
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
87
|
+
def dapp_project_image_with_children(image)
|
88
|
+
children = []
|
89
|
+
images = [image]
|
96
90
|
|
97
91
|
loop do
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end.flatten!.empty?
|
92
|
+
children.concat(dapp_project_images.select { |project_image| images.include?(project_image) })
|
93
|
+
images.map! do |parent_image|
|
94
|
+
dapp_project_images
|
95
|
+
.select { |project_image| dapp_project_image_parent(project_image) == parent_image }
|
103
96
|
end
|
97
|
+
images.flatten!
|
98
|
+
break if images.empty?
|
104
99
|
end
|
105
100
|
|
106
|
-
|
101
|
+
children
|
107
102
|
end
|
108
103
|
|
109
|
-
def
|
110
|
-
dapp_project_image_inspect(
|
104
|
+
def dapp_project_image_parent(image)
|
105
|
+
dapp_project_image_by_id(dapp_project_image_inspect(image)['Parent'])
|
111
106
|
end
|
112
107
|
end
|
113
108
|
end
|
@@ -6,17 +6,19 @@ module Dapp
|
|
6
6
|
module CleanupRepo
|
7
7
|
def stages_cleanup_repo
|
8
8
|
lock_repo(repo = option_repo) do
|
9
|
-
raise Error::Command, code: :stages_cleanup_required_option unless stages_cleanup_option?
|
9
|
+
raise ::Dapp::Error::Command, code: :stages_cleanup_required_option unless stages_cleanup_option?
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
log_step_with_indent("#{repo} stages") do
|
12
|
+
registry = dimg_registry(repo)
|
13
|
+
repo_dimgs = repo_dimgs_images(registry)
|
14
|
+
repo_dimgstages = repo_dimgstages_images(registry)
|
14
15
|
|
15
|
-
|
16
|
+
repo_dimgstages.delete_if { |dimgstage| repo_dimgs.any? { |dimg| dimgstage[:id] == dimg[:id] } } # ignoring stages with dimgs ids (v2)
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
proper_repo_cache(registry, repo_dimgstages) if proper_cache_version?
|
19
|
+
repo_dimgstages_cleanup(registry, repo_dimgs, repo_dimgstages) if proper_repo_cache?
|
20
|
+
proper_repo_git_commit(registry) if proper_git_commit?
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -31,24 +33,24 @@ module Dapp
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def repo_dimgstages_cleanup(registry, repo_dimgs, repo_dimgstages)
|
34
|
-
|
35
|
-
repo_dimgs.each { |dimg| except_repo_image_with_parents(registry,
|
36
|
+
log_proper_repo_cache do
|
37
|
+
repo_dimgs.each { |dimg| except_repo_image_with_parents(registry, dimg, repo_dimgstages) }
|
36
38
|
repo_dimgstages.each { |dimgstage| delete_repo_image(registry, dimgstage) }
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
def except_repo_image_with_parents(registry,
|
41
|
-
repo_image_dapp_artifacts_labels(registry, repo_image).each do |
|
42
|
-
|
43
|
-
|
42
|
+
def except_repo_image_with_parents(registry, repo_image, repo_dimgstages)
|
43
|
+
repo_image_dapp_artifacts_labels(registry, repo_image).each do |aiid|
|
44
|
+
unless (repo_artifact_image = repo_image_by_id(aiid, repo_dimgstages)).nil?
|
45
|
+
except_repo_image_with_parents(registry, repo_artifact_image, repo_dimgstages)
|
46
|
+
end
|
44
47
|
end
|
45
48
|
|
49
|
+
ri = repo_image
|
46
50
|
loop do
|
47
|
-
repo_dimgstages.delete_if { |dimgstage| dimgstage
|
48
|
-
|
49
|
-
|
50
|
-
(repo_image = find_repo_image_by_id(repo_dimgstages, iid)).nil?
|
51
|
-
end
|
51
|
+
repo_dimgstages.delete_if { |dimgstage| dimgstage == ri }
|
52
|
+
ri_parent_id = registry.image_parent_id(ri[:tag], ri[:dimg])
|
53
|
+
break if ri_parent_id.empty? || (ri = repo_image_by_id(ri_parent_id, repo_dimgstages)).nil?
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -60,20 +62,20 @@ module Dapp
|
|
60
62
|
registry.image_labels(repo_image[:tag], repo_image[:dimg])['dapp-cache-version']
|
61
63
|
end
|
62
64
|
|
63
|
-
def
|
65
|
+
def repo_image_by_id(repo_image_id, repo_images)
|
64
66
|
repo_images.find { |repo_image| repo_image[:id] == repo_image_id }
|
65
67
|
end
|
66
68
|
|
67
69
|
def proper_repo_git_commit(registry)
|
68
70
|
log_proper_git_commit do
|
69
|
-
|
71
|
+
unproper_dimgstages = []
|
70
72
|
repo_detailed_dimgstage_images(registry).each do |dimgstage|
|
71
73
|
dimgstage[:labels].each do |repo_name, commit|
|
72
74
|
next if (repo = dapp_git_repositories[repo_name]).nil?
|
73
|
-
|
75
|
+
unproper_dimgstages.concat(repo_detailed_image_with_children(registry, dimgstage)) unless repo.commit_exists?(commit)
|
74
76
|
end
|
75
77
|
end
|
76
|
-
|
78
|
+
unproper_dimgstages.uniq.each { |dimgstage| delete_repo_image(registry, dimgstage) }
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
@@ -87,27 +89,21 @@ module Dapp
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
90
|
-
def
|
91
|
-
|
92
|
-
|
92
|
+
def repo_detailed_image_with_children(registry, image)
|
93
|
+
children = []
|
94
|
+
detailed_images = [image]
|
93
95
|
|
94
96
|
loop do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end.flatten!.empty?
|
97
|
+
children.concat(detailed_images)
|
98
|
+
detailed_images.map! do |repo_image|
|
99
|
+
repo_detailed_dimgstage_images(registry)
|
100
|
+
.select { |dimgstage| dimgstage[:parent] == repo_image[:id] }
|
100
101
|
end
|
102
|
+
detailed_images.flatten!
|
103
|
+
break if detailed_images.empty?
|
101
104
|
end
|
102
105
|
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
def remove_repo_dapp_dimgstage_images(registry, tags)
|
107
|
-
tags.each do |tag|
|
108
|
-
log(tag) if log_verbose? || dry_run?
|
109
|
-
registry.image_delete(tag, nil) unless dry_run?
|
110
|
-
end
|
106
|
+
children
|
111
107
|
end
|
112
108
|
end
|
113
109
|
end
|
@@ -6,6 +6,14 @@ module Dapp
|
|
6
6
|
module Common
|
7
7
|
protected
|
8
8
|
|
9
|
+
def repo_detailed_dimgs_images(registry)
|
10
|
+
repo_dimgs_images(registry).each do |dimg|
|
11
|
+
image_history = registry.image_history(dimg[:tag], dimg[:dimg])
|
12
|
+
dimg[:parent] = image_history['container_config']['Image']
|
13
|
+
dimg[:labels] = image_history['config']['Labels']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
def repo_dimgs_images(registry)
|
10
18
|
[].tap do |dimgs_images|
|
11
19
|
{}.tap do |dimgs_tags|
|
@@ -53,9 +61,11 @@ module Dapp
|
|
53
61
|
{}.tap do |repositories|
|
54
62
|
dimgs = build_configs.map { |config| Dimg.new(config: config, dapp: self, ignore_git_fetch: true) }
|
55
63
|
dimgs.each do |dimg|
|
56
|
-
[dimg, dimg.artifacts]
|
57
|
-
|
58
|
-
|
64
|
+
[dimg, dimg.artifacts]
|
65
|
+
.flatten
|
66
|
+
.map(&:git_artifacts)
|
67
|
+
.flatten
|
68
|
+
.map { |git_artifact| repositories[dimgstage_g_a_commit_label(git_artifact.paramshash)] = git_artifact.repo }
|
59
69
|
end
|
60
70
|
end
|
61
71
|
end
|
@@ -6,9 +6,7 @@ module Dapp
|
|
6
6
|
module FlushLocal
|
7
7
|
def stages_flush_local
|
8
8
|
lock("#{name}.images") do
|
9
|
-
|
10
|
-
dapp_project_dangling_images_flush
|
11
|
-
remove_project_images(dapp_project_images_ids)
|
9
|
+
log_step_with_indent('flush stages') { remove_project_images(dapp_project_dimgstages) }
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -5,9 +5,9 @@ module Dapp
|
|
5
5
|
module Stages
|
6
6
|
module FlushRepo
|
7
7
|
def stages_flush_repo
|
8
|
-
lock_repo(option_repo) do
|
9
|
-
log_step_with_indent(
|
10
|
-
registry = dimg_registry(
|
8
|
+
lock_repo(repo = option_repo) do
|
9
|
+
log_step_with_indent("#{repo} stages") do
|
10
|
+
registry = dimg_registry(repo)
|
11
11
|
repo_dimgstages_images(registry).each { |repo_image| delete_repo_image(registry, repo_image) }
|
12
12
|
end
|
13
13
|
end
|
@@ -5,20 +5,10 @@ module Dapp
|
|
5
5
|
module Stages
|
6
6
|
module Pull
|
7
7
|
def stages_pull
|
8
|
-
|
9
|
-
|
10
|
-
build_configs.each do |config|
|
11
|
-
log_dimg_name_with_indent(config) do
|
12
|
-
Dimg.new(config: config, dapp: self, ignore_git_fetch: true).tap do |dimg|
|
13
|
-
dimg.import_stages!(repo, format: '%{repo}:dimgstage-%{signature}')
|
14
|
-
end
|
15
|
-
end
|
8
|
+
dimg_import_export_base(should_be_built: false) do |dimg|
|
9
|
+
dimg.import_stages!(option_repo, format: dimgstage_push_format)
|
16
10
|
end
|
17
11
|
end
|
18
|
-
|
19
|
-
def pull_all_stages?
|
20
|
-
!!options[:pull_all_stages]
|
21
|
-
end
|
22
12
|
end
|
23
13
|
end
|
24
14
|
end
|
@@ -5,14 +5,8 @@ module Dapp
|
|
5
5
|
module Stages
|
6
6
|
module Push
|
7
7
|
def stages_push
|
8
|
-
|
9
|
-
|
10
|
-
build_configs.each do |config|
|
11
|
-
log_dimg_name_with_indent(config) do
|
12
|
-
Dimg.new(config: config, dapp: self, ignore_git_fetch: true, should_be_built: true).tap do |dimg|
|
13
|
-
dimg.export_stages!(repo, format: '%{repo}:dimgstage-%{signature}')
|
14
|
-
end
|
15
|
-
end
|
8
|
+
dimg_import_export_base(should_be_built: false) do |dimg|
|
9
|
+
dimg.export_stages!(option_repo, format: dimgstage_push_format)
|
16
10
|
end
|
17
11
|
end
|
18
12
|
end
|
@@ -3,12 +3,9 @@ module Dapp
|
|
3
3
|
module Dapp
|
4
4
|
module Command
|
5
5
|
module Tag
|
6
|
-
def tag
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Dimg.new(config: build_configs.first, dapp: self, ignore_git_fetch: true, should_be_built: true).tap do |app|
|
11
|
-
app.tag!(tag)
|
6
|
+
def tag
|
7
|
+
dimg_import_export_base do |dimg|
|
8
|
+
dimg.tag!(option_repo, format: push_format(dimg.config._name))
|
12
9
|
end
|
13
10
|
end
|
14
11
|
end
|
data/lib/dapp/dimg/dapp/dapp.rb
CHANGED
@@ -6,6 +6,16 @@ module Dapp
|
|
6
6
|
dimgs_names.first.nil?
|
7
7
|
end
|
8
8
|
|
9
|
+
def dimg_name!
|
10
|
+
one_dimg!
|
11
|
+
build_configs.first._name
|
12
|
+
end
|
13
|
+
|
14
|
+
def one_dimg!
|
15
|
+
return if build_configs.one?
|
16
|
+
raise ::Dapp::Error::Command, code: :command_unexpected_dimgs_number, data: { dimgs_names: build_configs.map(&:_name).join('`, `') }
|
17
|
+
end
|
18
|
+
|
9
19
|
def dimgs_names
|
10
20
|
build_configs.map(&:_name)
|
11
21
|
end
|
@@ -15,7 +25,7 @@ module Dapp
|
|
15
25
|
config._dimg.select do |dimg|
|
16
26
|
dimgs_patterns.any? { |pattern| dimg._name.nil? || File.fnmatch(pattern, dimg._name) }
|
17
27
|
end.tap do |dimgs|
|
18
|
-
raise ::Dapp::Error::Dapp, code: :no_such_dimg, data: { dimgs_patterns: dimgs_patterns.join('
|
28
|
+
raise ::Dapp::Error::Dapp, code: :no_such_dimg, data: { dimgs_patterns: dimgs_patterns.join('`, `') } if dimgs.empty?
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
data/lib/dapp/dimg/dimg.rb
CHANGED
@@ -46,53 +46,60 @@ module Dapp
|
|
46
46
|
artifacts.each { |artifact| artifact.last_stage.save_in_cache! }
|
47
47
|
end
|
48
48
|
|
49
|
-
def tag!(
|
49
|
+
def tag!(repo, format:)
|
50
|
+
dimg_export_base!(repo, export_format: format)
|
51
|
+
end
|
52
|
+
|
53
|
+
def export!(repo, format:)
|
54
|
+
dimg_export_base!(repo, export_format: format, push: true)
|
55
|
+
end
|
56
|
+
|
57
|
+
def export_stages!(repo, format:)
|
50
58
|
dapp.lock("#{dapp.name}.images", readonly: true) do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
dapp.log_process(dimg_name, process: dapp.t(code: 'status.process.tagging')) do
|
56
|
-
last_stage.image.tag!(tag)
|
59
|
+
export_images.each do |stage_image|
|
60
|
+
image_name = format(format, repo: repo, signature: stage_image.name.split(':').last)
|
61
|
+
export_base!(image_name, push: true) do
|
62
|
+
stage_image.export!(image_name)
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
61
67
|
|
62
|
-
def
|
68
|
+
def dimg_export_base!(repo, export_format:, push: false)
|
63
69
|
dapp.lock("#{dapp.name}.images", readonly: true) do
|
64
70
|
dapp.tags_by_scheme.each do |tag_scheme_name, tags|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
71
|
+
dapp.log_step_with_indent(tag_scheme_name) do
|
72
|
+
tags.each do |tag|
|
73
|
+
image_name = format(export_format, repo: repo, dimg_name: config._name, tag: tag)
|
74
|
+
export_base!(image_name, push: push) do
|
75
|
+
export_image = build_export_image!(image_name, scheme_name: tag_scheme_name)
|
76
|
+
if push
|
77
|
+
export_image.export!
|
78
|
+
else
|
79
|
+
export_image.tag!
|
80
|
+
end
|
81
|
+
end
|
69
82
|
end
|
70
|
-
end
|
83
|
+
end unless tags.empty?
|
71
84
|
end
|
72
85
|
end
|
73
86
|
end
|
74
87
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
image.export!(image_name)
|
81
|
-
end
|
82
|
-
end
|
88
|
+
def build_export_image!(image_name, scheme_name:)
|
89
|
+
Image::Dimg.image_by_name(name: image_name, from: last_stage.image, dapp: dapp).tap do |export_image|
|
90
|
+
export_image.add_service_change_label(:'dapp-tag-scheme' => scheme_name)
|
91
|
+
export_image.add_service_change_label(:'dapp-dimg' => true)
|
92
|
+
export_image.build!
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
86
|
-
def export_base!(image_name)
|
96
|
+
def export_base!(image_name, push: true)
|
87
97
|
if dapp.dry_run?
|
88
|
-
dapp.log_state(image_name, state: dapp.t(code: 'state.push'), styles: { status: :success })
|
98
|
+
dapp.log_state(image_name, state: dapp.t(code: push ? 'state.push' : 'state.export'), styles: { status: :success })
|
89
99
|
else
|
90
100
|
dapp.lock("image.#{hashsum image_name}") do
|
91
101
|
::Dapp::Dimg::Image::Docker.reset_image_inspect(image_name)
|
92
|
-
|
93
|
-
dapp.log_process(image_name, process: dapp.t(code: 'status.process.pushing')) do
|
94
|
-
yield
|
95
|
-
end
|
102
|
+
dapp.log_process(image_name, process: dapp.t(code: push ? 'status.process.pushing' : 'status.process.exporting')) { yield }
|
96
103
|
end
|
97
104
|
end
|
98
105
|
end
|
@@ -107,7 +114,7 @@ module Dapp
|
|
107
114
|
dapp.log_info ::Dapp::Helper::NetStatus.message(e)
|
108
115
|
next
|
109
116
|
end
|
110
|
-
break unless dapp.pull_all_stages
|
117
|
+
break unless !!dapp.options[:pull_all_stages]
|
111
118
|
end
|
112
119
|
end
|
113
120
|
end
|
@@ -117,9 +124,10 @@ module Dapp
|
|
117
124
|
dapp.log_state(image_name, state: dapp.t(code: 'state.pull'), styles: { status: :success })
|
118
125
|
else
|
119
126
|
dapp.lock("image.#{hashsum image_name}") do
|
120
|
-
dapp.log_process(image_name,
|
121
|
-
|
122
|
-
|
127
|
+
dapp.log_process(image_name,
|
128
|
+
process: dapp.t(code: 'status.process.pulling'),
|
129
|
+
status: { failed: dapp.t(code: 'status.failed.not_pulled') },
|
130
|
+
style: { failed: :secondary }) do
|
123
131
|
image.import!(image_name)
|
124
132
|
end
|
125
133
|
end
|