dapp 0.24.4 → 0.24.5
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/lib/dapp/dimg/artifact.rb +2 -2
- data/lib/dapp/dimg/dapp/command/common.rb +14 -6
- data/lib/dapp/dimg/dimg/git_artifact.rb +6 -3
- data/lib/dapp/dimg/dimg/stages.rb +16 -4
- data/lib/dapp/dimg/git_artifact.rb +17 -13
- data/lib/dapp/dimg/git_repo/base.rb +3 -24
- data/lib/dapp/dimg/git_repo/local.rb +2 -2
- data/lib/dapp/dimg/git_repo/own.rb +2 -6
- data/lib/dapp/dimg/git_repo/remote.rb +27 -5
- 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: ed725aab664bfb2ec80a0c818bd83cf216dffadb
|
4
|
+
data.tar.gz: 8b64733931dc8da20c647c400510152fcf4eb044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f50ab878df68cd4693eb6682fa9094bcf24bf94b29743daab8853718c0a3c3cc9c2e371a13e0cf3db53914112231f82b0020c07c947664eb8a7b38335e04c93
|
7
|
+
data.tar.gz: a4010b1a1d54582f3ad08368ddc70011f1785d503e15f762f9cf12047329d016c7737c7061d1ae180dd1ba56d2b7a6fcb5222049bb5df42b87152c4c4fb3db3f
|
data/lib/dapp/dimg/artifact.rb
CHANGED
@@ -83,15 +83,23 @@ module Dapp
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def ignore_used_images(images_ids_or_names)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
else
|
86
|
+
not_used_images = proc do |*image_id_or_name, log: true|
|
87
|
+
images = image_id_or_name.flatten
|
88
|
+
filters = images.map { |iion| "--filter=ancestor=#{iion}" }.join(' ')
|
89
|
+
res = shellout!(%(#{host_docker} ps -a -q #{filters})).stdout.strip
|
90
|
+
if res.empty?
|
92
91
|
true
|
92
|
+
else
|
93
|
+
log_info("Skip `#{images.join('`, `')}` (used by containers: #{res.split.join(' ')})") if log
|
94
|
+
false
|
93
95
|
end
|
94
96
|
end
|
97
|
+
|
98
|
+
if not_used_images.call(images_ids_or_names, log: false)
|
99
|
+
images_ids_or_names
|
100
|
+
else
|
101
|
+
images_ids_or_names.select(¬_used_images)
|
102
|
+
end
|
95
103
|
end
|
96
104
|
|
97
105
|
def remove_containers_by_query(containers_query)
|
@@ -9,7 +9,7 @@ module Dapp
|
|
9
9
|
def local_git_artifacts
|
10
10
|
@local_git_artifact_list ||= [].tap do |artifacts|
|
11
11
|
break artifacts if (local_git_artifacts = Array(config._git_artifact._local)).empty?
|
12
|
-
repo = GitRepo::Own.new(
|
12
|
+
repo = GitRepo::Own.new(dapp)
|
13
13
|
local_git_artifacts.map do |ga_config|
|
14
14
|
artifacts.concat(generate_git_artifacts(repo, **ga_config._artifact_options))
|
15
15
|
end
|
@@ -19,7 +19,10 @@ module Dapp
|
|
19
19
|
def remote_git_artifacts
|
20
20
|
@remote_git_artifact_list ||= [].tap do |artifacts|
|
21
21
|
Array(config._git_artifact._remote).each do |ga_config|
|
22
|
-
repo = GitRepo::Remote.
|
22
|
+
repo = GitRepo::Remote.get_or_create(dapp, ga_config._name,
|
23
|
+
url: ga_config._url,
|
24
|
+
branch: ga_config._branch,
|
25
|
+
ignore_git_fetch: ignore_git_fetch)
|
23
26
|
artifacts.concat(generate_git_artifacts(repo, **ga_config._artifact_options))
|
24
27
|
end
|
25
28
|
end
|
@@ -27,7 +30,7 @@ module Dapp
|
|
27
30
|
|
28
31
|
def generate_git_artifacts(repo, **git_artifact_options)
|
29
32
|
[].tap do |artifacts|
|
30
|
-
artifacts << (artifact = ::Dapp::Dimg::GitArtifact.new(repo, **git_artifact_options))
|
33
|
+
artifacts << (artifact = ::Dapp::Dimg::GitArtifact.new(repo, self, **git_artifact_options))
|
31
34
|
artifacts.concat(generate_git_embedded_artifacts(artifact))
|
32
35
|
end
|
33
36
|
end
|
@@ -31,13 +31,25 @@ module Dapp
|
|
31
31
|
stages + artifacts.map(&:all_stages).flatten
|
32
32
|
end
|
33
33
|
|
34
|
+
def last_stage
|
35
|
+
@last_stage || begin
|
36
|
+
(self.last_stage = last_stage_class.new(self)).tap do |stage|
|
37
|
+
dapp.log_secondary_process("#{config._name || 'nameless'}: calculating stages signatures") do
|
38
|
+
stage.signature
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
34
44
|
protected
|
35
45
|
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
attr_writer :last_stage
|
47
|
+
|
48
|
+
def last_stage_class
|
49
|
+
if scratch?
|
50
|
+
Build::Stage::ImportArtifact
|
39
51
|
else
|
40
|
-
Build::Stage::DockerInstructions
|
52
|
+
Build::Stage::DockerInstructions
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
@@ -12,10 +12,11 @@ module Dapp
|
|
12
12
|
# FIXME: переименовать cwd в from
|
13
13
|
|
14
14
|
# rubocop:disable Metrics/ParameterLists
|
15
|
-
def initialize(repo, to:, name: nil, branch: nil, commit: nil,
|
15
|
+
def initialize(repo, dimg, to:, name: nil, branch: nil, commit: nil,
|
16
16
|
cwd: nil, include_paths: nil, exclude_paths: nil, owner: nil, group: nil, as: nil,
|
17
17
|
stages_dependencies: {})
|
18
18
|
@repo = repo
|
19
|
+
@dimg = dimg
|
19
20
|
@name = name
|
20
21
|
|
21
22
|
@branch = branch || repo.dapp.options[:git_artifact_branch] || repo.branch
|
@@ -69,17 +70,19 @@ module Dapp
|
|
69
70
|
embedded_rel_path = embedded_params[:path]
|
70
71
|
embedded_repo = begin
|
71
72
|
if embedded_params[:type] == :remote
|
72
|
-
GitRepo::Remote.
|
73
|
-
|
73
|
+
GitRepo::Remote.get_or_create(repo.dapp, embedded_rel_path,
|
74
|
+
url: embedded_params[:url],
|
75
|
+
branch: embedded_params[:branch],
|
76
|
+
ignore_git_fetch: dimg.ignore_git_fetch )
|
74
77
|
elsif embedded_params[:type] == :local
|
75
78
|
embedded_path = File.join(repo.workdir_path, embedded_params[:path])
|
76
|
-
GitRepo::Local.new(repo.
|
79
|
+
GitRepo::Local.new(repo.dapp, embedded_rel_path, embedded_path)
|
77
80
|
else
|
78
81
|
raise
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
82
|
-
self.class.new(embedded_repo, embedded_artifact_options(embedded_params))
|
85
|
+
self.class.new(embedded_repo, dimg, embedded_artifact_options(embedded_params))
|
83
86
|
end
|
84
87
|
|
85
88
|
def embedded_artifact_options(embedded_params)
|
@@ -293,6 +296,7 @@ module Dapp
|
|
293
296
|
Digest::SHA256.hexdigest args.compact.map {|arg| arg.to_s.force_encoding("ASCII-8BIT")}.join(":::")
|
294
297
|
end
|
295
298
|
|
299
|
+
attr_reader :dimg
|
296
300
|
attr_reader :to
|
297
301
|
attr_reader :commit
|
298
302
|
attr_reader :branch
|
@@ -316,11 +320,11 @@ module Dapp
|
|
316
320
|
else
|
317
321
|
archive_file_with_tar_writer(stage, commit)
|
318
322
|
end
|
319
|
-
|
323
|
+
dimg.container_tmp_path('archives', archive_file_name(commit))
|
320
324
|
end
|
321
325
|
|
322
326
|
def archive_file_with_tar_writer(stage, commit)
|
323
|
-
tar_write(
|
327
|
+
tar_write(dimg.tmp_path('archives', archive_file_name(commit))) do |tar|
|
324
328
|
each_archive_entry(stage, commit) do |path, content, mode|
|
325
329
|
if mode == 0o120000 # symlink
|
326
330
|
tar.add_symlink path, content, mode
|
@@ -336,10 +340,10 @@ module Dapp
|
|
336
340
|
end
|
337
341
|
|
338
342
|
def archive_file_with_system_tar(stage, commit)
|
339
|
-
|
343
|
+
dimg.tmp_path('archives', archive_file_name(commit)).tap do |archive_path|
|
340
344
|
relative_archive_file_path = File.join('archives_files', file_name(commit))
|
341
345
|
each_archive_entry(stage, commit) do |path, content, mode|
|
342
|
-
file_path =
|
346
|
+
file_path = dimg.tmp_path(relative_archive_file_path, path)
|
343
347
|
|
344
348
|
if mode == 0o120000 # symlink
|
345
349
|
FileUtils.symlink(content, file_path)
|
@@ -349,7 +353,7 @@ module Dapp
|
|
349
353
|
end
|
350
354
|
end
|
351
355
|
|
352
|
-
repo.dapp.shellout!("tar -C #{
|
356
|
+
repo.dapp.shellout!("tar -C #{dimg.tmp_path(relative_archive_file_path)} -cf #{archive_path} .")
|
353
357
|
end
|
354
358
|
end
|
355
359
|
|
@@ -375,10 +379,10 @@ module Dapp
|
|
375
379
|
end
|
376
380
|
|
377
381
|
def patch_file(stage, from_commit, to_commit)
|
378
|
-
File.open(
|
382
|
+
File.open(dimg.tmp_path('patches', patch_file_name(from_commit, to_commit)), File::RDWR | File::CREAT) do |f|
|
379
383
|
diff_patches(from_commit, to_commit).each { |patch| f.write change_patch_new_file_path(stage, patch) }
|
380
384
|
end
|
381
|
-
|
385
|
+
dimg.container_tmp_path('patches', patch_file_name(from_commit, to_commit))
|
382
386
|
end
|
383
387
|
|
384
388
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -548,7 +552,7 @@ module Dapp
|
|
548
552
|
end
|
549
553
|
|
550
554
|
def dev_mode?
|
551
|
-
local? &&
|
555
|
+
local? && dimg.dev_mode?
|
552
556
|
end
|
553
557
|
|
554
558
|
def local?
|
@@ -6,32 +6,13 @@ module Dapp
|
|
6
6
|
include Helper::Trivia
|
7
7
|
|
8
8
|
attr_reader :name
|
9
|
+
attr_reader :dapp
|
9
10
|
|
10
|
-
def initialize(
|
11
|
-
@
|
11
|
+
def initialize(dapp, name)
|
12
|
+
@dapp = dapp
|
12
13
|
@name = name
|
13
14
|
end
|
14
15
|
|
15
|
-
def dapp
|
16
|
-
@dapp ||= begin
|
17
|
-
if manager.is_a? ::Dapp::Dapp
|
18
|
-
manager
|
19
|
-
else
|
20
|
-
dimg.dapp
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def dimg
|
26
|
-
@dimg ||= begin
|
27
|
-
if manager.is_a? ::Dapp::Dimg::Dimg
|
28
|
-
manager
|
29
|
-
else
|
30
|
-
raise
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
16
|
def exclude_paths
|
36
17
|
[]
|
37
18
|
end
|
@@ -208,8 +189,6 @@ module Dapp
|
|
208
189
|
|
209
190
|
protected
|
210
191
|
|
211
|
-
attr_reader :manager
|
212
|
-
|
213
192
|
def git(**kwargs)
|
214
193
|
@git ||= Rugged::Repository.new(path.to_s, **kwargs)
|
215
194
|
end
|
@@ -2,12 +2,8 @@ module Dapp
|
|
2
2
|
module Dimg
|
3
3
|
module GitRepo
|
4
4
|
class Own < Local
|
5
|
-
def initialize(
|
6
|
-
super(
|
7
|
-
end
|
8
|
-
|
9
|
-
def path=(_)
|
10
|
-
super(dapp.path.to_s)
|
5
|
+
def initialize(dapp)
|
6
|
+
super(dapp, 'own', dapp.path.to_s)
|
11
7
|
end
|
12
8
|
|
13
9
|
def exclude_paths
|
@@ -5,9 +5,31 @@ module Dapp
|
|
5
5
|
CACHE_VERSION = 1
|
6
6
|
|
7
7
|
attr_reader :url
|
8
|
+
attr_reader :path
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def get_or_create(dapp, name, url:, branch:, ignore_git_fetch: false)
|
12
|
+
key = [url, branch, ignore_git_fetch]
|
13
|
+
inverse_key = [url, branch, !ignore_git_fetch]
|
14
|
+
|
15
|
+
repositories[key] ||= begin
|
16
|
+
if repositories.key?(inverse_key)
|
17
|
+
repositories[inverse_key]
|
18
|
+
else
|
19
|
+
new(dapp, name, url: url)
|
20
|
+
end.tap do |repo|
|
21
|
+
repo.fetch!(branch, ignore_git_fetch: ignore_git_fetch) unless ignore_git_fetch
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def repositories
|
27
|
+
@repositories ||= {}
|
28
|
+
end
|
29
|
+
end
|
8
30
|
|
9
|
-
def initialize(
|
10
|
-
super(
|
31
|
+
def initialize(dapp, name, url:)
|
32
|
+
super(dapp, name)
|
11
33
|
|
12
34
|
@url = url
|
13
35
|
|
@@ -41,10 +63,10 @@ module Dapp
|
|
41
63
|
end
|
42
64
|
|
43
65
|
def path
|
44
|
-
Pathname(
|
66
|
+
Pathname(dapp.build_path("remote_git_repo", CACHE_VERSION.to_s, name).to_s)
|
45
67
|
end
|
46
68
|
|
47
|
-
def fetch!(branch = nil)
|
69
|
+
def fetch!(branch = nil, ignore_git_fetch: false)
|
48
70
|
_with_lock do
|
49
71
|
branch ||= self.branch
|
50
72
|
|
@@ -66,7 +88,7 @@ module Dapp
|
|
66
88
|
end
|
67
89
|
raise Error::Rugged, code: :branch_not_exist_in_remote_git_repository, data: { branch: branch, url: url } unless branch_exist?(branch)
|
68
90
|
end
|
69
|
-
end unless
|
91
|
+
end unless ignore_git_fetch || dapp.dry_run?
|
70
92
|
end
|
71
93
|
|
72
94
|
def branch_exist?(name)
|
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.24.
|
4
|
+
version: 0.24.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|